hudsonfleite 17 de mar. de 2004
Para que o titulo da coluna apareça é necessário colocá-lo dentro de um componente JScrollPane, tipo assim:
import javax.swing.* ;
import java.awt.* ;
public class teste extends JFrame & # 123 ;
public teste & # 40 ; & # 41 ; & # 123 ;
super & # 40 ; "Teste" & # 41 ;;
setSize & # 40 ; 600 , 600 & # 41 ;;
JTable t = new JTable & # 40 ; new Object & # 91 ; & # 93 ; & # 91 ; & # 93 ; & # 123 ; & # 125 ;, new String & # 91 ; & # 93 ; & # 123 ; "Nome" , "Fone" & # 125 ; & # 41 ;;
t . setPreferredScrollableViewportSize & # 40 ; new Dimension & # 40 ; 600 , 400 & # 41 ; & # 41 ;;
JScrollPane s = new JScrollPane & # 40 ; t & # 41 ;;
getContentPane & # 40 ; & # 41 ;. setLayout & # 40 ; new BorderLayout & # 40 ; & # 41 ; & # 41 ;;
getContentPane & # 40 ; & # 41 ;. add & # 40 ; s , BorderLayout . CENTER & # 41 ;;
& # 125 ;
public static void main & # 40 ; String & # 91 ; & # 93 ; args & # 41 ; & # 123 ;
new teste & # 40 ; & # 41 ;. show & # 40 ; & # 41 ;;
& # 125 ;
& # 125 ;
Espero ter sido útil.
charlesSouza 18 de mar. de 2004
o que vc mandou funcionou, mas meu código nao funciona, se vc ver algum erro no código me avise. aqui esta a parte do código (o resto funciona normal):
import javax.swing. < em > ;
import java.awt. </ em > ;
import javax.swing.table. < em > ;
import javax.swing.event. </ em > ;
public class CisalhamentoDireto implements TableModelListener
{
static final int numLinhas = 24 ;
int numTabbed = 0 ;
int totalLinhasUsadas = 0 ;
JanelaInterna novoCisalhamentoDireto;
ModeloTabela modelo;
JTable tabelaDados;
static TabbedPane tabbed;
Object dados[][];
public CisalhamentoDireto( JDesktopPane desktop, int numeroCisalhamento )
{
dados = new Object[ numLinhas ][ 7 ];
numeroCisalhamento ++;
novoCisalhamentoDireto = new JanelaInterna ( "CisalhamentoDireto" + numeroCisalhamento );
novoCisalhamentoDireto . setResizable ( false );
novoCisalhamentoDireto . setSize ( 1000 , 600 );
modelo = new ModeloTabela ();
tabelaDados = new JTable ( dados , new String [] { "Vertical lv", "Horizontal lh", "Mola lm", "%", "cm3", "kgf", "kgf cm2" } );
tabelaDados . setModel ( modelo );
tabelaDados . setCellSelectionEnabled ( true );
modelo . addTableModelListener ( this );
tabelaDados . setPreferredScrollableViewportSize ( new Dimension ( 700 , 400 ));
JScrollPane scroll = new JScrollPane ( tabelaDados );
tabbed = new TabbedPane ( scroll );
novoCisalhamentoDireto . getContentPane () . add ( tabbed );
novoCisalhamentoDireto . show ();
desktop . add ( novoCisalhamentoDireto );
try
{
novoCisalhamentoDireto.setSelected( true ) ;
} catch ( java . beans . PropertyVetoException e ) { JOptionPane.showMessageDialog( null, e + ": CisalhamentoDireto. java : linha46 " );}
}