List of usage examples for com.jgoodies.forms.builder ButtonBarBuilder addButton
@Override
public ButtonBarBuilder addButton(Action... actions)
From source file:de.peterspan.csv2db.ui.MainPanel.java
License:Open Source License
private void initialize() { setLayout(new JideBorderLayout()); add(getFileSelectionPanel(), JideBorderLayout.NORTH); FormLayout layout = new FormLayout("fill:pref:grow, 4dlu, right:pref"); //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(); buttonBarBuilder.addGlue();// ww w.j a v a 2s.c o m buttonBarBuilder.addButton(getReadLocationButton()); buttonBarBuilder.addButton(getReadInputButton()); builder.append(getProgressBar()); builder.append(buttonBarBuilder.build()); add(builder.getPanel(), BorderLayout.SOUTH); }
From source file:jgnash.ui.StaticUIMethods.java
License:Open Source License
/** * Builds and returns a right aligned button bar with the given buttons. * * @param buttons an array of buttons to add * @return a right aligned button bar with the given buttons *///www .j ava2s . c om public static JPanel buildRightAlignedBar(final AbstractButton... buttons) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGlue(); builder.addButton(buttons); return builder.getPanel(); }
From source file:jgnash.ui.StaticUIMethods.java
License:Open Source License
/** * Builds and returns a right aligned bar with help and other buttons. * * @param help the help button to add on the left side * @param buttons an array of buttons to add * @return a right aligned button bar with the given buttons *//*from www .jav a 2s .c o m*/ public static JPanel buildHelpBar(final JButton help, final AbstractButton... buttons) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addButton(help); builder.addUnrelatedGap(); builder.addGlue(); builder.addButton(buttons); return builder.getPanel(); }
From source file:net.sf.jabref.ContentSelectorDialog2.java
License:Open Source License
private void initLayout() { fieldNameField.setEnabled(false);//from w w w .java 2s . co m fieldList.setVisibleRowCount(4); wordList.setVisibleRowCount(10); final String VAL = "Uren luren himmelturen, ja Besseggen."; fieldList.setPrototypeCellValue(VAL); wordList.setPrototypeCellValue(VAL); fieldPan.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Field name"))); wordPan.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Keyword"))); fieldPan.setLayout(gbl); wordPan.setLayout(gbl); con.insets = new Insets(2, 2, 2, 2); con.fill = GridBagConstraints.BOTH; con.gridwidth = 2; con.weightx = 1; con.weighty = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fPane, con); fieldPan.add(fPane); gbl.setConstraints(wPane, con); wordPan.add(wPane); con.gridwidth = 1; con.gridx = 2; //con.weightx = 0.7; con.gridheight = 2; gbl.setConstraints(fieldNamePan, con); fieldPan.add(fieldNamePan); gbl.setConstraints(wordEditPan, con); wordPan.add(wordEditPan); con.gridx = 0; con.gridy = 1; con.weightx = 0; con.weighty = 0; con.gridwidth = 1; con.gridheight = 1; con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.WEST; gbl.setConstraints(newField, con); fieldPan.add(newField); gbl.setConstraints(newWord, con); wordPan.add(newWord); con.gridx = 1; //con.anchor = GridBagConstraints.EAST; gbl.setConstraints(removeField, con); fieldPan.add(removeField); gbl.setConstraints(removeWord, con); wordPan.add(removeWord); con.anchor = GridBagConstraints.WEST; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldNameField, con); fieldNamePan.add(fieldNameField); gbl.setConstraints(wordEditField, con); wordEditPan.add(wordEditField); // Add buttons: ButtonBarBuilder bsb = new ButtonBarBuilder(buttonPan); bsb.addGlue(); bsb.addButton(ok); bsb.addButton(apply); bsb.addButton(cancel); bsb.addRelatedGap(); bsb.addButton(help); bsb.addGlue(); // Add panels to dialog: con.fill = GridBagConstraints.BOTH; getContentPane().setLayout(gbl); con.weightx = 1; con.weighty = 0.5; con.gridwidth = 1; con.gridheight = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldPan, con); getContentPane().add(fieldPan); con.gridy = 1; gbl.setConstraints(wordPan, con); getContentPane().add(wordPan); con.weighty = 0; con.gridy = 2; con.insets = new Insets(12, 2, 2, 2); gbl.setConstraints(buttonPan, con); getContentPane().add(buttonPan); }
From source file:net.sf.jabref.EntryTypeDialog.java
License:Open Source License
public EntryTypeDialog(JabRefFrame baseFrame_) { super(baseFrame_, true); // Set modal on. setTitle(Globals.lang("Select entry type")); addWindowListener(new WindowAdapter() { @Override//from w ww . j a v a2 s.c o m public void windowClosing(WindowEvent e) { cancelAction.actionPerformed(null); } }); getContentPane().setLayout(new BorderLayout()); JPanel pan = new JPanel(); getContentPane().add(pan, BorderLayout.CENTER); JPanel buttons = new JPanel(); JButton // ok = new JButton("Ok"), cancel = new JButton(Globals.lang("Cancel")); //ok.addActionListener(this); cancel.addActionListener(this); // Make ESC close dialog, equivalent to clicking Cancel. cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(baseFrame_.prefs.getKey("Close dialog"), "close"); cancel.getActionMap().put("close", cancelAction); //buttons.add(ok); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); //buttons.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); bb.addGlue(); bb.addButton(cancel); bb.addGlue(); getContentPane().add(buttons, BorderLayout.SOUTH); GridBagLayout gbl = new GridBagLayout(); pan.setLayout(gbl); GridBagConstraints con = new GridBagConstraints(); con.anchor = GridBagConstraints.WEST; con.fill = GridBagConstraints.HORIZONTAL; con.insets = new Insets(4, 4, 4, 4); int col = 0; for (BibtexEntryType tp : BibtexEntryType.ALL_TYPES.values()) { if (tp.isVisibleAtNewEntryDialog()) { TypeButton b = new TypeButton(StringUtil.nCase(tp.getName()), tp); b.addActionListener(this); // Check if we should finish the row. col++; if (col == EntryTypeDialog.COLNUM) { col = 0; con.gridwidth = GridBagConstraints.REMAINDER; } else { con.gridwidth = 1; } gbl.setConstraints(b, con); pan.add(b); } } pan.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Entry types"))); //pan.setBackground(Color.white); //buttons.setBackground(Color.white); pack(); setResizable(false); }
From source file:net.sf.jabref.export.CustomExportDialog.java
License:Open Source License
public CustomExportDialog(JabRefFrame parent_) { super(parent_, Globals.lang("Edit custom export"), true); parent = parent_;//from w ww. ja v a 2 s .com ActionListener okListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Check that there are no empty strings. if ((layoutFile.getText().isEmpty()) || (name.getText().isEmpty()) || (extension.getText().isEmpty()) || (!layoutFile.getText().endsWith(".layout"))) { //JOptionPane.showMessageDialog // (parent, Globals.lang("You must provide a name, a search " // +"string and a field name for this group."), // Globals.lang("Create group"), // JOptionPane.ERROR_MESSAGE); return; } // Handling of : and ; must also be done. ok_pressed = true; dispose(); } }; JButton ok = new JButton(Globals.lang("Ok")); ok.addActionListener(okListener); name.addActionListener(okListener); layoutFile.addActionListener(okListener); extension.addActionListener(okListener); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; JButton cancel = new JButton(Globals.lang("Cancel")); cancel.addActionListener(cancelAction); JButton browse = new JButton(Globals.lang("Browse")); browse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File directory = new File(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY)); String chosenStr = FileDialogs.getNewFile(parent, directory, ".layout", JFileChooser.OPEN_DIALOG, false); if (chosenStr == null) { return; } File chosen = new File(chosenStr); // Update working directory for layout files. Globals.prefs.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, chosen.getParent()); layoutFile.setText(chosen.getPath()); } }); // Key bindings: JPanel main = new JPanel(); ActionMap am = main.getActionMap(); InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(parent.prefs().getKey("Close dialog"), "close"); am.put("close", cancelAction); // Layout starts here. GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Globals.lang("Export properties"))); // Main panel: GridBagConstraints con = new GridBagConstraints(); con.weightx = 0; con.gridwidth = 1; con.insets = new Insets(3, 5, 3, 5); con.anchor = GridBagConstraints.EAST; con.fill = GridBagConstraints.NONE; con.gridx = 0; con.gridy = 0; JLabel nl = new JLabel(Globals.lang("Export name") + ':'); gbl.setConstraints(nl, con); main.add(nl); con.gridy = 1; JLabel nr = new JLabel(Globals.lang("Main layout file") + ':'); gbl.setConstraints(nr, con); main.add(nr); con.gridy = 2; JLabel nf = new JLabel(Globals.lang("File extension") + ':'); gbl.setConstraints(nf, con); main.add(nf); con.gridwidth = 2; con.weightx = 1; con.anchor = GridBagConstraints.WEST; con.fill = GridBagConstraints.HORIZONTAL; con.gridy = 0; con.gridx = 1; gbl.setConstraints(name, con); main.add(name); con.gridy = 1; con.gridwidth = 1; gbl.setConstraints(layoutFile, con); main.add(layoutFile); con.gridx = 2; con.weightx = 0; gbl.setConstraints(browse, con); main.add(browse); con.weightx = 1; con.gridwidth = 2; con.gridx = 1; con.gridy = 2; gbl.setConstraints(extension, con); main.add(extension); JPanel buttons = new JPanel(); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); bb.addGlue(); bb.addButton(ok); bb.addButton(cancel); bb.addGlue(); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); //pack(); setSize(600, 170); Util.placeDialog(this, parent); }
From source file:net.sf.jabref.export.ExportCustomizationDialog.java
License:Open Source License
public ExportCustomizationDialog(JabRefFrame frame_) throws HeadlessException { super(frame_, Globals.lang("Manage custom exports"), false); frame = frame_;/*from w w w. j a v a2s .c om*/ JButton addExport = new JButton(Globals.lang("Add new")); addExport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CustomExportDialog ecd = new CustomExportDialog(frame); ecd.setVisible(true); // ecd.show(); -> deprecated since 1.5 if (ecd.okPressed()) { String[] newFormat = new String[] { ecd.name(), ecd.layoutFile(), ecd.extension() }; Globals.prefs.customExports.addFormat(newFormat); Globals.prefs.customExports.store(); } } }); JButton modify = new JButton(Globals.lang("Modify")); modify.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = table.getSelectedRow(); if (row == -1) { return; } String[] old = Globals.prefs.customExports.getSortedList().get(row); CustomExportDialog ecd = new CustomExportDialog(frame, old[0], old[1], old[2]); ecd.setVisible(true); // ecd.show(); -> deprecated since 1.5 if (ecd.okPressed()) { old[0] = ecd.name(); old[1] = ecd.layoutFile(); old[2] = ecd.extension(); table.revalidate(); table.repaint(); Globals.prefs.customExports.store(); } } }); JButton remove = new JButton(Globals.lang("Remove")); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = table.getSelectedRows(); if (rows.length == 0) { return; } String[][] entries = new String[rows.length][]; for (int i = 0; i < rows.length; i++) { entries[i] = Globals.prefs.customExports.getSortedList().get(rows[i]); } for (int i = 0; i < rows.length; i++) { Globals.prefs.customExports.remove(entries[i]); } Globals.prefs.customExports.store(); } }); AbstractAction closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; JButton close = new JButton(Globals.lang("Close")); close.addActionListener(closeAction); JButton help = new JButton(Globals.lang("Help")); help.addActionListener(new HelpAction(frame.helpDiag, GUIGlobals.exportCustomizationHelp, "Help")); EventTableModel<String[]> tableModel = new EventTableModel<String[]>( Globals.prefs.customExports.getSortedList(), new ExportTableFormat()); table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_0_WIDTH); cm.getColumn(1).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_1_WIDTH); cm.getColumn(2).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_2_WIDTH); JScrollPane sp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(500, 150)); if (table.getRowCount() > 0) { table.setRowSelectionInterval(0, 0); } // Key bindings: JPanel main = new JPanel(); ActionMap am = main.getActionMap(); InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(frame.prefs().getKey("Close dialog"), "close"); am.put("close", closeAction); //am = table.getActionMap(); //im = table.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); //im.put(frame.prefs().getKey("Close dialog"), "close"); //am.put("close", closeAction); main.setLayout(new BorderLayout()); main.add(sp, BorderLayout.CENTER); JPanel buttons = new JPanel(); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); bb.addGlue(); bb.addButton(addExport); bb.addButton(modify); bb.addButton(remove); bb.addButton(close); bb.addUnrelatedGap(); bb.addButton(help); bb.addGlue(); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); pack(); Util.placeDialog(this, frame); new FocusRequester(table); }
From source file:net.sf.jabref.exporter.CustomExportDialog.java
License:Open Source License
public CustomExportDialog(final JabRefFrame parent) { super(parent, Localization.lang("Edit custom export"), true); ActionListener okListener = e -> { // Check that there are no empty strings. if (layoutFile.getText().isEmpty() || name.getText().isEmpty() || extension.getText().isEmpty() || !layoutFile.getText().endsWith(".layout")) { //JOptionPane.showMessageDialog // (parent, Globals.lang("You must provide a name, a search " // +"string and a field name for this group."), // Globals.lang("Create group"), // JOptionPane.ERROR_MESSAGE); return; }//from ww w. j av a 2s .c o m // Handling of : and ; must also be done. okPressed = true; dispose(); }; JButton ok = new JButton(Localization.lang("OK")); ok.addActionListener(okListener); name.addActionListener(okListener); layoutFile.addActionListener(okListener); extension.addActionListener(okListener); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; JButton cancel = new JButton(Localization.lang("Cancel")); cancel.addActionListener(cancelAction); JButton browse = new JButton(Localization.lang("Browse")); browse.addActionListener(e -> { File directory = new File(Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY)); String chosenStr = FileDialogs.getNewFile(parent, directory, ".layout", JFileChooser.OPEN_DIALOG, false); if (chosenStr == null) { return; } File chosen = new File(chosenStr); // Update working directory for layout files. Globals.prefs.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, chosen.getParent()); layoutFile.setText(chosen.getPath()); }); // Key bindings: JPanel main = new JPanel(); ActionMap am = main.getActionMap(); InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); // Layout starts here. GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("Export properties"))); // Main panel: GridBagConstraints con = new GridBagConstraints(); con.weightx = 0; con.gridwidth = 1; con.insets = new Insets(3, 5, 3, 5); con.anchor = GridBagConstraints.EAST; con.fill = GridBagConstraints.NONE; con.gridx = 0; con.gridy = 0; JLabel nl = new JLabel(Localization.lang("Export name") + ':'); gbl.setConstraints(nl, con); main.add(nl); con.gridy = 1; JLabel nr = new JLabel(Localization.lang("Main layout file") + ':'); gbl.setConstraints(nr, con); main.add(nr); con.gridy = 2; JLabel nf = new JLabel(Localization.lang("File extension") + ':'); gbl.setConstraints(nf, con); main.add(nf); con.gridwidth = 2; con.weightx = 1; con.anchor = GridBagConstraints.WEST; con.fill = GridBagConstraints.HORIZONTAL; con.gridy = 0; con.gridx = 1; gbl.setConstraints(name, con); main.add(name); con.gridy = 1; con.gridwidth = 1; gbl.setConstraints(layoutFile, con); main.add(layoutFile); con.gridx = 2; con.weightx = 0; gbl.setConstraints(browse, con); main.add(browse); con.weightx = 1; con.gridwidth = 2; con.gridx = 1; con.gridy = 2; gbl.setConstraints(extension, con); main.add(extension); JPanel buttons = new JPanel(); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); bb.addGlue(); bb.addButton(ok); bb.addButton(cancel); bb.addGlue(); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); setSize(700, 200); PositionWindow.placeDialog(this, parent); }
From source file:net.sf.jabref.exporter.ExportCustomizationDialog.java
License:Open Source License
public ExportCustomizationDialog(final JabRefFrame frame) { super(frame, Localization.lang("Manage custom exports"), false); DefaultEventTableModel<List<String>> tableModel = new DefaultEventTableModel<>( Globals.prefs.customExports.getSortedList(), new ExportTableFormat()); JTable table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_0_WIDTH); cm.getColumn(1).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_1_WIDTH); cm.getColumn(2).setPreferredWidth(GUIGlobals.EXPORT_DIALOG_COL_2_WIDTH); JScrollPane sp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(500, 150)); if (table.getRowCount() > 0) { table.setRowSelectionInterval(0, 0); }/*from w w w.jav a 2 s .c o m*/ JButton addExport = new JButton(Localization.lang("Add new")); addExport.addActionListener(e -> { CustomExportDialog ecd = new CustomExportDialog(frame); ecd.setVisible(true); if (ecd.okPressed()) { List<String> newFormat = Arrays.asList(ecd.name(), ecd.layoutFile(), ecd.extension()); Globals.prefs.customExports.addFormat(newFormat); Globals.prefs.customExports.store(); } }); JButton modify = new JButton(Localization.lang("Modify")); modify.addActionListener(e -> { int row = table.getSelectedRow(); if (row == -1) { return; } List<String> old = Globals.prefs.customExports.getSortedList().get(row); CustomExportDialog ecd = new CustomExportDialog(frame, old.get(0), old.get(1), old.get(2)); ecd.setVisible(true); // ecd.show(); -> deprecated since 1.5 if (ecd.okPressed()) { old.set(0, ecd.name()); old.set(1, ecd.layoutFile()); old.set(2, ecd.extension()); table.revalidate(); table.repaint(); Globals.prefs.customExports.store(); } }); JButton remove = new JButton(Localization.lang("Remove")); remove.addActionListener(e -> { int[] rows = table.getSelectedRows(); if (rows.length == 0) { return; } List<List<String>> entries = new ArrayList<>(); for (int i = 0; i < rows.length; i++) { entries.add(Globals.prefs.customExports.getSortedList().get(rows[i])); } for (List<String> list : entries) { Globals.prefs.customExports.remove(list); } Globals.prefs.customExports.store(); }); Action closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; JButton close = new JButton(Localization.lang("Close")); close.addActionListener(closeAction); JButton help = new HelpAction(HelpFiles.exportCustomizationHelp).getHelpButton(); // Key bindings: JPanel main = new JPanel(); ActionMap am = main.getActionMap(); InputMap im = main.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", closeAction); main.setLayout(new BorderLayout()); main.add(sp, BorderLayout.CENTER); JPanel buttons = new JPanel(); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); bb.addGlue(); bb.addButton(addExport); bb.addButton(modify); bb.addButton(remove); bb.addButton(close); bb.addUnrelatedGap(); bb.addButton(help); bb.addGlue(); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); pack(); PositionWindow.placeDialog(this, frame); new FocusRequester(table); }
From source file:net.sf.jabref.external.ExternalFileTypeEditor.java
License:Open Source License
private void init() { ok.addActionListener(new ActionListener() { @Override/*from w w w . j ava 2s. c o m*/ public void actionPerformed(ActionEvent e) { storeSettings(); dispose(); } }); AbstractAction 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(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { /*int reply = JOptionPane.showConfirmDialog(ExternalFileTypeEditor.this, Globals.lang("All custom file types will be lost. Proceed?"), Globals.lang("Reset file type definitons"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);*/ //if (reply == JOptionPane.YES_OPTION) { java.util.List<ExternalFileType> list = Globals.prefs.getDefaultExternalFileTypes(); fileTypes.clear(); fileTypes.addAll(list); Collections.sort(fileTypes); //Globals.prefs.resetExternalFileTypesToDefault(); //setValues(); tableModel.fireTableDataChanged(); //} } }); add.addActionListener(new AddListener()); remove.addActionListener(new RemoveListener()); edit.addActionListener(editListener); fileTypes = new ArrayList<ExternalFileType>(); 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.prefs.getKey("Close dialog"), "close"); am.put("close", cancelAction); am = bb.getPanel().getActionMap(); im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.prefs.getKey("Close dialog"), "close"); am.put("close", cancelAction); if (frame != null) { setLocationRelativeTo(frame); } else { setLocationRelativeTo(dialog); } }