use of javax.swing.table.DefaultTableModel in project processing by processing.
the class ErrorTable method addRow.
public void addRow(Problem data, String msg, String filename, String line) {
DefaultTableModel dtm = (DefaultTableModel) getModel();
dtm.addRow(new Object[] { data, msg, filename, line });
}
use of javax.swing.table.DefaultTableModel in project antlrworks by antlr.
the class DialogAbout method initComponents.
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Open Source Project license - ANTLR (www.antlr.org)
appIconButton = new JButton();
descriptionLabel = new JLabel();
titleLabel = new JLabel();
versionLabel = new JLabel();
copyrightLabel = new JLabel();
tabbedPane1 = new JTabbedPane();
panel2 = new JPanel();
acknowledgeTextArea = new JTextArea();
panel1 = new JPanel();
scrollPane1 = new JScrollPane();
infoTable = new JTable();
CellConstraints cc = new CellConstraints();
//======== this ========
setResizable(false);
setTitle("About");
Container contentPane = getContentPane();
contentPane.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.BOTTOM, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec("top:max(default;15dlu)"), FormFactory.LINE_GAP_ROWSPEC, new RowSpec("bottom:max(default;10dlu)"), FormFactory.LINE_GAP_ROWSPEC, new RowSpec("top:max(default;10dlu)"), FormFactory.LINE_GAP_ROWSPEC, new RowSpec("fill:max(default;60dlu):grow"), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(10)) }));
//---- appIconButton ----
appIconButton.setIcon(null);
appIconButton.setBorderPainted(false);
appIconButton.setContentAreaFilled(false);
appIconButton.setDefaultCapable(false);
appIconButton.setEnabled(true);
appIconButton.setFocusable(false);
appIconButton.setFocusPainted(false);
appIconButton.setPreferredSize(new Dimension(124, 144));
appIconButton.setMaximumSize(new Dimension(136, 144));
appIconButton.setMinimumSize(new Dimension(136, 144));
contentPane.add(appIconButton, cc.xywh(3, 3, 1, 8));
//---- descriptionLabel ----
descriptionLabel.setText("A graphical development environment for developing and debugging ANTLR v3 grammars");
descriptionLabel.setHorizontalAlignment(SwingConstants.LEFT);
descriptionLabel.setHorizontalTextPosition(SwingConstants.LEFT);
descriptionLabel.setVerticalTextPosition(SwingConstants.TOP);
descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
contentPane.add(descriptionLabel, cc.xywh(5, 7, 1, 2));
//---- titleLabel ----
titleLabel.setText("ANTLRWorks");
titleLabel.setFont(new Font("Lucida Grande", Font.BOLD, 36));
contentPane.add(titleLabel, cc.xy(5, 3));
//---- versionLabel ----
versionLabel.setText("Version 1.0 early access 1");
contentPane.add(versionLabel, cc.xy(5, 5));
//---- copyrightLabel ----
copyrightLabel.setText("Copyright (c) 2005 Jean Bovet & Terence Parr");
contentPane.add(copyrightLabel, cc.xy(5, 9));
//======== tabbedPane1 ========
{
//======== panel2 ========
{
panel2.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(10)) }));
//---- acknowledgeTextArea ----
acknowledgeTextArea.setText("ANTLR and StringTemplate are (c) 1989-2005 Terence Parr\nXJLibrary is (c) 2004-2005 Jean Bovet\nPortion of the GUI uses JGoodies, (c) 2002-2004 Karsten Lentzsch\nPortion of the GUI was created using JFormDesigner, (c) 2004-2005 Karl Tauber\nBrowserLauncher is (c) 2001 Eric Albert <ejalbert@cs.stanford.edu>\nApplication icon is (c) Matthew McClintock <matthew@mc.clintock.com>\n");
acknowledgeTextArea.setEditable(false);
acknowledgeTextArea.setBackground(SystemColor.window);
panel2.add(acknowledgeTextArea, cc.xy(3, 3));
}
tabbedPane1.addTab("Acknowledgment", panel2);
//======== panel1 ========
{
panel1.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(Sizes.dluX(10)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(10)) }, new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(10), FormSpec.DEFAULT_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(Sizes.dluY(10)) }));
//======== scrollPane1 ========
{
//---- infoTable ----
infoTable.setModel(new DefaultTableModel(new Object[][] { { null, null }, { null, null }, { null, null }, { null, null } }, new String[] { "Name", "Version" }) {
boolean[] columnEditable = new boolean[] { false, false };
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return columnEditable[columnIndex];
}
});
infoTable.setShowVerticalLines(true);
scrollPane1.setViewportView(infoTable);
}
panel1.add(scrollPane1, cc.xy(3, 3));
}
tabbedPane1.addTab("Information", panel1);
}
contentPane.add(tabbedPane1, cc.xywh(3, 11, 3, 1));
pack();
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
use of javax.swing.table.DefaultTableModel in project libgdx by libgdx.
the class DynamicsInfluencerPanel method initializeComponents.
protected void initializeComponents() {
super.initializeComponents();
JPanel velocitiesPanel = new JPanel();
velocitiesPanel.setLayout(new GridBagLayout());
{
JPanel sideButtons = new JPanel(new GridBagLayout());
velocitiesPanel.add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
{
sideButtons.add(velocityBox = new JComboBox(new DefaultComboBoxModel()), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
}
{
JButton newButton = new JButton("New");
sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
newButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
createVelocity(velocityBox.getSelectedItem());
}
});
}
{
JButton deleteButton = new JButton("Delete");
sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
deleteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
deleteVelocity();
}
});
}
}
JScrollPane scroll = new JScrollPane();
velocitiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
velocityTable = new JTable() {
public Class getColumnClass(int column) {
return column == 1 ? Boolean.class : super.getColumnClass(column);
}
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension dim = super.getPreferredScrollableViewportSize();
dim.height = getPreferredSize().height;
return dim;
}
};
velocityTable.getTableHeader().setReorderingAllowed(false);
velocityTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scroll.setViewportView(velocityTable);
velocityTableModel = new DefaultTableModel(new String[0][0], new String[] { "Velocity", "Active" });
velocityTable.setModel(velocityTableModel);
velocityTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
velocitySelected();
}
});
velocityTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent event) {
if (event.getColumn() != 1)
return;
velocityChecked(event.getFirstRow(), (Boolean) velocityTable.getValueAt(event.getFirstRow(), 1));
}
});
//Velocity values
emptyPanel = new ParticleValuePanel(editor, "", "", true, false);
strengthVelocityPanel = new StrengthVelocityPanel(editor, null, "Life", "", "");
angularVelocityPanel = new AngularVelocityPanel(editor, null, "Life", "", "");
strengthVelocityPanel.setVisible(false);
angularVelocityPanel.setVisible(false);
emptyPanel.setVisible(false);
strengthVelocityPanel.setIsAlwayShown(true);
angularVelocityPanel.setIsAlwayShown(true);
emptyPanel.setIsAlwayShown(true);
emptyPanel.setValue(null);
//Assemble
int i = 0;
addContent(i++, 0, velocitiesPanel);
addContent(i++, 0, strengthVelocityPanel);
addContent(i++, 0, angularVelocityPanel);
addContent(i++, 0, emptyPanel);
}
use of javax.swing.table.DefaultTableModel in project libgdx by libgdx.
the class EffectPanel method initializeComponents.
private void initializeComponents() {
setLayout(new GridBagLayout());
{
JPanel sideButtons = new JPanel(new GridBagLayout());
add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
JButton newButton = new JButton("New");
sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
newButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
newEmitter("Untitled", true);
}
});
}
{
JButton newButton = new JButton("Duplicate");
sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
newButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
duplicateEmitter();
}
});
}
{
JButton deleteButton = new JButton("Delete");
sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
deleteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
deleteEmitter();
}
});
}
{
sideButtons.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
}
{
JButton saveButton = new JButton("Save");
sideButtons.add(saveButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
saveEffect();
}
});
}
{
JButton openButton = new JButton("Open");
sideButtons.add(openButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
openEffect(false);
}
});
}
{
JButton mergeButton = new JButton("Merge");
sideButtons.add(mergeButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
mergeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
openEffect(true);
}
});
}
{
JButton upButton = new JButton("Up");
sideButtons.add(upButton, new GridBagConstraints(0, -1, 1, 1, 0, 1, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
upButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
move(-1);
}
});
}
{
JButton downButton = new JButton("Down");
sideButtons.add(downButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
downButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
move(1);
}
});
}
}
{
JScrollPane scroll = new JScrollPane();
add(scroll, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 6), 0, 0));
{
emitterTable = new JTable() {
public Class getColumnClass(int column) {
return column == 1 ? Boolean.class : super.getColumnClass(column);
}
};
emitterTable.getTableHeader().setReorderingAllowed(false);
emitterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scroll.setViewportView(emitterTable);
emitterTableModel = new DefaultTableModel(new String[0][0], new String[] { "Emitter", "" });
emitterTable.setModel(emitterTableModel);
emitterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting())
return;
emitterSelected();
}
});
emitterTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent event) {
if (event.getColumn() != 1)
return;
emitterChecked(event.getFirstRow(), (Boolean) emitterTable.getValueAt(event.getFirstRow(), 1));
}
});
}
}
}
use of javax.swing.table.DefaultTableModel in project gephi by gephi.
the class PartitionColorTransformerPanel method setup.
public void setup(PartitionFunction function) {
this.function = function;
NumberFormat formatter = NumberFormat.getPercentInstance();
formatter.setMaximumFractionDigits(2);
Partition partition = function.getPartition();
values = partition.getSortedValues();
List<Object> nullColors = new ArrayList<>();
Color defaultColor = Color.LIGHT_GRAY;
for (Object val : values) {
Color c = partition.getColor(val);
if (c == null) {
nullColors.add(val);
partition.setColor(val, defaultColor);
}
}
int valuesWithColors = values.size() - nullColors.size();
if (!nullColors.isEmpty() && valuesWithColors < 8) {
Color[] cls = PaletteGenerator.generatePalette(Math.min(8, values.size()), 5, new Random(42l));
int i = 0;
for (Object val : nullColors) {
int index = valuesWithColors + i++;
if (index < cls.length) {
partition.setColor(val, cls[index]);
}
}
}
//Model
String[] columnNames = new String[] { "Color", "Partition", "Percentage" };
DefaultTableModel model = new DefaultTableModel(columnNames, values.size()) {
@Override
public boolean isCellEditable(int row, int column) {
return column == 0;
}
};
table.setModel(model);
String countMsg = NbBundle.getMessage(PartitionColorTransformerPanel.class, "PartitionColorTransformerPanel.tooltip.elementsCount");
TableColumn partCol = table.getColumnModel().getColumn(1);
partCol.setCellRenderer(new TextRenderer(null));
TableColumn percCol = table.getColumnModel().getColumn(2);
percCol.setCellRenderer(new TextRenderer(countMsg));
percCol.setPreferredWidth(60);
percCol.setMaxWidth(60);
TableColumn colorCol = table.getColumnModel().getColumn(0);
colorCol.setCellEditor(new ColorChooserEditor());
colorCol.setCellRenderer(new ColorChooserRenderer());
colorCol.setPreferredWidth(16);
colorCol.setMaxWidth(16);
int j = 0;
for (Object value : values) {
String displayName = value == null ? "null" : value.getClass().isArray() ? AttributeUtils.printArray(value) : value.toString();
int count = function.getPartition().count(value);
float percentage = function.getPartition().percentage(value) / 100f;
model.setValueAt(value, j, 0);
model.setValueAt(displayName, j, 1);
String percCount = count + "_(" + formatter.format(percentage) + ")";
model.setValueAt(percCount, j, 2);
j++;
}
}
Aggregations