Example usage for javax.swing JTextArea JTextArea

List of usage examples for javax.swing JTextArea JTextArea

Introduction

In this page you can find the example usage for javax.swing JTextArea JTextArea.

Prototype

public JTextArea() 

Source Link

Document

Constructs a new TextArea.

Usage

From source file:net.sf.firemox.ui.wizard.AboutMdb.java

/**
 * Creates a new instance of AboutMdb <br>
 * //  www.j  a v  a2  s .com
 * @param parent
 */
public AboutMdb(JFrame parent) {
    super(LanguageManager.getString("about.tbs"),
            "<html><b>" + LanguageManager.getString("tbsname") + ": </b>" + MdbLoader.getTbsFullName()
                    + "<br><b>" + LanguageManager.getString("author") + ": </b>" + MdbLoader.getAuthor()
                    + "<br><b>" + LanguageManager.getString("info") + ": </b>" + MdbLoader.getMoreInfo()
                    + "<br><b>" + LanguageManager.getString("version") + ": </b>" + MdbLoader.getVersion(),
            "mp64.gif", LanguageManager.getString("close"), 420, 320);
    JTextArea disclaimer = new JTextArea();
    disclaimer.setEditable(false);
    disclaimer.setLineWrap(true);
    disclaimer.setWrapStyleWord(true);
    disclaimer.setAutoscrolls(true);
    // Then try and read it locally
    final InputStream inGPL = MToolKit.getResourceAsStream(MToolKit.mdbFile);
    if (inGPL != null) {
        disclaimer.setText(MdbLoader.getDisclaimer().replaceAll("\t", "").replaceAll("\n", ""));
        IOUtils.closeQuietly(inGPL);
    }
    JScrollPane disclaimerSPanel = new JScrollPane();
    disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(disclaimerSPanel);
    disclaimerSPanel.setViewportView(disclaimer);
    gameParamPanel.add(disclaimerSPanel);
    setLocation((getToolkit().getScreenSize().width - 420) / 2,
            (getToolkit().getScreenSize().height - 320) / 2);
}

From source file:de.bley.word.menu.GuiMenu.java

/**
 * Kmponenten der Oberflaeche werden Initialisiert.
 *//*from  w  ww  .  j  ava2  s .c  om*/
public GuiMenu() {
    instance = this;
    setBounds(0, 0, Toolkit.getDefaultToolkit().getScreenSize().width / 4,
            Toolkit.getDefaultToolkit().getScreenSize().height / 2);
    setLocationRelativeTo(null);
    menuPanel = new MenuBarPanel();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.LIGHT_GRAY);
    textfield = new JTextArea();
    panel.add(textfield);
    JScrollPane scr = new JScrollPane(textfield, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    panel.add(scr);
    button = new JButton();
    button.setText("Save");
    addListener();

}

From source file:ProgressMonitorInputStreamTest.java

public TextFrame() {
    setTitle("ProgressMonitorInputStreamTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    textArea = new JTextArea();
    add(new JScrollPane(textArea));

    chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*from w  w w. j  ava  2  s  . com*/
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    openItem = new JMenuItem("Open");
    openItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                openFile();
            } catch (IOException exception) {
                exception.printStackTrace();
            }
        }
    });

    fileMenu.add(openItem);
    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
    fileMenu.add(exitItem);
}

From source file:InterruptibleSocketTest.java

public InterruptibleSocketFrame() {
    setSize(WIDTH, HEIGHT);/*from w  w w. j a v  a2 s  .  c o  m*/
    setTitle("InterruptibleSocketTest");

    JPanel northPanel = new JPanel();
    add(northPanel, BorderLayout.NORTH);

    messages = new JTextArea();
    add(new JScrollPane(messages));

    interruptibleButton = new JButton("Interruptible");
    blockingButton = new JButton("Blocking");

    northPanel.add(interruptibleButton);
    northPanel.add(blockingButton);

    interruptibleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            interruptibleButton.setEnabled(false);
            blockingButton.setEnabled(false);
            cancelButton.setEnabled(true);
            connectThread = new Thread(new Runnable() {
                public void run() {
                    try {
                        connectInterruptibly();
                    } catch (IOException e) {
                        messages.append("\nInterruptibleSocketTest.connectInterruptibly: " + e);
                    }
                }
            });
            connectThread.start();
        }
    });

    blockingButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            interruptibleButton.setEnabled(false);
            blockingButton.setEnabled(false);
            cancelButton.setEnabled(true);
            connectThread = new Thread(new Runnable() {
                public void run() {
                    try {
                        connectBlocking();
                    } catch (IOException e) {
                        messages.append("\nInterruptibleSocketTest.connectBlocking: " + e);
                    }
                }
            });
            connectThread.start();
        }
    });

    cancelButton = new JButton("Cancel");
    cancelButton.setEnabled(false);
    northPanel.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            connectThread.interrupt();
            cancelButton.setEnabled(false);
        }
    });
    server = new TestServer();
    new Thread(server).start();
}

From source file:de.ipk_gatersleben.ag_nw.graffiti.services.GUIhelper.java

public static Component getHelpTextComponent(String plainText, String title, String helpTopic) {
    JPanel result = new JPanel();
    plainText = plainText.replaceAll("<br>", "\n");
    plainText = plainText.replaceAll("<html>", "");
    plainText = plainText.replaceAll("<small>", "");
    FolderPanel fp = new FolderPanel(title, false, false, false,
            JLabelJavaHelpLink.getHelpActionListener(helpTopic));
    JTextArea helpText = new JTextArea();
    helpText.setLineWrap(true);//from  w w  w . ja  v a2s . c o  m
    helpText.setWrapStyleWord(true);
    helpText.setText(plainText);
    helpText.setEditable(false);
    fp.addGuiComponentRow(new JLabel(""), helpText, false);
    fp.layoutRows();
    fp.setFrameColor(Color.LIGHT_GRAY, Color.WHITE, 1, 5);

    double border = 2;
    double topBorder = 12;
    double[][] size = { { border, TableLayoutConstants.FILL, border }, // Columns
            { topBorder, TableLayoutConstants.PREFERRED, border } }; // Rows
    result.setLayout(new TableLayout(size));
    result.add(fp, "1,1");
    return result;
}

From source file:TextViewer.java

/**
 * Constructor/*from  w  ww.j a v a  2 s  .c om*/
 */
public TextViewer() {
    super(new GridLayout(1, 1));

    // create the text area
    text_area = new JTextArea();
    text_area.setEditable(false);
    text_area.setLineWrap(true);

    // create a scroll pane for the JTextArea
    JScrollPane sp = new JScrollPane();
    sp.setPreferredSize(new Dimension(300, 300));
    sp.getViewport().add(text_area);

    add(sp);
}

From source file:gtu.xml.xstream.iisi.MQDecodeUI.java

private void initGUI() {
    try {// w w w.  j av  a  2 s .  c o  m
        JCommonUtil.defaultLookAndFeel();
        GridLayout thisLayout = new GridLayout(3, 1);
        thisLayout.setColumns(1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setRows(3);
        getContentPane().setLayout(thisLayout);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            beforeArea = new JTextArea();
            getContentPane().add(beforeArea);
        }
        {
            afterArea = new JTextArea();
            getContentPane().add(afterArea);
        }
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            getContentPane().add(jPanel1);
            jPanel1.setPreferredSize(new java.awt.Dimension(546, 38));
            jPanel1.setLayout(jPanel1Layout);
            {
                executeBtn = new JButton();
                jPanel1.add(executeBtn);
                executeBtn.setText("\u7522\u751f");
                executeBtn.setPreferredSize(new java.awt.Dimension(78, 22));
                executeBtn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        try {
                            Validate.notBlank(beforeArea.getText(), "messgaeContent");
                            String msg2 = beforeArea.getText();

                            XmlParserImpl xmlParserImpl = new XmlParserImpl();
                            final String jmsMessageXML = StringCompressUtil.uncompress(msg2);
                            JmsMessageNew jmsMessageNew = (JmsMessageNew) xmlParserImpl
                                    .parseToObj(jmsMessageXML);
                            String returnMessage = jmsMessageNew.getMessageXML();
                            System.out.println(returnMessage);
                            afterArea.setText(returnMessage);
                            System.out.println("done...");
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
            }
            {
                cleanBtn = new JButton();
                jPanel1.add(cleanBtn);
                cleanBtn.setText("\u6e05\u9664");
                cleanBtn.setPreferredSize(new java.awt.Dimension(78, 22));
                cleanBtn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        try {
                            beforeArea.setText("");
                            afterArea.setText("");
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
            }
        }
        pack();
        this.setSize(554, 402);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:com.igormaznitsa.sciareto.ui.editors.TextEditor.java

public TextEditor(@Nonnull final Context context, @Nullable File file) throws IOException {
    super();/*w  ww  .  j ava 2 s.  com*/
    this.editor = new JTextArea();
    this.title = new TabTitle(context, this, file);

    this.editor.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(@Nonnull final DocumentEvent e) {
            if (!ignoreChange) {
                title.setChanged(true);
            }
        }

        @Override
        public void removeUpdate(@Nonnull final DocumentEvent e) {
            if (!ignoreChange) {
                title.setChanged(true);
            }
        }

        @Override
        public void changedUpdate(@Nonnull final DocumentEvent e) {
            if (!ignoreChange) {
                title.setChanged(true);
            }
        }
    });

    setViewportView(this.editor);

    loadContent(file);
}

From source file:com.github.rholder.gradle.ui.DependencyViewerStandalone.java

public DependencyViewerStandalone() {
    super(TITLE);
    this.dependencyCellRenderer = new DependencyCellRenderer();
    this.information = new JTextArea();
    this.information.setEditable(false);

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setSize(1024, 768);//from  w w  w. j  a  v a 2 s .  c o  m
    setLocation(128, 128);

    initMenu();
    initToolingLogger();
    initContent();
}

From source file:ee.ioc.cs.vsle.util.Console.java

private Console() {
    // create all components and add them
    frame = new JFrame("Java Console");
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = new Dimension((screenSize.width / 2), (screenSize.height / 2));
    int x = (frameSize.width / 2);
    int y = (frameSize.height / 2);
    frame.setBounds(x, y, frameSize.width, frameSize.height);

    textArea = new JTextArea();
    textArea.setEditable(false);/*from   w ww  . j  av a  2 s  .  c  om*/
    JButton button = new JButton("clear");

    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER);
    frame.getContentPane().add(button, BorderLayout.SOUTH);
    frame.setVisible(true);

    frame.addWindowListener(this);
    button.addActionListener(this);

    final PipedInputStream pin = new PipedInputStream();
    try {
        PipedOutputStream pout = new PipedOutputStream(pin);
        System.setOut(new PrintStream(new TeeOutputStream(systemOut, pout), true));
    } catch (java.io.IOException io) {
        textArea.append("Couldn't redirect STDOUT to this console\n" + io.getMessage());
    } catch (SecurityException se) {
        textArea.append("Couldn't redirect STDOUT to this console\n" + se.getMessage());
    }

    final PipedInputStream pin2 = new PipedInputStream();
    try {
        PipedOutputStream pout2 = new PipedOutputStream(pin2);
        System.setErr(new PrintStream(new TeeOutputStream(systemErr, pout2), true));
    } catch (java.io.IOException io) {
        textArea.append("Couldn't redirect STDERR to this console\n" + io.getMessage());
    } catch (SecurityException se) {
        textArea.append("Couldn't redirect STDERR to this console\n" + se.getMessage());
    }

    quit = false; // signals the Threads that they should exit

    sysOutFollower = new StreamFollower(pin, StreamRestorer.SYS_OUT, "Console_out");
    sysOutFollower.start();
    //
    sysErrFollower = new StreamFollower(pin2, StreamRestorer.SYS_ERR, "Console_err");
    sysErrFollower.start();
}