TableColumnAdjuster , . - .
SSCCE, 5 , TableColumnAdjuster:
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class SSCCE extends JPanel
{
public SSCCE()
{
setLayout( new BorderLayout() );
String[] columnNames = {"Column1", "Column with big header text", "Column3"};
DefaultTableModel model = new DefaultTableModel(columnNames, 3);
model.setValueAt("column1 data", 0, 0);
model.setValueAt("column2 data", 1, 1);
model.setValueAt("column3 long data", 2, 2);
JTable table = new JTable( model );
add( new JScrollPane( table ) );
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnAdjuster tca = new TableColumnAdjuster(table);
tca.adjustColumns();
}
private static void createAndShowGUI()
{
JFrame frame = new JFrame("SSCCE");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new SSCCE());
frame.setLocationByPlatform( true );
frame.pack();
frame.setVisible( true );
}
public static void main(String[] args)
{
EventQueue.invokeLater( () -> createAndShowGUI() );
}
}
, , ?
? ?
, , ?
/ ?
SSCCE, .