1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| package test.jxtable;
import org.jdesktop.swingx.JXTable;
import javax.swing.*;
import java.awt.*;
public final class Main extends JFrame {
Main() {
// Columns.
final var columns = new String[]{
"Id", "Name", "Hourly Rate", "Part Time"
};
// Data.
final var data = new Object[][]{
{1, "John", 40.0, false},
{2, "Rambo", 70.0, false},
{3, "Zorro", 60.0, true},
};
final var table = new JXTable(data, columns);
table.setShowGrid(true);
// table.setColumnControlVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
add(new JScrollPane(table), BorderLayout.CENTER);
setTitle("Test");
setPreferredSize(new Dimension(800, 600));
}
public static void main(final String... args) {
SwingUtilities.invokeLater(() -> launch(args));
}
private static void launch(final String... args) {
final var main = new Main();
main.pack();
main.setVisible(true);
}
} |
Partager