Search in sources :

Example 36 with JTextArea

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");
}
Also used : JCheckBox(javax.swing.JCheckBox) Set(java.util.Set) HashSet(java.util.HashSet) JTextArea(javax.swing.JTextArea) JFrame(javax.swing.JFrame) HashSet(java.util.HashSet)

Example 37 with JTextArea

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);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter)

Example 38 with JTextArea

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();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 39 with JTextArea

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) JFrame(javax.swing.JFrame)

Example 40 with JTextArea

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");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JTextArea (javax.swing.JTextArea)182 JScrollPane (javax.swing.JScrollPane)104 JPanel (javax.swing.JPanel)79 BorderLayout (java.awt.BorderLayout)60 JButton (javax.swing.JButton)59 JLabel (javax.swing.JLabel)59 Dimension (java.awt.Dimension)36 JTextField (javax.swing.JTextField)35 JFrame (javax.swing.JFrame)33 ActionEvent (java.awt.event.ActionEvent)26 Font (java.awt.Font)24 GridBagLayout (java.awt.GridBagLayout)23 GridBagConstraints (java.awt.GridBagConstraints)22 Insets (java.awt.Insets)22 ActionListener (java.awt.event.ActionListener)21 FlowLayout (java.awt.FlowLayout)20 Color (java.awt.Color)18 JCheckBox (javax.swing.JCheckBox)18 JSplitPane (javax.swing.JSplitPane)16 EmptyBorder (javax.swing.border.EmptyBorder)16