use of javax.swing.JTextArea in project JMRI by JMRI.
the class AbstractMonPane method configureDataPane.
/**
* Do default configuration of a data pane
* @param textPane a JTextArea into which the data pane will be placed
*/
protected void configureDataPane(JTextArea textPane) {
textPane.setVisible(true);
// NOI18N
textPane.setToolTipText(Bundle.getMessage("TooltipMonTextPane"));
textPane.setEditable(false);
// Add document listener to scroll to end when modified if required
textPane.getDocument().addDocumentListener(new DocumentListener() {
// References to the JTextArea and JCheckBox
// of this instantiation
JTextArea ta = textPane;
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());
}
});
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class HorizontalMouseWheelOnShiftPressed method createAndShowGUI.
static void createAndShowGUI() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
textArea = new JTextArea("Hello World!");
scrollPane = new JScrollPane(textArea);
JPanel panel = new JPanel(new BorderLayout());
panel.add(scrollPane, BorderLayout.CENTER);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class VSyncedBufferStrategyTest method createAndShowDescGUI.
private static void createAndShowDescGUI(final Frame f3, final Frame f1, final Frame f2) throws HeadlessException, RuntimeException {
final JFrame desc = new JFrame("VSyncedBufferStrategyTest - Description");
desc.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
f1.dispose();
f2.dispose();
f3.dispose();
l.countDown();
}
});
JPanel p = new JPanel();
JButton bPassed = new JButton("Passed");
bPassed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
desc.dispose();
f1.dispose();
f2.dispose();
f3.dispose();
l.countDown();
}
});
JButton bFailed = new JButton("Failed");
bFailed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
failed = true;
desc.dispose();
f1.dispose();
f2.dispose();
f3.dispose();
l.countDown();
}
});
p.setLayout(new FlowLayout());
p.add(bPassed);
p.add(bFailed);
JTextArea ta = new JTextArea(24, 75);
ta.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
ta.setEditable(false);
ta.setText(description);
desc.add("Center", new JScrollPane(ta));
desc.add("South", p);
desc.pack();
desc.setLocation(BLOCK_W * 10 + 50, 0);
desc.setVisible(true);
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class DisposeFrameOnDragTest method constructTestUI.
private static void constructTestUI() {
final JFrame frame = new JFrame("Test frame");
textArea = new JTextArea("Drag Me!");
try {
textArea.getDropTarget().addDropTargetListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetDropEvent dtde) {
//IGNORE
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
frame.dispose();
}
});
} catch (TooManyListenersException ex) {
throw new RuntimeException(ex);
}
textArea.setSize(100, 100);
textArea.setDragEnabled(true);
textArea.select(0, textArea.getText().length());
frame.add(textArea);
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
}
use of javax.swing.JTextArea in project java-design-patterns by iluwatar.
the class Client method setup.
private void setup() {
setLayout(new BorderLayout());
JPanel panel = new JPanel();
add(jl, BorderLayout.SOUTH);
add(panel, BorderLayout.CENTER);
panel.setLayout(new GridLayout(6, 2));
panel.add(new JLabel("Name"));
panel.add(jtFields[0]);
panel.add(new JLabel("Contact Number"));
panel.add(jtFields[1]);
panel.add(new JLabel("Address"));
panel.add(jtAreas[0]);
panel.add(new JLabel("Deposit Number"));
panel.add(jtFields[2]);
panel.add(new JLabel("Order"));
panel.add(jtAreas[1]);
panel.add(clearButton);
panel.add(processButton);
clearButton.addActionListener(e -> {
for (JTextArea i : jtAreas) {
i.setText("");
}
for (JTextField i : jtFields) {
i.setText("");
}
});
processButton.addActionListener(e -> {
Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(), jtAreas[1].getText());
jl.setText(sendRequest(order));
});
JRootPane rootPane = SwingUtilities.getRootPane(processButton);
rootPane.setDefaultButton(processButton);
setVisible(true);
}
Aggregations