Search in sources :

Example 6 with TextArea

use of java.awt.TextArea in project Smack by igniterealtime.

the class JMFInit method createGUI.

private void createGUI() {
    TextArea textBox = new TextArea(5, 50);
    add("Center", textBox);
    textBox.setEditable(false);
    addNotify();
    pack();
    int scrWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int scrHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    setLocation((scrWidth - getWidth()) / 2, (scrHeight - getHeight()) / 2);
    setVisible(visible);
}
Also used : TextArea(java.awt.TextArea)

Example 7 with TextArea

use of java.awt.TextArea in project jdk8u_jdk by JetBrains.

the class bug7129742 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            frame = new JFrame("Test");
            TextArea textArea = new TextArea("Non-editable textArea");
            textArea.setEditable(false);
            frame.setLayout(new FlowLayout());
            frame.add(textArea);
            frame.pack();
            frame.setVisible(true);
            try {
                Class XTextAreaPeerClzz = textArea.getPeer().getClass();
                System.out.println(XTextAreaPeerClzz.getName());
                if (!XTextAreaPeerClzz.getName().equals("sun.awt.X11.XTextAreaPeer")) {
                    fastreturn = true;
                    return;
                }
                Field jtextField = XTextAreaPeerClzz.getDeclaredField("jtext");
                jtextField.setAccessible(true);
                JTextArea jtext = (JTextArea) jtextField.get(textArea.getPeer());
                caret = (DefaultCaret) jtext.getCaret();
                textArea.requestFocusInWindow();
            } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
                /* These exceptions mean the implementation of XTextAreaPeer is
                     * changed, this testcase is not valid any more, fix it or remove.
                     */
                frame.dispose();
                throw new RuntimeException("This testcase is not valid any more!");
            }
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            try {
                if (fastreturn) {
                    return;
                }
                boolean passed = caret.isActive();
                System.out.println("is caret visible : " + passed);
                if (!passed) {
                    throw new RuntimeException("The test for bug 71297422 failed");
                }
            } finally {
                frame.dispose();
            }
        }
    });
}
Also used : Field(java.lang.reflect.Field) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) DefaultCaret(javax.swing.text.DefaultCaret) JFrame(javax.swing.JFrame) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) SunToolkit(sun.awt.SunToolkit)

Example 8 with TextArea

use of java.awt.TextArea in project jdk8u_jdk by JetBrains.

the class TextAreaTwicePack method main.

public static void main(final String[] args) {
    final Frame frame = new Frame();
    final TextArea ta = new TextArea();
    frame.add(ta);
    frame.pack();
    frame.setVisible(true);
    sleep();
    final Dimension before = frame.getSize();
    frame.pack();
    final Dimension after = frame.getSize();
    if (!after.equals(before)) {
        throw new RuntimeException("Expected size: " + before + ", actual size: " + after);
    }
    frame.dispose();
}
Also used : Frame(java.awt.Frame) TextArea(java.awt.TextArea) Dimension(java.awt.Dimension)

Example 9 with TextArea

use of java.awt.TextArea in project jdk8u_jdk by JetBrains.

the class TestApplet method init.

public void init() {
    final TextArea log = new TextArea("Events:\n");
    log.setEditable(false);
    log.setSize(400, 200);
    this.add(log);
    log.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            log.append("Key typed: char = " + e.getKeyChar() + "\n");
        }

        @Override
        public void keyPressed(KeyEvent e) {
            log.append("Key pressed: char = " + e.getKeyChar() + " code = " + e.getKeyCode() + "\n");
        }

        @Override
        public void keyReleased(KeyEvent e) {
            log.append("Key released: char = " + e.getKeyChar() + " code = " + e.getKeyCode() + "\n");
        }
    });
}
Also used : KeyEvent(java.awt.event.KeyEvent) TextArea(java.awt.TextArea) KeyAdapter(java.awt.event.KeyAdapter)

Example 10 with TextArea

use of java.awt.TextArea in project voltdb by VoltDB.

the class DatabaseManager method initGUI.

private void initGUI() {
    Panel pQuery = new Panel();
    Panel pCommand = new Panel();
    pResult = new Panel();
    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());
    Font fFont = new Font("Dialog", Font.PLAIN, 12);
    txtCommand = new TextArea(5, 40);
    txtCommand.addKeyListener(this);
    txtResult = new TextArea(20, 40);
    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    butExecute = new Button("Execute");
    butClear = new Button("Clear");
    butExecute.addActionListener(this);
    butClear.addActionListener(this);
    pCommand.add("East", butExecute);
    pCommand.add("West", butClear);
    pCommand.add("Center", txtCommand);
    gResult = new Grid();
    setLayout(new BorderLayout());
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    fMain.add("Center", pQuery);
    tTree = new Tree();
    // (ulrivo): screen with less than 640 width
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    if (d.width >= 640) {
        tTree.setMinimumSize(new Dimension(200, 100));
    } else {
        tTree.setMinimumSize(new Dimension(80, 100));
    }
    gResult.setMinimumSize(new Dimension(200, 300));
    fMain.add("West", tTree);
    doLayout();
    fMain.pack();
}
Also used : Panel(java.awt.Panel) BorderLayout(java.awt.BorderLayout) TextArea(java.awt.TextArea) Button(java.awt.Button) Dimension(java.awt.Dimension) Font(java.awt.Font)

Aggregations

TextArea (java.awt.TextArea)11 Panel (java.awt.Panel)5 Dimension (java.awt.Dimension)4 BorderLayout (java.awt.BorderLayout)3 Button (java.awt.Button)3 Frame (java.awt.Frame)3 TextField (java.awt.TextField)3 Checkbox (java.awt.Checkbox)2 FlowLayout (java.awt.FlowLayout)2 Font (java.awt.Font)2 GridLayout (java.awt.GridLayout)2 JFrame (javax.swing.JFrame)2 GenericDialog (ij.gui.GenericDialog)1 NonBlockingGenericDialog (ij.gui.NonBlockingGenericDialog)1 Canvas (java.awt.Canvas)1 CardLayout (java.awt.CardLayout)1 Choice (java.awt.Choice)1 Component (java.awt.Component)1 Dialog (java.awt.Dialog)1 FileDialog (java.awt.FileDialog)1