use of org.beanfabrics.swing.table.BnColumn in project grafikon by jub77.
the class EditRegionDialog method initComponents.
private void initComponents() {
ActionListener closeListener = evt -> setVisible(false);
BnButton okButton = new BnButton();
javax.swing.JButton cancelButton = new javax.swing.JButton();
// NOI18N
okButton.setText(ResourceLoader.getString("button.ok"));
okButton.addActionListener(closeListener);
// NOI18N
cancelButton.setText(ResourceLoader.getString("button.cancel"));
cancelButton.addActionListener(closeListener);
JPanel panel = new JPanel();
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(panel, BorderLayout.CENTER);
GridBagLayout gbLayout = new GridBagLayout();
gbLayout.columnWeights = new double[] { 0.0, 1.0 };
gbLayout.rowWeights = new double[] { 0.0, 0.0, 0.0 };
panel.setLayout(gbLayout);
// NOI18N
JLabel nameLabel = new JLabel(ResourceLoader.getString("edit.region.name"));
GridBagConstraints dlCons = new GridBagConstraints();
dlCons.anchor = GridBagConstraints.WEST;
dlCons.insets = new Insets(0, 0, 5, 5);
dlCons.gridx = 0;
dlCons.gridy = 0;
panel.add(nameLabel, dlCons);
BnTextField nameTextField = new BnTextField();
GridBagConstraints dtfCons = new GridBagConstraints();
dtfCons.insets = new Insets(0, 0, 5, 0);
dtfCons.anchor = GridBagConstraints.NORTH;
dtfCons.fill = GridBagConstraints.HORIZONTAL;
dtfCons.gridx = 1;
dtfCons.gridy = 0;
panel.add(nameTextField, dtfCons);
nameTextField.setColumns(30);
nameTextField.setModelProvider(provider);
nameTextField.setPath(new Path("name"));
// NOI18N
JLabel localeLabel = new JLabel(ResourceLoader.getString("edit.region.locale"));
GridBagConstraints llCons = new GridBagConstraints();
llCons.anchor = GridBagConstraints.WEST;
llCons.insets = new Insets(0, 0, 5, 5);
llCons.gridx = 0;
llCons.gridy = 1;
panel.add(localeLabel, llCons);
BnComboBox localeComboBox = new BnComboBox();
GridBagConstraints ltfCons = new GridBagConstraints();
ltfCons.insets = new Insets(0, 0, 5, 0);
ltfCons.fill = GridBagConstraints.HORIZONTAL;
ltfCons.gridx = 1;
ltfCons.gridy = 1;
panel.add(localeComboBox, ltfCons);
localeComboBox.setModelProvider(provider);
localeComboBox.setPath(new Path("locale"));
// NOI18N
JLabel superRegionLabel = new JLabel(ResourceLoader.getString("edit.region.super.region"));
GridBagConstraints srlCons = new GridBagConstraints();
srlCons.anchor = GridBagConstraints.WEST;
srlCons.insets = new Insets(0, 0, 5, 5);
srlCons.gridx = 0;
srlCons.gridy = 2;
panel.add(superRegionLabel, srlCons);
BnComboBox superRegionComboBox = new BnComboBox();
GridBagConstraints srltfCons = new GridBagConstraints();
srltfCons.insets = new Insets(0, 0, 5, 0);
srltfCons.fill = GridBagConstraints.HORIZONTAL;
srltfCons.gridx = 1;
srltfCons.gridy = 2;
panel.add(superRegionComboBox, srltfCons);
superRegionComboBox.setModelProvider(provider);
superRegionComboBox.setPath(new Path("superRegion"));
// NOI18N
JLabel colorRegionLabel = new JLabel(ResourceLoader.getString("edit.region.color.region"));
GridBagConstraints cclCons = new GridBagConstraints();
cclCons.anchor = GridBagConstraints.WEST;
cclCons.insets = new Insets(0, 0, 5, 5);
cclCons.gridx = 0;
cclCons.gridy = 3;
panel.add(colorRegionLabel, cclCons);
BnCheckBox colorRegionCheckBox = new BnCheckBox();
colorRegionCheckBox.setBorder(null);
GridBagConstraints cccbCons = new GridBagConstraints();
cccbCons.insets = new Insets(0, 0, 5, 0);
cccbCons.fill = GridBagConstraints.HORIZONTAL;
cccbCons.gridx = 1;
cccbCons.gridy = 3;
panel.add(colorRegionCheckBox, cccbCons);
colorRegionCheckBox.setModelProvider(provider);
colorRegionCheckBox.setPath(new Path("colorRegion"));
JScrollPane scrollPane = new JScrollPane();
BnTable mapTable = new BnTable();
Dimension viewportSize = mapTable.getPreferredScrollableViewportSize();
viewportSize.setSize(0, mapTable.getRowHeight() * DEFAULT_ROW_COUNT);
mapTable.setPreferredScrollableViewportSize(viewportSize);
GridBagConstraints mapCons = new GridBagConstraints();
mapCons.insets = new Insets(0, 0, 5, 0);
mapCons.fill = GridBagConstraints.BOTH;
mapCons.gridx = 0;
mapCons.gridy = 4;
mapCons.weighty = 1.0;
mapCons.gridwidth = 2;
panel.add(scrollPane, mapCons);
scrollPane.setViewportView(mapTable);
mapTable.setModelProvider(provider);
mapTable.setPath(new Path("colorMap"));
// NOI18N
mapTable.addColumn(new BnColumn(new Path("color"), ResourceLoader.getString("edit.region.color")));
// NOI18N
mapTable.addColumn(new BnColumn(new Path("region"), ResourceLoader.getString("edit.region.region")));
mapTable.setSortable(true);
JPanel addRemovePanel = new JPanel();
GridBagConstraints arCons = new GridBagConstraints();
arCons.insets = new Insets(0, 0, 5, 0);
arCons.fill = GridBagConstraints.HORIZONTAL;
arCons.gridx = 0;
arCons.gridy = 5;
arCons.gridwidth = 2;
panel.add(addRemovePanel, arCons);
addRemovePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
BnButton addButton = GuiComponentUtils.createBnButton(GuiIcon.ADD, 2);
addRemovePanel.add(addButton);
addButton.setModelProvider(provider);
addButton.setPath(new Path("add"));
addRemovePanel.add(Box.createHorizontalStrut(5));
BnButton removeButton = GuiComponentUtils.createBnButton(GuiIcon.REMOVE, 2);
addRemovePanel.add(removeButton);
removeButton.setModelProvider(provider);
removeButton.setPath(new Path("remove"));
Component verticalGlue = Box.createVerticalGlue();
GridBagConstraints vgCons = new GridBagConstraints();
vgCons.fill = GridBagConstraints.VERTICAL;
vgCons.insets = new Insets(0, 0, 0, 5);
vgCons.gridx = 0;
vgCons.gridy = 6;
panel.add(verticalGlue, vgCons);
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
okButton.setModelProvider(provider);
okButton.setPath(new Path("ok"));
}
Aggregations