use of javax.swing.JTextArea in project platform_frameworks_base by android.
the class ShowDataAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// TODO(agampe): Auto-generated method stub
int selRow = Main.getUI().getSelectedDataTableRow();
if (selRow != -1) {
DumpData data = dataTableModel.getData().get(selRow);
Map<String, Set<String>> inv = data.invertData();
StringBuilder builder = new StringBuilder();
// First bootclasspath.
add(builder, "Boot classpath:", inv.get(null));
// Now everything else.
for (String k : inv.keySet()) {
if (k != null) {
builder.append("==================\n\n");
add(builder, k, inv.get(k));
}
}
JFrame newFrame = new JFrame(data.getPackageName() + " " + data.getDate());
newFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
newFrame.getContentPane().add(new JScrollPane(new JTextArea(builder.toString())), BorderLayout.CENTER);
newFrame.setSize(800, 600);
newFrame.setLocationRelativeTo(null);
newFrame.setVisible(true);
}
}
use of javax.swing.JTextArea in project jgnash by ccavanaugh.
the class ConsoleDialog method show.
public static void show() {
if (dialog == null) {
// only one visible window
init();
ResourceBundle rb = ResourceUtils.getBundle();
JButton copyButton = new JButton(rb.getString("Button.CopyToClip"));
copyButton.addActionListener(e -> {
if (console != null) {
console.selectAll();
console.copy();
}
});
JButton gcButton = new JButton(rb.getString("Button.ForceGC"));
gcButton.addActionListener(e -> System.gc());
JButton heapButton = new JButton(rb.getString("Button.CreateHeapDump"));
heapButton.addActionListener(e -> {
if (console != null) {
dumpHeap();
}
});
dialog = new JDialog(UIApplication.getFrame(), Dialog.ModalityType.MODELESS);
dialog.setTitle(rb.getString("Title.Console"));
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
/* force the shut down to the end of the event thread.
* Lets other listeners do their job */
EventQueue.invokeLater(() -> {
synchronized (consoleLock) {
ConsoleDialog.close();
}
});
}
});
synchronized (consoleLock) {
console = new JTextArea();
console.setEditable(false);
// set a mono spaced font to preserve spacing
console.setFont(new Font("Monospaced", Font.PLAIN, console.getFont().getSize()));
}
JPanel panel = new JPanel();
panel.setBorder(Borders.DIALOG);
panel.setLayout(new BorderLayout());
panel.add(new MemoryMonitor(), BorderLayout.NORTH);
panel.add(new JScrollPane(console), BorderLayout.CENTER);
JPanel buttonPanel = StaticUIMethods.buildRightAlignedBar(heapButton, gcButton, copyButton);
buttonPanel.setBorder(new EmptyBorder(10, 0, 10, 0));
panel.add(buttonPanel, BorderLayout.SOUTH);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.pack();
// Minimum size
dialog.setMinimumSize(dialog.getSize());
dialog.setFocusableWindowState(false);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
DialogUtils.addBoundsListener(dialog);
dialog.setVisible(true);
}
}
use of javax.swing.JTextArea in project jgnash by ccavanaugh.
the class ExceptionDialog method getTextArea.
private static JTextArea getTextArea(final Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter(sw);
t.printStackTrace(out);
JTextArea textArea = new JTextArea(10, 30);
textArea.append(sw.toString());
return textArea;
}
use of javax.swing.JTextArea in project gephi by gephi.
the class TopDialog method message2Component.
/**
* Given a message object, create a displayable component from it.
*/
private static Component message2Component(Object message) {
if (message instanceof Component) {
return (Component) message;
} else if (message instanceof Object[]) {
Object[] sub = (Object[]) message;
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
for (int i = 0; i < sub.length; i++) {
panel.add(message2Component(sub[i]));
}
return panel;
} else if (message instanceof Icon) {
return new JLabel((Icon) message);
} else {
// bugfix #35742, used JTextArea to correctly word-wrapping
String text = message.toString();
JTextArea area = new JTextArea(text);
// NOI18N
Color c = UIManager.getColor("Label.background");
if (c != null) {
area.setBackground(c);
}
area.setLineWrap(true);
area.setWrapStyleWord(true);
area.setEditable(false);
// looks better for module sys messages than 8
area.setTabSize(4);
area.setColumns(40);
if (text.indexOf('\n') != -1) {
// Complex multiline message.
return new JScrollPane(area);
} else {
// Simple message.
return area;
}
}
}
use of javax.swing.JTextArea in project languagetool by languagetool-org.
the class FontChooser method initComponents.
private void initComponents() {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "Hide");
getRootPane().getActionMap().put("Hide", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectedFont = null;
setVisible(false);
}
});
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
selectedFont = null;
setVisible(false);
}
});
setTitle(messages.getString("FontChooser.title"));
fontStylesArray = new String[] { messages.getString("FontChooser.style.plain"), messages.getString("FontChooser.style.bold"), messages.getString("FontChooser.style.italic"), messages.getString("FontChooser.style.bold_italic") };
String[] fontNamesArray = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(4, 4, 4, 4);
JPanel fontPanel = new JPanel(new GridBagLayout());
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
JLabel fontNameLabel = new JLabel(messages.getString("FontChooser.label.name"));
fontPanel.add(fontNameLabel, c);
c.gridx = 1;
c.gridy = 0;
JLabel fontStyleLabel = new JLabel(messages.getString("FontChooser.label.style"));
fontPanel.add(fontStyleLabel, c);
c.gridx = 2;
c.gridy = 0;
JLabel fontSizeLabel = new JLabel(messages.getString("FontChooser.label.size"));
fontPanel.add(fontSizeLabel, c);
c.gridx = 0;
c.gridy = 1;
c.weightx = 1.0;
c.fill = GridBagConstraints.HORIZONTAL;
fontNameTextField = new JTextField();
fontNameTextField.setEnabled(false);
fontNameTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontNameTextField, c);
c.weightx = 0.0;
c.gridx = 1;
c.gridy = 1;
fontStyleTextField = new JTextField();
fontStyleTextField.setEnabled(false);
fontStyleTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontStyleTextField, c);
c.gridx = 2;
c.gridy = 1;
fontSizeTextField = new JTextField();
fontSizeTextField.setColumns(4);
fontSizeTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontSizeTextField, c);
c.gridx = 0;
c.gridy = 2;
c.weightx = 1.0;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
fontNameList = new JList<>(fontNamesArray);
fontNameList.addListSelectionListener(this);
fontNameList.setVisibleRowCount(5);
fontNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane fontNameListPane = new JScrollPane(fontNameList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontNameListPane, c);
c.gridx = 1;
c.gridy = 2;
c.weightx = 0.5;
fontStyleList = new JList<>(fontStylesArray);
fontStyleList.addListSelectionListener(this);
fontStyleList.setVisibleRowCount(5);
fontStyleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane fontStyleListPane = new JScrollPane(fontStyleList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontStyleListPane, c);
c.gridx = 2;
c.gridy = 2;
fontSizeList = new JList<>(fontSizesArray);
fontSizeList.addListSelectionListener(this);
fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fontSizeList.setVisibleRowCount(5);
JScrollPane fontSizeListPane = new JScrollPane(fontSizeList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontSizeListPane, c);
c.insets = new Insets(8, 8, 4, 8);
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.0;
c.weighty = 0.4;
getContentPane().add(fontPanel, c);
c.insets = new Insets(4, 8, 4, 8);
c.gridx = 0;
c.gridy = 1;
c.weightx = 1.0;
c.weighty = 0.6;
previewArea = new JTextArea(messages.getString("FontChooser.pangram"));
previewArea.setLineWrap(true);
previewArea.setRows(4);
JScrollPane pane = new JScrollPane(previewArea);
TitledBorder border = BorderFactory.createTitledBorder(messages.getString("FontChooser.preview"));
pane.setBorder(border);
getContentPane().add(pane, c);
JPanel buttonPanel = new JPanel(new GridBagLayout());
c.insets = new Insets(4, 4, 4, 4);
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 0.0;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.NONE;
JButton resetButton = new JButton(Tools.getLabel(messages.getString("FontChooser.reset")));
resetButton.setMnemonic(Tools.getMnemonic(messages.getString("FontChooser.reset")));
resetButton.setActionCommand(ACTION_COMMAND_RESET);
resetButton.addActionListener(this);
buttonPanel.add(resetButton, c);
c.gridx = 1;
c.gridy = 0;
c.weightx = 0.0;
c.weighty = 0.0;
c.anchor = GridBagConstraints.LINE_END;
c.fill = GridBagConstraints.NONE;
JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
cancelButton.addActionListener(this);
buttonPanel.add(cancelButton, c);
c.gridx = 2;
c.gridy = 0;
JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
okButton.setActionCommand(ACTION_COMMAND_OK);
okButton.addActionListener(this);
buttonPanel.add(okButton, c);
c.insets = new Insets(4, 8, 8, 8);
c.gridx = 0;
c.gridy = 2;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.HORIZONTAL;
getContentPane().add(buttonPanel, c);
this.defaultFont = previewArea.getFont();
setDefaultFont();
getRootPane().setDefaultButton(cancelButton);
this.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
pack();
}
Aggregations