Search in sources :

Example 76 with JTextArea

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());
        }
    });
}
Also used : JCheckBox(javax.swing.JCheckBox) DocumentListener(javax.swing.event.DocumentListener) JTextArea(javax.swing.JTextArea) DocumentEvent(javax.swing.event.DocumentEvent)

Example 77 with JTextArea

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

Example 78 with JTextArea

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) 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) Font(java.awt.Font)

Example 79 with JTextArea

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);
}
Also used : DropTargetAdapter(java.awt.dnd.DropTargetAdapter) DropTargetDragEvent(java.awt.dnd.DropTargetDragEvent) TooManyListenersException(java.util.TooManyListenersException) JTextArea(javax.swing.JTextArea) JFrame(javax.swing.JFrame) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent)

Example 80 with JTextArea

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);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JTextArea(javax.swing.JTextArea) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) JRootPane(javax.swing.JRootPane) JTextField(javax.swing.JTextField)

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