下面列出了javax.swing.JScrollPane#setAlignmentX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JPanel createParametersPanel() {
JPanel paramsPanel = new JPanel();
BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
paramsPanel.setLayout(layout);
AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon("/org/esa/snap/resources/images/icons/Add16.png"), false);
addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
paramsPanel.add(addParamBut);
this.paramsTable = new OperatorParametersTable(this.fakeOperatorDescriptor, appContext);
JScrollPane tableScrollPane = new JScrollPane(paramsTable);
tableScrollPane.setPreferredSize(new Dimension(500, 130));
tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
paramsPanel.add(tableScrollPane);
addParamBut.addActionListener((ActionEvent e) -> paramsTable.addParameterToTable());
TitledBorder title = BorderFactory.createTitledBorder("Template Parameters");
paramsPanel.setBorder(title);
return paramsPanel;
}
@Override
protected JPanel createParametersPanel() {
JPanel paramsPanel = new JPanel();
BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
paramsPanel.setLayout(layout);
AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
addParamBut.setAlignmentY(Component.TOP_ALIGNMENT);
paramsPanel.add(addParamBut);
int tableWidth = (formWidth - 2 * DEFAULT_PADDING);
int widths[] = {27, 120, (int)(tableWidth * 0.25), (int)(tableWidth * 0.1), 100, (int)(tableWidth * 0.32), 30};
for(int i=0; i < widths.length; i++) {
paramsTable.getColumnModel().getColumn(i).setPreferredWidth(widths[i]);
}
JScrollPane tableScrollPane = new JScrollPane(paramsTable);
tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
paramsPanel.add(tableScrollPane);
addParamBut.addActionListener(e -> paramsTable.addParameterToTable(new ToolParameterDescriptor("parameterName", String.class), 0));
TitledBorder title = BorderFactory.createTitledBorder(Bundle.CTL_Panel_OpParams_Border_TitleText());
paramsPanel.setBorder(title);
return paramsPanel;
}
@Override
protected JPanel createParametersPanel() {
JPanel paramsPanel = new JPanel();
BoxLayout layout = new BoxLayout(paramsPanel, BoxLayout.PAGE_AXIS);
paramsPanel.setLayout(layout);
AbstractButton addParamBut = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addParamBut.setText("New Parameter");
addParamBut.setMaximumSize(new Dimension(150, controlHeight));
addParamBut.setAlignmentX(Component.LEFT_ALIGNMENT);
addParamBut.setAlignmentY(Component.TOP_ALIGNMENT);
paramsPanel.add(addParamBut);
JScrollPane tableScrollPane = new JScrollPane(paramsTable);
tableScrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
paramsPanel.add(tableScrollPane);
addParamBut.addActionListener(e -> paramsTable.addParameterToTable());
return paramsPanel;
}
protected void initGuiComponents(){
setLayout(new BorderLayout());
editor = new ResourceParametersEditor();
editor.setEditable(false);
editor.setAutoResizeMode(XJTable.AUTO_RESIZE_LAST_COLUMN);
JScrollPane scroller = new JScrollPane(editor);
scroller.setAlignmentX(Component.LEFT_ALIGNMENT);
scroller.setAlignmentY(Component.TOP_ALIGNMENT);
add(scroller, BorderLayout.CENTER);
}
/**
* Creates a new Box with table and actions buttons
* @return a new Box
*/
protected Container createTablePanel() {
table = new JTable(tableModel, tableModel.getTableColumnModel());
table.setRowHeight(22);
table.setAutoCreateRowSorter(true);
tableModel.addTableModelListener(this);
JScrollPane scroll = new JScrollPane(table);
scroll.setAlignmentX(Container.LEFT_ALIGNMENT);
Box box = Box.createVerticalBox();
JButton addButton = new JButton(new AddAction());
JButton deleteButton = new JButton(new DeleteAction());
JButton saveButton = new JButton(new SaveAction());
JButton refreshButton = new JButton(new RefreshAction());
Box buttonBox = Box.createHorizontalBox();
buttonBox.add(addButton);
buttonBox.add(Box.createHorizontalStrut(5));
buttonBox.add(deleteButton);
buttonBox.add(Box.createHorizontalStrut(5));
buttonBox.add(saveButton);
buttonBox.add(Box.createHorizontalStrut(5));
buttonBox.add(refreshButton);
buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT);
buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));
box.add(buttonBox);
box.add(Box.createVerticalStrut(5));
box.add(scroll);
return box;
}
private JComponent createInfoPanel(Resources resources) {
StoryMetadata storyinfo = resources.getMetadata().getStoryInfo();
Box infopanel = Box.createVerticalBox();
infopanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
JComponent panel = infopanel;
// in case cover art is available, stack it into the info panel
int coverartnum = getCoverartNum(resources);
if (coverartnum > 0 && resources.getImages().getNumResources() > 0) {
Box wholepanel = Box.createHorizontalBox();
wholepanel.add(createPicturePanel(resources, coverartnum));
wholepanel.add(infopanel);
panel = wholepanel;
}
infopanel.setAlignmentX(Component.LEFT_ALIGNMENT);
infopanel.setPreferredSize(new Dimension(STD_WIDTH, 400));
List<JLabel> labels = new ArrayList<JLabel>();
labels.add(new JLabel(storyinfo.getTitle()));
if (storyinfo.getHeadline() != null) {
labels.add(new JLabel(storyinfo.getHeadline()));
}
labels.add(new JLabel(storyinfo.getAuthor() + " ("
+ storyinfo.getYear() + ")"));
for (JLabel label : labels) {
infopanel.add(label);
label.setAlignmentX(Component.LEFT_ALIGNMENT);
// Ensure that the label fonts are all bold
label.setFont(label.getFont().deriveFont(Font.BOLD));
}
infopanel.add(Box.createVerticalStrut(6));
JTextArea descarea = new JTextArea(storyinfo.getDescription());
descarea.setLineWrap(true);
descarea.setWrapStyleWord(true);
descarea.setEditable(false);
Insets margins = new Insets(3, 3, 3, 3);
descarea.setMargin(margins);
descarea.setFont(labels.get(0).getFont().deriveFont(Font.PLAIN));
JScrollPane spane = new JScrollPane(descarea);
spane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
spane.setPreferredSize(new Dimension(STD_WIDTH, 200));
spane.setAlignmentX(Component.LEFT_ALIGNMENT);
infopanel.add(spane);
return panel;
}
public ProgressPanel() {
super();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
int width = 400;
progressTotal = new SafeJProgressBar();
progressTotal.setAlignmentX(CENTER_ALIGNMENT);
progressTotal.setMaximumSize(
new Dimension(width, progressTotal.getPreferredSize().height));
progressTotal.setIndeterminate(true);
message = new JLabel("");
message.setIcon(new ProgressIcon(48, 48));
message.setHorizontalTextPosition(SwingConstants.RIGHT);
message.setHorizontalAlignment(SwingConstants.CENTER);
message.setAlignmentX(CENTER_ALIGNMENT);
dlMsg = new JLabel("Downloading CREOLE Plugin...");
dlMsg.setIcon(new DownloadIcon(48, 48));
dlMsg.setHorizontalTextPosition(SwingConstants.RIGHT);
dlMsg.setHorizontalAlignment(SwingConstants.CENTER);
dlMsg.setAlignmentX(CENTER_ALIGNMENT);
dlMsg.setVisible(false);
partProgress = new JPanel();
partProgress.setLayout(new BoxLayout(partProgress, BoxLayout.Y_AXIS));
scroller = new JScrollPane(partProgress);
scroller.setAlignmentX(CENTER_ALIGNMENT);
scroller.setMaximumSize(
new Dimension(width, progressTotal.getPreferredSize().height*6));
scroller.setPreferredSize(
new Dimension(width, progressTotal.getPreferredSize().height*6));
add(Box.createVerticalGlue());
add(message);
add(Box.createVerticalStrut(5));
add(progressTotal);
add(Box.createVerticalStrut(10));
add(dlMsg);
add(Box.createVerticalStrut(5));
add(scroller);
add(Box.createVerticalGlue());
addComponentListener(this);
}
/**
* GUIAInitialization
*/
protected void initUI() {
this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
// Tab
tabPane = new JTabbedPane();
tabPane.setAlignmentX(LEFT_ALIGNMENT);
this.add(tabPane);
// Rules
listboxRule = new JList[GameEngine.MAX_GAMESTYLE];
for(int i = 0; i < GameEngine.MAX_GAMESTYLE; i++) {
listboxRule[i] = new JList(extractRuleListFromRuleEntries(i));
JScrollPane scpaneRule = new JScrollPane(listboxRule[i]);
scpaneRule.setPreferredSize(new Dimension(380, 250));
scpaneRule.setAlignmentX(LEFT_ALIGNMENT);
tabPane.addTab(GameEngine.GAMESTYLE_NAMES[i], scpaneRule);
}
// default Back to button
JButton btnUseDefault = new JButton(NullpoMinoSwing.getUIText("RuleSelect_UseDefault"));
btnUseDefault.setMnemonic('D');
btnUseDefault.addActionListener(this);
btnUseDefault.setActionCommand("RuleSelect_UseDefault");
btnUseDefault.setAlignmentX(LEFT_ALIGNMENT);
btnUseDefault.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
btnUseDefault.setVisible(false);
this.add(btnUseDefault);
// buttonKind
JPanel pButtons = new JPanel();
pButtons.setLayout(new BoxLayout(pButtons, BoxLayout.X_AXIS));
pButtons.setAlignmentX(LEFT_ALIGNMENT);
this.add(pButtons);
JButton btnOK = new JButton(NullpoMinoSwing.getUIText("RuleSelect_OK"));
btnOK.setMnemonic('O');
btnOK.addActionListener(this);
btnOK.setActionCommand("RuleSelect_OK");
btnOK.setAlignmentX(LEFT_ALIGNMENT);
btnOK.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
pButtons.add(btnOK);
this.getRootPane().setDefaultButton(btnOK);
JButton btnCancel = new JButton(NullpoMinoSwing.getUIText("RuleSelect_Cancel"));
btnCancel.setMnemonic('C');
btnCancel.addActionListener(this);
btnCancel.setActionCommand("RuleSelect_Cancel");
btnCancel.setAlignmentX(LEFT_ALIGNMENT);
btnCancel.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
pButtons.add(btnCancel);
}
@Override
protected JPanel createTablePanel(AbstractListTableModel<?> tableModel, String title)
{
/* Set up Design Table */
final JTable table = new JTable(tableModel);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
setSelectAllowed(table.getSelectedRow() >= 0);
}
});
setWidthAsPercentages(table, tableModel.getWidths());
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
table.setRowSorter(sorter);
JScrollPane tableScroller = new JScrollPane(table);
tableScroller.setPreferredSize(new Dimension(450, 200));
tableScroller.setAlignmentX(LEFT_ALIGNMENT);
JLabel tableLabel = new JLabel(title);
tableLabel.setLabelFor(table);
JPanel tablePane = new JPanel();
tablePane.setLayout(new BoxLayout(tablePane, BoxLayout.PAGE_AXIS));
tablePane.add(tableLabel);
tablePane.add(Box.createRigidArea(new Dimension(0, 5)));
tablePane.add(tableScroller);
tablePane.putClientProperty("table", table);
tablePane.putClientProperty("scroller", tableScroller);
tablePane.putClientProperty("label", tableLabel);
//If the user decide to double click on a design, open the design in SBOLDesigner.
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && table.getSelectedRow() >= 0 && !showModDefs.isSelected())
{
SBOLDocument chosenDesign = getSelection();
gui.openSBOLDesigner(filePath, fileName, chosenDesign.getRootComponentDefinitions(), chosenDesign.getDefaultURIprefix());
setVisible(false);
}
}
});
return tablePane;
}
public ResultWindow(String title, PeakListRow peakListRow, double searchedMass, int charge,
Task searchTask) {
super(title);
this.title = title;
this.peakListRow = peakListRow;
this.searchTask = searchTask;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setBackground(Color.white);
JPanel pnlLabelsAndList = new JPanel(new BorderLayout());
pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pnlLabelsAndList.add(new JLabel("List of possible formulas"), BorderLayout.NORTH);
resultsTableModel = new ResultTableModel(searchedMass);
resultsTable = new JTable();
// int rowHeight = resultsTable.getRowHeight();
resultsTable.setRowHeight(22);
resultsTable.setModel(resultsTableModel);
resultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
resultsTable.getTableHeader().setReorderingAllowed(false);
resultsTableSorter = new TableRowSorter<ResultTableModel>(resultsTableModel);
// set descending order by isotope score
resultsTableSorter.toggleSortOrder(3);
resultsTableSorter.toggleSortOrder(3);
resultsTable.setRowSorter(resultsTableSorter);
TableColumnModel columnModel = resultsTable.getColumnModel();
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(SwingConstants.LEFT);
resultsTable.setDefaultRenderer(Double.class, renderer);
columnModel.getColumn(4).setCellRenderer(new PercentageCellRenderer(1));
columnModel.getColumn(5).setCellRenderer(new PercentageCellRenderer(1));
JScrollPane listScroller = new JScrollPane(resultsTable);
listScroller.setPreferredSize(new Dimension(350, 100));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
JPanel listPanel = new JPanel();
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS));
listPanel.add(listScroller);
listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
pnlLabelsAndList.add(listPanel, BorderLayout.CENTER);
JPanel pnlButtons = new JPanel();
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
pnlButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
GUIUtils.addButton(pnlButtons, "Add identity", null, this, "ADD");
GUIUtils.addButton(pnlButtons, "Copy to clipboard", null, this, "COPY");
GUIUtils.addButton(pnlButtons, "Export all", null, this, "EXPORT");
GUIUtils.addButton(pnlButtons, "View isotope pattern", null, this, "SHOW_ISOTOPES");
GUIUtils.addButton(pnlButtons, "Show MS/MS", null, this, "SHOW_MSMS");
setLayout(new BorderLayout());
setSize(500, 200);
add(pnlLabelsAndList, BorderLayout.CENTER);
add(pnlButtons, BorderLayout.SOUTH);
pack();
}
public DBFrame(SiriusCompound compound, JButton button) {
super("Database links");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setBackground(Color.white);
JPanel pnlLabelsAndList = new JPanel(new BorderLayout());
pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pnlLabelsAndList.add(new JLabel("List of databases with IDs"), BorderLayout.NORTH);
// Configure table
dbTable = new JTable();
model = new DBTableModel();
dbTable.setModel(model);
dbTable.setRowSorter(new TableRowSorter<>(dbTable.getModel()));
dbTable.getTableHeader().setReorderingAllowed(false);
dbTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane listScroller = new JScrollPane(dbTable);
listScroller.setPreferredSize(new Dimension(400, 250));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
JPanel listPanel = new JPanel();
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS));
listPanel.add(listScroller);
listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
pnlLabelsAndList.add(listPanel, BorderLayout.CENTER);
// Buttons panel
JPanel pnlButtons = new JPanel();
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
pnlButtons.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
GUIUtils.addButton(pnlButtons, "Open browser", null, this, "OPEN_WEB");
setLayout(new BorderLayout());
add(pnlLabelsAndList, BorderLayout.CENTER);
add(pnlButtons, BorderLayout.SOUTH);
// Set size and position
setSize(400, 250);
setLocation(button.getLocationOnScreen());
pack();
// Initiate loading of DB links into new table
SwingUtilities.invokeLater(new Runnable() {
public void run() {
model.addElement(compound);
}
});
}
public ResultWindow(PeakListRow peakListRow, Task searchTask) {
super("");
this.peakListRow = peakListRow;
this.searchTask = searchTask;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setBackground(Color.white);
JPanel pnlLabelsAndList = new JPanel(new BorderLayout());
pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pnlLabelsAndList.add(new JLabel("List of possible identities"), BorderLayout.NORTH);
listElementModel = new ResultTableModel();
compoundsTable = new ResultTable(listElementModel);
// Specify content position
JScrollPane listScroller = new JScrollPane(compoundsTable);
listScroller.setPreferredSize(new Dimension(1000, 450));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
JPanel listPanel = new JPanel();
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS));
listPanel.add(listScroller);
listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
pnlLabelsAndList.add(listPanel, BorderLayout.CENTER);
// Specify buttons
JPanel pnlButtons = new JPanel();
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
pnlButtons.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
GUIUtils.addButton(pnlButtons, "Add identity", null, this, "ADD");
GUIUtils.addButton(pnlButtons, "Copy SMILES string", null, this, "COPY_SMILES");
GUIUtils.addButton(pnlButtons, "Copy Formula string", null, this, "COPY_FORMULA");
browse = new JButton("Display DB links");
browse.setActionCommand("DB_LIST");
browse.addActionListener(this);
pnlButtons.add(browse);
setLayout(new BorderLayout());
setSize(500, 200);
add(pnlLabelsAndList, BorderLayout.CENTER);
add(pnlButtons, BorderLayout.SOUTH);
pack();
}
public ResultWindow(PeakListRow peakListRow, double searchedMass, Task searchTask) {
super("");
this.peakListRow = peakListRow;
this.searchTask = searchTask;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setBackground(Color.white);
JPanel pnlLabelsAndList = new JPanel(new BorderLayout());
pnlLabelsAndList.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pnlLabelsAndList.add(new JLabel("List of possible identities"), BorderLayout.NORTH);
listElementModel = new ResultTableModel(searchedMass);
IDList = new JTable();
IDList.setModel(listElementModel);
IDList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
IDList.getTableHeader().setReorderingAllowed(false);
TableRowSorter<ResultTableModel> sorter =
new TableRowSorter<ResultTableModel>(listElementModel);
IDList.setRowSorter(sorter);
JScrollPane listScroller = new JScrollPane(IDList);
listScroller.setPreferredSize(new Dimension(350, 100));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
JPanel listPanel = new JPanel();
listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.PAGE_AXIS));
listPanel.add(listScroller);
listPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
pnlLabelsAndList.add(listPanel, BorderLayout.CENTER);
JPanel pnlButtons = new JPanel();
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.X_AXIS));
pnlButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
GUIUtils.addButton(pnlButtons, "Add identity", null, this, "ADD");
GUIUtils.addButton(pnlButtons, "View structure", null, this, "VIEWER");
GUIUtils.addButton(pnlButtons, "View isotope pattern", null, this, "ISOTOPE_VIEWER");
GUIUtils.addButton(pnlButtons, "Open browser", null, this, "BROWSER");
setLayout(new BorderLayout());
setSize(500, 200);
add(pnlLabelsAndList, BorderLayout.CENTER);
add(pnlButtons, BorderLayout.SOUTH);
pack();
}
@Override
protected JPanel createVariablesPanel() {
JPanel variablesBorderPanel = new JPanel();
BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
variablesBorderPanel.setLayout(layout);
variablesBorderPanel.setBorder(BorderFactory.createTitledBorder(Bundle.CTL_Panel_SysVar_Border_TitleText()));
AbstractButton addVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
addVariableButton.setMaximumSize(new Dimension(150, controlHeight));
AbstractButton addDependentVariableButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));
JPanel buttonsPannel = new JPanel(new SpringLayout());
buttonsPannel.add(addVariableButton);
buttonsPannel.add(addDependentVariableButton);
SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
variablesBorderPanel.add(buttonsPannel);
varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
varTable.setRowHeight(20);
JScrollPane scrollPane = new JScrollPane(varTable);
scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
variablesBorderPanel.add(scrollPane);
variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
Dimension variablesPanelDimension = new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
variablesBorderPanel.setMinimumSize(variablesPanelDimension);
variablesBorderPanel.setMaximumSize(variablesPanelDimension);
variablesBorderPanel.setPreferredSize(variablesPanelDimension);
addVariableButton.addActionListener(e -> {
newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
varTable.revalidate();
});
addDependentVariableButton.addActionListener(e -> {
newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
varTable.revalidate();
});
return variablesBorderPanel;
}
@Override
protected JPanel createVariablesPanel() {
JPanel variablesBorderPanel = new JPanel();
BoxLayout layout = new BoxLayout(variablesBorderPanel, BoxLayout.PAGE_AXIS);
variablesBorderPanel.setLayout(layout);
AbstractButton addVariableButton =
ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addVariableButton.setText(Bundle.CTL_Button_Add_Variable_Text());
addVariableButton.setMaximumSize(new Dimension(150, controlHeight));
addVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
AbstractButton addDependentVariableButton =
ToolButtonFactory.createButton(UIUtils.loadImageIcon(Bundle.Icon_Add()), false);
addDependentVariableButton.setText(Bundle.CTL_Button_Add_PDVariable_Text());
addDependentVariableButton.setMaximumSize(new Dimension(250, controlHeight));
addDependentVariableButton.setAlignmentX(Component.LEFT_ALIGNMENT);
JPanel buttonsPannel = new JPanel(new SpringLayout());
buttonsPannel.add(addVariableButton);
buttonsPannel.add(addDependentVariableButton);
SpringUtilities.makeCompactGrid(buttonsPannel, 1, 2, 0, 0, 0, 0);
buttonsPannel.setAlignmentX(Component.LEFT_ALIGNMENT);
variablesBorderPanel.add(buttonsPannel);
varTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
varTable.setRowHeight(controlHeight);
int widths[] = {controlHeight, 3 * controlHeight, 10 * controlHeight};
for (int i = 0; i < widths.length; i++) {
TableColumn column = varTable.getColumnModel().getColumn(i);
column.setPreferredWidth(widths[i]);
column.setWidth(widths[i]);
}
JScrollPane scrollPane = new JScrollPane(varTable);
scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
variablesBorderPanel.add(scrollPane);
variablesBorderPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
Dimension variablesPanelDimension =
new Dimension((formWidth - 3 * DEFAULT_PADDING) / 2 - 2 * DEFAULT_PADDING, 130);
variablesBorderPanel.setMinimumSize(variablesPanelDimension);
variablesBorderPanel.setMaximumSize(variablesPanelDimension);
variablesBorderPanel.setPreferredSize(variablesPanelDimension);
addVariableButton.addActionListener(e -> {
newOperatorDescriptor.getVariables().add(new SystemVariable("key", ""));
varTable.revalidate();
});
addDependentVariableButton.addActionListener(e -> {
newOperatorDescriptor.getVariables().add(new SystemDependentVariable("key", ""));
varTable.revalidate();
});
return variablesBorderPanel;
}