import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import java.math.*; public class main { public static void main(String[] args) throws Exception { showSideBySide("Two Text Areas", withTitle("Left Text", newTypeWriterTextArea()), withTitle("Right Text", newTypeWriterTextArea())); } static JComponent withTitle(String title, Component c) { return withTitle(withTitle_titlePanel(title), c); } static JComponent withTitle_titlePanel(String title) { return new JLabel(title); } static JPanel withTitle(JComponent titleComponent, Component c) { titleComponent.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("Button.borderColor"))); JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.WHITE); panel.add(BorderLayout.NORTH, titleComponent); panel.add(BorderLayout.CENTER, wrap(c)); return panel; } static JFrame showSideBySide(String title, Component c1, Component c2) { JFrame frame = showFrame(title); frame.getContentPane().setLayout(new GridLayout(1, 2)); frame.getContentPane().add(wrap(c1)); frame.getContentPane().add(wrap(c2)); swingUpdate(frame); return frame; } static JTextArea newTypeWriterTextArea() { JTextArea textArea = new JTextArea(); textArea.setFont(new Font("Courier", Font.PLAIN, 14)); return textArea; } static JTextArea newTypeWriterTextArea(String text) { JTextArea textArea = newTypeWriterTextArea(); textArea.setText(text); return textArea; } static JFrame showFrame() { return makeFrame(); } static JFrame showFrame(Component content) { return makeFrame(content); } static JFrame showFrame(String title) { return makeFrame(title); } static JFrame showFrame(String title, Component content) { return makeFrame(title, content); } static Component wrap(Component c) { if (c instanceof JTable || c instanceof JList || c instanceof JTextArea) return new JScrollPane(c); return c; } static void swingUpdate(Component c) { c.revalidate(); c.repaint(); } static JFrame makeFrame() { return makeFrame((Component) null); } static JFrame makeFrame(Component content) { // TODO: get program ID return makeFrame("A JavaX Frame", content); } static JFrame makeFrame(String title) { return makeFrame(title, null); } static JFrame makeFrame(String title, Component content) { JFrame frame = new JFrame(title); if (content != null) frame.getContentPane().add(content); frame.setBounds(300, 100, 500, 400); frame.setVisible(true); //exitOnFrameClose(frame); return frame; } }