use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class WrongKeyTypedConsumedTest method start.
public void start() {
setSize(200, 200);
setVisible(true);
validate();
JFrame frame = new JFrame("The Frame");
Set ftk = new HashSet();
ftk.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DOWN, 0));
frame.getContentPane().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, ftk);
JCheckBox checkbox = new JCheckBox("test");
frame.getContentPane().add(checkbox, BorderLayout.NORTH);
JTextArea textarea = new JTextArea(40, 10);
frame.getContentPane().add(textarea);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(robot);
if (!frame.isActive()) {
throw new RuntimeException("Test Fialed: frame isn't active");
}
// verify if checkbox has focus
if (!checkbox.isFocusOwner()) {
checkbox.requestFocusInWindow();
Util.waitForIdle(robot);
if (!checkbox.isFocusOwner()) {
throw new RuntimeException("Test Failed: checkbox doesn't have focus");
}
}
// press VK_DOWN
robot.keyPress(KeyEvent.VK_DOWN);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_DOWN);
robot.delay(50);
Util.waitForIdle(robot);
// verify if text area has focus
if (!textarea.isFocusOwner()) {
throw new RuntimeException("Test Failed: focus wasn't transfered to text area");
}
// press '1'
robot.keyPress(KeyEvent.VK_1);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_1);
robot.delay(50);
Util.waitForIdle(robot);
// verify if KEY_TYPED arrived
if (!"1".equals(textarea.getText())) {
throw new RuntimeException("Test Failed: text area text is \"" + textarea.getText() + "\", not \"1\"");
}
System.out.println("Test Passed");
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class TooMuchWheelRotationEventsTest method createUI.
private static void createUI() {
final JFrame mainFrame = new JFrame("Trackpad scrolling test");
GridBagLayout layout = new GridBagLayout();
JPanel mainControlPanel = new JPanel(layout);
JPanel resultButtonPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
JPanel testPanel = createTestPanel();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(testPanel, gbc);
JTextArea instructionTextArea = new JTextArea();
instructionTextArea.setText(INSTRUCTIONS);
instructionTextArea.setEditable(false);
instructionTextArea.setBackground(Color.white);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(instructionTextArea, gbc);
JButton passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener((ActionEvent e) -> {
testResult = true;
mainFrame.dispose();
countDownLatch.countDown();
});
JButton failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
mainFrame.add(mainControlPanel);
mainFrame.pack();
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
mainFrame.setVisible(true);
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method doTest.
private static void doTest(Runnable action) {
String description = " A TexturePaint graphics will be shown on console.\n" + " The same graphics is sent to printer.\n" + " Please verify if TexturePaint shading is printed.\n" + " If none is printed, press FAIL else press PASS";
final JDialog dialog = new JDialog();
dialog.setTitle("printSelectionTest");
JTextArea textArea = new JTextArea(description);
textArea.setEditable(false);
final JButton testButton = new JButton("Start Test");
final JButton passButton = new JButton("PASS");
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
pass();
});
final JButton failButton = new JButton("FAIL");
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
fail();
});
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
action.run();
passButton.setEnabled(true);
failButton.setEnabled(true);
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.out.println("main dialog closing");
testGeneratedInterrupt = false;
mainThread.interrupt();
}
});
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class TextViewOOM method createAndShowGUI.
private static void createAndShowGUI() {
frame = new JFrame();
final JScrollPane jScrollPane1 = new JScrollPane();
ta = new JTextArea();
ta.setEditable(false);
ta.setColumns(20);
ta.setRows(5);
jScrollPane1.setViewportView(ta);
frame.add(ta);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
use of javax.swing.JTextArea in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
Aggregations