use of javax.swing.JTextField in project jabref by JabRef.
the class ManageKeywordsAction method createDialog.
private void createDialog() {
if (diag != null) {
return;
}
// keyword to add
JTextField keyword = new JTextField();
keywordListModel = new DefaultListModel<>();
JList<Keyword> keywordList = new JList<>(keywordListModel);
keywordList.setVisibleRowCount(8);
JScrollPane kPane = new JScrollPane(keywordList);
diag = new JDialog(frame, Localization.lang("Manage keywords"), true);
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
JButton add = new JButton(Localization.lang("Add"));
JButton remove = new JButton(Localization.lang("Remove"));
keywordList.setVisibleRowCount(10);
intersectKeywords = new JRadioButton(Localization.lang("Display keywords appearing in ALL entries"));
mergeKeywords = new JRadioButton(Localization.lang("Display keywords appearing in ANY entry"));
ButtonGroup group = new ButtonGroup();
group.add(intersectKeywords);
group.add(mergeKeywords);
ActionListener stateChanged = e -> fillKeyWordList();
intersectKeywords.addActionListener(stateChanged);
mergeKeywords.addActionListener(stateChanged);
intersectKeywords.setSelected(true);
FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:200dlu:grow, 4dlu, fill:pref", "pref, 2dlu, pref, 1dlu, pref, 2dlu, fill:100dlu:grow, 4dlu, pref, 4dlu, pref, "));
builder.addSeparator(Localization.lang("Keywords of selected entries")).xyw(1, 1, 3);
builder.add(intersectKeywords).xyw(1, 3, 3);
builder.add(mergeKeywords).xyw(1, 5, 3);
builder.add(kPane).xywh(1, 7, 1, 3);
builder.add(remove).xy(3, 9);
builder.add(keyword).xy(1, 11);
builder.add(add).xy(3, 11);
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
ok.addActionListener(e -> {
canceled = false;
diag.dispose();
});
Action cancelAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
canceled = true;
diag.dispose();
}
};
cancel.addActionListener(cancelAction);
final ActionListener addActionListener = arg0 -> addButtonActionListener(keyword);
add.addActionListener(addActionListener);
final ActionListener removeActionListenter = arg0 -> {
List<Keyword> values = keywordList.getSelectedValuesList();
for (Keyword val : values) {
keywordListModel.removeElement(val);
}
};
remove.addActionListener(removeActionListenter);
keywordList.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent arg0) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent arg0) {
// Do nothing
}
@Override
public void keyPressed(KeyEvent arg0) {
if (arg0.getKeyCode() == KeyEvent.VK_DELETE) {
removeActionListenter.actionPerformed(null);
}
}
});
AutoCompleter<String> autoComp = JabRefGUI.getMainFrame().getCurrentBasePanel().getAutoCompleters().get(FieldName.KEYWORDS);
AutoCompleteListener acl = new AutoCompleteListener(autoComp);
keyword.addKeyListener(acl);
keyword.addFocusListener(acl);
keyword.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent e) {
// Do nothing
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
addActionListener.actionPerformed(null);
}
}
});
// Key bindings:
ActionMap am = builder.getPanel().getActionMap();
InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", cancelAction);
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
}
use of javax.swing.JTextField in project jabref by JabRef.
the class BibtexKeyPatternPanel method addEntryType.
private JTextField addEntryType(Container c, EntryType type, int y) {
JLabel lab = new JLabel(type.getName());
con.gridx = 0;
con.gridy = y;
con.fill = GridBagConstraints.BOTH;
con.weightx = 0;
con.weighty = 0;
con.anchor = GridBagConstraints.WEST;
con.insets = new Insets(0, 5, 0, 5);
gbl.setConstraints(lab, con);
c.add(lab);
JTextField tf = new JTextField();
tf.setColumns(15);
con.gridx = 1;
con.fill = GridBagConstraints.HORIZONTAL;
con.weightx = 1;
con.weighty = 0;
con.anchor = GridBagConstraints.CENTER;
con.insets = new Insets(0, 5, 0, 5);
gbl.setConstraints(tf, con);
c.add(tf);
JButton but = new JButton(Localization.lang("Default"));
con.gridx = 2;
con.fill = GridBagConstraints.BOTH;
con.weightx = 0;
con.weighty = 0;
con.anchor = GridBagConstraints.CENTER;
con.insets = new Insets(0, 5, 0, 5);
gbl.setConstraints(but, con);
but.setActionCommand(type.getName().toLowerCase(Locale.ROOT));
but.addActionListener(e -> {
JTextField tField = textFields.get(e.getActionCommand());
tField.setText("");
});
c.add(but);
return tf;
}
use of javax.swing.JTextField in project jabref by JabRef.
the class FromAuxDialog method initPanels.
private void initPanels() {
// collect the names of all open databases
int len = parentTabbedPane.getTabCount();
int toSelect = -1;
for (int i = 0; i < len; i++) {
dbChooser.addItem(parentTabbedPane.getTitleAt(i));
if (parentFrame.getBasePanelAt(i) == parentFrame.getCurrentBasePanel()) {
toSelect = i;
}
}
if (toSelect >= 0) {
dbChooser.setSelectedIndex(toSelect);
}
auxFileField = new JTextField("", 25);
JButton browseAuxFileButton = new JButton(Localization.lang("Browse"));
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().addExtensionFilter(FileExtensions.AUX).withDefaultExtension(FileExtensions.AUX).withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
DialogService ds = new FXDialogService();
browseAuxFileButton.addActionListener(e -> {
Optional<Path> file = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration));
file.ifPresent(f -> auxFileField.setText(f.toAbsolutePath().toString()));
});
notFoundList = new JList<>();
JScrollPane listScrollPane = new JScrollPane(notFoundList);
statusInfos = new JTextArea("", 5, 20);
JScrollPane statusScrollPane = new JScrollPane(statusInfos);
statusInfos.setEditable(false);
DefaultFormBuilder b = new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, left:pref", ""), buttons);
b.appendSeparator(Localization.lang("Options"));
b.append(Localization.lang("Reference library") + ":");
b.append(dbChooser, 3);
b.nextLine();
b.append(Localization.lang("LaTeX AUX file") + ":");
b.append(auxFileField);
b.append(browseAuxFileButton);
b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
b = new DefaultFormBuilder(new FormLayout("fill:pref:grow, 4dlu, fill:pref:grow", "pref, pref, fill:pref:grow"), statusPanel);
b.appendSeparator(Localization.lang("Result"));
b.append(Localization.lang("Unknown BibTeX entries") + ":");
b.append(Localization.lang("Messages") + ":");
b.nextLine();
b.append(listScrollPane);
b.append(statusScrollPane);
b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}
use of javax.swing.JTextField in project jabref by JabRef.
the class OpenOfficePanel method showManualConnectionDialog.
private void showManualConnectionDialog() {
dialogOkPressed = false;
final JDialog cDiag = new JDialog(frame, Localization.lang("Set connection parameters"), true);
final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();
final DialogService dirDialog = new FXDialogService();
DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder().withInitialDirectory(nativeDesktop.getApplicationDirectory()).build();
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().withInitialDirectory(nativeDesktop.getApplicationDirectory()).build();
DialogService fileDialog = new FXDialogService();
// Path fields
final JTextField ooPath = new JTextField(30);
JButton browseOOPath = new JButton(Localization.lang("Browse"));
ooPath.setText(preferences.getInstallationPath());
browseOOPath.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> dirDialog.showDirectorySelectionDialog(dirDialogConfiguration)).ifPresent(f -> ooPath.setText(f.toAbsolutePath().toString())));
final JTextField ooExec = new JTextField(30);
JButton browseOOExec = new JButton(Localization.lang("Browse"));
ooExec.setText(preferences.getExecutablePath());
browseOOExec.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> fileDialog.showFileOpenDialog(fileDialogConfiguration)).ifPresent(f -> ooExec.setText(f.toAbsolutePath().toString())));
final JTextField ooJars = new JTextField(30);
ooJars.setText(preferences.getJarsPath());
JButton browseOOJars = new JButton(Localization.lang("Browse"));
browseOOJars.addActionListener(e -> DefaultTaskExecutor.runInJavaFXThread(() -> dirDialog.showDirectorySelectionDialog(dirDialogConfiguration)).ifPresent(f -> ooJars.setText(f.toAbsolutePath().toString())));
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:pref:grow, 4dlu, fill:pref", "pref"));
if (OS.WINDOWS || OS.OS_X) {
builder.add(Localization.lang("Path to OpenOffice/LibreOffice directory")).xy(1, 1);
builder.add(ooPath).xy(3, 1);
builder.add(browseOOPath).xy(5, 1);
} else {
builder.add(Localization.lang("Path to OpenOffice/LibreOffice executable")).xy(1, 1);
builder.add(ooExec).xy(3, 1);
builder.add(browseOOExec).xy(5, 1);
builder.appendRows("4dlu, pref");
builder.add(Localization.lang("Path to OpenOffice/LibreOffice library dir")).xy(1, 3);
builder.add(ooJars).xy(3, 3);
builder.add(browseOOJars).xy(5, 3);
}
builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
cDiag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
// Buttons
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
ok.addActionListener(e -> {
if (OS.WINDOWS || OS.OS_X) {
preferences.updateConnectionParams(ooPath.getText(), ooPath.getText(), ooPath.getText());
} else {
preferences.updateConnectionParams(ooPath.getText(), ooExec.getText(), ooJars.getText());
}
dialogOkPressed = true;
cDiag.dispose();
});
cancel.addActionListener(e -> cDiag.dispose());
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addRelatedGap();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.padding("5dlu, 5dlu, 5dlu, 5dlu");
cDiag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
// Finish and show dirDialog
cDiag.pack();
cDiag.setLocationRelativeTo(frame);
cDiag.setVisible(true);
}
use of javax.swing.JTextField in project JMRI by JMRI.
the class JTableUtil method sortableDataModel.
/**
*
* @param dataModel model for table
* @return a table
* @deprecated since 4.5.4; create a standard {@link javax.swing.JTable} and
* add a {@link javax.swing.RowSorter} to that table instead. If you need
* custom {@link javax.swing.table.TableCellEditor} selection behavior,
* provide custom TableCellEditors for the columns that need the custom
* behavior.
*/
@Deprecated
public static JTable sortableDataModel(TableModel dataModel) {
TableSorter sorter;
sorter = new TableSorter(dataModel);
JTable dataTable = new JTable(sorter) {
@Override
public boolean editCellAt(int row, int column, java.util.EventObject e) {
boolean res = super.editCellAt(row, column, e);
java.awt.Component c = this.getEditorComponent();
if (c instanceof javax.swing.JTextField) {
((JTextField) c).selectAll();
}
return res;
}
};
sorter.setTableHeader(dataTable.getTableHeader());
return dataTable;
}
Aggregations