use of javax.swing.JTextArea in project jgnash by ccavanaugh.
the class RecurringEntryDialog method createTransactionPanel.
private JPanel createTransactionPanel() {
FormLayout layout = new FormLayout("left:p, 4dlu, p:g, 4dlu, p", "f:p, 3dlu, f:p, 3dlu, f:p, 3dlu, f:40dlu:g");
layout.setRowGroups(new int[][] { { 1, 3, 5 } });
CellConstraints cc = new CellConstraints();
JPanel p = new JPanel(layout);
descriptionField = new JTextFieldEx();
accountCombo = new AccountListComboBox();
notesArea = new JTextArea(5, 20);
notesArea.setLineWrap(true);
notesArea.setAutoscrolls(true);
JScrollPane pane = new JScrollPane(notesArea);
pane.setAutoscrolls(true);
transactionField = new JTextFieldEx();
transactionField.setEditable(false);
editButton = new JButton(rb.getString("Button.Edit"));
deleteButton = new JButton(rb.getString("Button.Delete"));
p.add(new JLabel(rb.getString("Label.Account")), cc.xy(1, 1));
p.add(accountCombo, cc.xywh(3, 1, 3, 1));
p.add(new JLabel(rb.getString("Label.Description")), cc.xy(1, 3));
p.add(descriptionField, cc.xywh(3, 3, 3, 1));
p.add(new JLabel(rb.getString("Label.Transaction")), cc.xy(1, 5));
p.add(transactionField, cc.xy(3, 5));
p.add(new ButtonBarBuilder().addButton(editButton, deleteButton).build(), cc.xy(5, 5));
p.add(new JLabel(rb.getString("Label.Notes")), cc.xy(1, 7));
p.add(pane, cc.xywh(3, 7, 3, 1));
return p;
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class XSheet method handleNotification.
/**
* Notification listener: handles asynchronous reception
* of MBean operation results and MBean notifications.
*/
// Call on EDT
public void handleNotification(Notification e, Object handback) {
// Operation result
if (e.getType().equals(XOperations.OPERATION_INVOCATION_EVENT)) {
final Object message;
if (handback == null) {
JTextArea textArea = new JTextArea("null");
textArea.setEditable(false);
textArea.setEnabled(true);
textArea.setRows(textArea.getLineCount());
message = textArea;
} else {
Component comp = mbeansTab.getDataViewer().createOperationViewer(handback, mbean);
if (comp == null) {
JTextArea textArea = new JTextArea(handback.toString());
textArea.setEditable(false);
textArea.setEnabled(true);
textArea.setRows(textArea.getLineCount());
JScrollPane scrollPane = new JScrollPane(textArea);
Dimension d = scrollPane.getPreferredSize();
if (d.getWidth() > 400 || d.getHeight() > 250) {
scrollPane.setPreferredSize(new Dimension(400, 250));
}
message = scrollPane;
} else {
if (!(comp instanceof JScrollPane)) {
comp = new JScrollPane(comp);
}
Dimension d = comp.getPreferredSize();
if (d.getWidth() > 400 || d.getHeight() > 250) {
comp.setPreferredSize(new Dimension(400, 250));
}
message = comp;
}
}
new ThreadDialog((Component) e.getSource(), message, Messages.OPERATION_RETURN_VALUE, JOptionPane.INFORMATION_MESSAGE).run();
} else // Got notification
if (e.getType().equals(XMBeanNotifications.NOTIFICATION_RECEIVED_EVENT)) {
DefaultMutableTreeNode emitter = (DefaultMutableTreeNode) handback;
Long received = (Long) e.getUserData();
updateReceivedNotifications(emitter, received.longValue(), true);
}
}
use of javax.swing.JTextArea 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.JTextArea in project jabref by JabRef.
the class SaveDatabaseAction method saveDatabase.
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException {
SaveSession session;
// block user input
frame.block();
try {
SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs).withEncoding(encoding);
BibtexDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(FileSaveSession::new);
if (selectedOnly) {
session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), panel.getSelectedEntries(), prefs);
} else {
session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs);
}
panel.registerUndoableChanges(session);
} catch (UnsupportedCharsetException ex) {
JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization.lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save library"), JOptionPane.ERROR_MESSAGE);
// FIXME: rethrow anti-pattern
throw new SaveException("rt");
} catch (SaveException ex) {
if (ex == SaveException.FILE_LOCKED) {
throw ex;
}
if (ex.specificEntry()) {
BibEntry entry = ex.getEntry();
// Error occured during processing of an entry. Highlight it!
panel.highlightEntry(entry);
} else {
LOGGER.error("A problem occured when trying to save the file", ex);
}
JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save library"), JOptionPane.ERROR_MESSAGE);
// FIXME: rethrow anti-pattern
throw new SaveException("rt");
} finally {
// re-enable user input
frame.unblock();
}
// handle encoding problems
boolean success = true;
if (!session.getWriter().couldEncodeAll()) {
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref"));
JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters());
ta.setEditable(false);
builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1);
builder.add(ta).xy(3, 1);
builder.add(Localization.lang("What do you want to do?")).xy(1, 3);
String tryDiff = Localization.lang("Try different encoding");
int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save library"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff);
if (answer == JOptionPane.NO_OPTION) {
// The user wants to use another encoding.
Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save library"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding);
if (choice == null) {
success = false;
} else {
Charset newEncoding = Charset.forName((String) choice);
return saveDatabase(file, selectedOnly, newEncoding);
}
} else if (answer == JOptionPane.CANCEL_OPTION) {
success = false;
}
}
// backup file?
try {
if (success) {
session.commit(file.toPath());
// Make sure to remember which encoding we used.
panel.getBibDatabaseContext().getMetaData().setEncoding(encoding, ChangePropagation.DO_NOT_POST_EVENT);
} else {
session.cancel();
}
} catch (SaveException e) {
int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION);
if (ans == JOptionPane.YES_OPTION) {
session.setUseBackup(false);
session.commit(file.toPath());
panel.getBibDatabaseContext().getMetaData().setEncoding(encoding, ChangePropagation.DO_NOT_POST_EVENT);
} else {
success = false;
}
}
return success;
}
use of javax.swing.JTextArea in project jabref by JabRef.
the class FieldFormatterCleanupsPanel method makeDescriptionTextAreaLikeJLabel.
/**
* Create a TextArea that looks and behaves like a JLabel. Has the advantage of supporting multine and wordwrap
*/
private void makeDescriptionTextAreaLikeJLabel() {
descriptionAreaText = new JTextArea(DESCRIPTION);
descriptionAreaText.setLineWrap(true);
descriptionAreaText.setWrapStyleWord(true);
descriptionAreaText.setColumns(6);
descriptionAreaText.setEditable(false);
descriptionAreaText.setOpaque(false);
descriptionAreaText.setFocusable(false);
descriptionAreaText.setCursor(null);
descriptionAreaText.setFont(UIManager.getFont("Label.font"));
}
Aggregations