use of com.jgoodies.forms.builder.ButtonStackBuilder in project jabref by JabRef.
the class ExternalFileTypeEditor method init.
private void init() {
ok.addActionListener(e -> {
storeSettings();
dispose();
});
Action cancelAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
};
cancel.addActionListener(cancelAction);
// The toDefaults resets the entire list to its default values.
toDefaults.addActionListener(e -> {
List<ExternalFileType> list = ExternalFileTypes.getDefaultExternalFileTypes();
fileTypes.clear();
fileTypes.addAll(list);
Collections.sort(fileTypes);
tableModel.fireTableDataChanged();
});
add.addActionListener(e -> {
ExternalFileType type = new ExternalFileType("", "", "", "", "new", IconTheme.JabRefIcon.FILE.getSmallIcon());
getEditor(type).setVisible(true);
if (entryEditor.okPressed()) {
fileTypes.add(type);
tableModel.fireTableDataChanged();
}
});
remove.addActionListener(e -> {
int[] rows = table.getSelectedRows();
if (rows.length == 0) {
return;
}
for (int i = rows.length - 1; i >= 0; i--) {
fileTypes.remove(rows[i]);
}
tableModel.fireTableDataChanged();
if (!fileTypes.isEmpty()) {
int row = Math.min(rows[0], fileTypes.size() - 1);
table.setRowSelectionInterval(row, row);
}
});
edit.addActionListener(editListener);
fileTypes = new ArrayList<>();
setValues();
tableModel = new FileTypeTableModel();
table = new JTable(tableModel);
table.setDefaultRenderer(ImageIcon.class, new IconRenderer());
table.addMouseListener(new TableClickListener());
table.getColumnModel().getColumn(0).setMaxWidth(24);
table.getColumnModel().getColumn(0).setMinWidth(24);
table.getColumnModel().getColumn(1).setMinWidth(170);
table.getColumnModel().getColumn(2).setMinWidth(60);
table.getColumnModel().getColumn(3).setMinWidth(100);
table.getColumnModel().getColumn(0).setResizable(false);
JScrollPane sp = new JScrollPane(table);
JPanel upper = new JPanel();
upper.setLayout(new BorderLayout());
upper.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
upper.add(sp, BorderLayout.CENTER);
getContentPane().add(upper, BorderLayout.CENTER);
ButtonStackBuilder bs = new ButtonStackBuilder();
bs.addButton(add);
bs.addButton(remove);
bs.addButton(edit);
bs.addRelatedGap();
bs.addButton(toDefaults);
upper.add(bs.getPanel(), BorderLayout.EAST);
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
pack();
// Key bindings:
ActionMap am = upper.getActionMap();
InputMap im = upper.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", cancelAction);
am = bb.getPanel().getActionMap();
im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", cancelAction);
if (frame == null) {
setLocationRelativeTo(dialog);
} else {
setLocationRelativeTo(frame);
}
}
use of com.jgoodies.forms.builder.ButtonStackBuilder in project jgnash by ccavanaugh.
the class BudgetManagerDialog method layoutMainPanel.
private void layoutMainPanel() {
initComponents();
// build the button stack
ButtonStackBuilder buttonStackBuilder = new ButtonStackBuilder();
buttonStackBuilder.addButton(newAutoButton, newButton, duplicateButton, renameButton);
buttonStackBuilder.addUnrelatedGap();
buttonStackBuilder.addButton(deleteButton);
FormLayout layout = new FormLayout("p:g, $lcgap, f:p", "f:max(35dlu;p):g, $ugap, p");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.border(Borders.DIALOG);
CellConstraints cc = new CellConstraints();
builder.add(new JScrollPane(budgetList), cc.xy(1, 1));
builder.add(buttonStackBuilder.getPanel(), cc.xy(3, 1));
builder.add(StaticUIMethods.buildCloseBar(closeButton), cc.xyw(1, 3, 3));
getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
pack();
setMinimumSize(getSize());
}
Aggregations