use of javax.swing.JTextArea in project android_frameworks_base by crdroidandroid.
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 processdash by dtuma.
the class MigrationToolIndiv method showException.
private void showException(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
System.err.println("Unexpected Exception Encountered:");
e.printStackTrace();
String dataChangeMessage = maybeRestoreData(pw);
Object msg = new Object[] { "A serious, unexpected problem was encountered during the " + "migration operation. More information is available below.", new JScrollPane(new JTextArea(sw.toString())), dataChangeMessage.split("\n") };
JOptionPane.showMessageDialog(null, msg, "Encountered exception", JOptionPane.PLAIN_MESSAGE);
}
use of javax.swing.JTextArea in project JMRI by JMRI.
the class ReportContextAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent ev) {
// JmriJFrame to ensure fits on screen
final JFrame frame = new JmriJFrame(Bundle.getMessage("TitleContext"));
final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
pane = new JTextArea();
// add a little space at top
pane.append("\n");
pane.setEditable(false);
pane.setLineWrap(true);
pane.setWrapStyleWord(true);
pane.setColumns(120);
JScrollPane scroll = new JScrollPane(pane);
frame.add(scroll, BorderLayout.CENTER);
ReportContext r = new ReportContext();
addString(r.getReport(true));
// add a little space at bottom
pane.append("\n");
// Add button to allow copy to clipboard
JPanel p = new JPanel();
JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
copy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
StringSelection text = new StringSelection(pane.getText());
clipboard.setContents(text, text);
}
});
p.add(copy);
JButton close = new JButton(Bundle.getMessage("ButtonClose"));
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
frame.setVisible(false);
frame.dispose();
}
});
p.add(close);
frame.add(p, BorderLayout.SOUTH);
frame.pack();
// start scrolled to top
pane.setCaretPosition(0);
JScrollBar b = scroll.getVerticalScrollBar();
b.setValue(b.getMaximum());
// show
frame.setVisible(true);
}
use of javax.swing.JTextArea in project JMRI by JMRI.
the class ExceptionDisplayFrame method InitComponents.
private void InitComponents() {
setTitle(context.getTitle());
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
setContentPane(contentPane);
lblNewLabel_1 = new JLabel(// NOI18N
"This is a prototype dialog for displaying details about exceptions that are thrown during program execution. It still needs a lot of work!");
lblNewLabel_1.setAlignmentX(Component.CENTER_ALIGNMENT);
contentPane.add(lblNewLabel_1);
summaryPanel = new JPanel();
contentPane.add(summaryPanel);
// NOI18N
lblNewLabel_3 = new JLabel("Summary:");
summaryPanel.add(lblNewLabel_3);
summaryTextArea2 = new JTextArea();
summaryPanel.add(summaryTextArea2);
// NOI18N
showDetailsButton = new JButton("Show details");
showDetailsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
showDetailsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
detailsPanel.setVisible(true);
pack();
}
});
contentPane.add(showDetailsButton);
detailsPanel = new JPanel();
detailsPanel.setLayout(new BoxLayout(detailsPanel, BoxLayout.Y_AXIS));
detailsPanel.setVisible(false);
contentPane.add(detailsPanel);
stackTraceTextArea = new JTextArea();
stackTraceTextArea.setToolTipText(// NOI18N
"This is the trace of all of the methods that were active when the exception occurred.");
// NOI18N
stackTraceLabel = new JLabel("Stack trace:");
stackTraceLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
stackTraceLabel.setHorizontalAlignment(SwingConstants.LEFT);
detailsPanel.add(stackTraceLabel);
detailsPanel.add(stackTraceTextArea);
panel = new JPanel();
detailsPanel.add(panel);
// NOI18N
lblNewLabel = new JLabel("Operation:");
panel.add(lblNewLabel);
operationTextArea = new JTextArea();
panel.add(operationTextArea);
panel_4 = new JPanel();
detailsPanel.add(panel_4);
// NOI18N
lblNewLabel_4 = new JLabel("Messsage:");
panel_4.add(lblNewLabel_4);
messageTextArea = new JTextArea();
panel_4.add(messageTextArea);
panel_2 = new JPanel();
detailsPanel.add(panel_2);
// NOI18N
lblNewLabel_2 = new JLabel("Hint:");
panel_2.add(lblNewLabel_2);
hintTextArea = new JTextArea();
panel_2.add(hintTextArea);
panel_5 = new JPanel();
detailsPanel.add(panel_5);
// NOI18N
lblNewLabel_5 = new JLabel("Exception Type:");
panel_5.add(lblNewLabel_5);
typeTextArea = new JTextArea();
panel_5.add(typeTextArea);
panel_6 = new JPanel();
detailsPanel.add(panel_6);
// NOI18N
lblNewLabel_6 = new JLabel("Exception toString():");
panel_6.add(lblNewLabel_6);
toStringTextArea = new JTextArea();
panel_6.add(toStringTextArea);
panel_7 = new JPanel();
detailsPanel.add(panel_7);
// NOI18N
lblNewLabel_7 = new JLabel("Cause (Inner Ex):");
panel_7.add(lblNewLabel_7);
causeTextArea = new JTextArea();
panel_7.add(causeTextArea);
buttonPanel = new JPanel();
buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
contentPane.add(buttonPanel);
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
// NOI18N
copyButton = new JButton("Copy to Clipboard");
copyButton.setEnabled(false);
buttonPanel.add(copyButton);
// NOI18N
closeButton = new JButton("Close");
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
buttonPanel.add(closeButton);
// Now fill in the controls...
stackTraceTextArea.setText(context.getStackTraceAsString(10));
// New controls
operationTextArea.setText(context.getOperation());
messageTextArea.setText(context.getException().getMessage());
hintTextArea.setText(context.getHint());
summaryTextArea2.setText(context.getSummary());
typeTextArea.setText(context.getException().getClass().getName());
toStringTextArea.setText(context.getException().toString());
Throwable cause = context.getException().getCause();
if (cause != null) {
causeTextArea.setText(cause.toString());
} else {
// NOI18N
causeTextArea.setText("null");
}
pack();
setModalityType(ModalityType.DOCUMENT_MODAL);
setModal(true);
setLocationRelativeTo(null);
setVisible(true);
}
use of javax.swing.JTextArea in project JMRI by JMRI.
the class AbstractMonFrame method initComponents.
@Override
public void initComponents() throws Exception {
p = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
// the following code sets the frame's initial state
// NOI18N
clearButton.setText(Bundle.getMessage("ButtonClearScreen"));
clearButton.setVisible(true);
// NOI18N
clearButton.setToolTipText(Bundle.getMessage("TooltipClearMonHistory"));
// NOI18N
freezeButton.setText(Bundle.getMessage("ButtonFreezeScreen"));
freezeButton.setVisible(true);
// NOI18N
freezeButton.setToolTipText(Bundle.getMessage("TooltipStopScroll"));
// NOI18N
enterButton.setText(Bundle.getMessage("ButtonAddMessage"));
enterButton.setVisible(true);
// NOI18N
enterButton.setToolTipText(Bundle.getMessage("TooltipAddMessage"));
monTextPane.setVisible(true);
// NOI18N
monTextPane.setToolTipText(Bundle.getMessage("TooltipMonTextPane"));
monTextPane.setEditable(false);
// Add document listener to scroll to end when modified if required
monTextPane.getDocument().addDocumentListener(new DocumentListener() {
// References to the JTextArea and JCheckBox
// of this instantiation
JTextArea ta = monTextPane;
JCheckBox chk = autoScrollCheckBox;
@Override
public void insertUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
@Override
public void removeUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
@Override
public void changedUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
});
// NOI18N
entryField.setToolTipText(Bundle.getMessage("TooltipEntryPane"));
// fix a width for current character set
JTextField t = new JTextField(80);
int x = jScrollPane1.getPreferredSize().width + t.getPreferredSize().width;
int y = jScrollPane1.getPreferredSize().height + 10 * t.getPreferredSize().height;
jScrollPane1.getViewport().add(monTextPane);
jScrollPane1.setPreferredSize(new Dimension(x, y));
jScrollPane1.setVisible(true);
// NOI18N
startLogButton.setText(Bundle.getMessage("ButtonStartLogging"));
startLogButton.setVisible(true);
// NOI18N
startLogButton.setToolTipText(Bundle.getMessage("TooltipStartLogging"));
// NOI18N
stopLogButton.setText(Bundle.getMessage("ButtonStopLogging"));
stopLogButton.setVisible(true);
// NOI18N
stopLogButton.setToolTipText(Bundle.getMessage("TooltipStopLogging"));
// NOI18N
rawCheckBox.setText(Bundle.getMessage("ButtonShowRaw"));
rawCheckBox.setVisible(true);
// NOI18N
rawCheckBox.setToolTipText(Bundle.getMessage("TooltipShowRaw"));
rawCheckBox.setSelected(p.getSimplePreferenceState(rawDataCheck));
// NOI18N
timeCheckBox.setText(Bundle.getMessage("ButtonShowTimestamps"));
timeCheckBox.setVisible(true);
// NOI18N
timeCheckBox.setToolTipText(Bundle.getMessage("TooltipShowTimestamps"));
timeCheckBox.setSelected(p.getSimplePreferenceState(timeStampCheck));
// NOI18N
alwaysOnTopCheckBox.setText(Bundle.getMessage("ButtonWindowOnTop"));
alwaysOnTopCheckBox.setVisible(true);
// NOI18N
alwaysOnTopCheckBox.setToolTipText(Bundle.getMessage("TooltipWindowOnTop"));
alwaysOnTopCheckBox.setSelected(p.getSimplePreferenceState(alwaysOnTopCheck));
setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
// NOI18N
autoScrollCheckBox.setText(Bundle.getMessage("ButtonAutoScroll"));
autoScrollCheckBox.setVisible(true);
// NOI18N
autoScrollCheckBox.setToolTipText(Bundle.getMessage("TooltipAutoScroll"));
autoScrollCheckBox.setSelected(!p.getSimplePreferenceState(autoScrollCheck));
// NOI18N
openFileChooserButton.setText(Bundle.getMessage("ButtonChooseLogFile"));
openFileChooserButton.setVisible(true);
// NOI18N
openFileChooserButton.setToolTipText(Bundle.getMessage("TooltipChooseLogFile"));
setTitle(title());
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// add items to GUI
getContentPane().add(jScrollPane1);
JPanel paneA = new JPanel();
paneA.setLayout(new BoxLayout(paneA, BoxLayout.Y_AXIS));
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.X_AXIS));
pane1.add(clearButton);
pane1.add(freezeButton);
pane1.add(rawCheckBox);
pane1.add(timeCheckBox);
pane1.add(alwaysOnTopCheckBox);
paneA.add(pane1);
JPanel pane2 = new JPanel();
pane2.setLayout(new BoxLayout(pane2, BoxLayout.X_AXIS));
pane2.add(openFileChooserButton);
pane2.add(startLogButton);
pane2.add(stopLogButton);
paneA.add(pane2);
JPanel pane3 = new JPanel();
pane3.setLayout(new BoxLayout(pane3, BoxLayout.X_AXIS));
pane3.add(enterButton);
pane3.add(entryField);
paneA.add(pane3);
getContentPane().add(paneA);
// connect actions to buttons
clearButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
clearButtonActionPerformed(e);
}
});
startLogButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
startLogButtonActionPerformed(e);
}
});
stopLogButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stopLogButtonActionPerformed(e);
}
});
openFileChooserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
openFileChooserButtonActionPerformed(e);
}
});
enterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enterButtonActionPerformed(e);
}
});
alwaysOnTopCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
}
});
autoScrollCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doAutoScroll(monTextPane, autoScrollCheckBox.isSelected());
}
});
// set file chooser to a default
// NOI18N
logFileChooser.setSelectedFile(new File("monitorLog.txt"));
// connect to data source
init();
// add help menu to window
addHelpMenu();
// prevent button areas from expanding
pack();
paneA.setMaximumSize(paneA.getSize());
pack();
}
Aggregations