import javax.imageio.*; import java.awt.image.*; import java.awt.event.*; import java.awt.*; import java.security.spec.*; import java.security.*; import java.lang.management.*; import java.lang.ref.*; import java.lang.reflect.*; import java.net.*; import java.io.*; import javax.swing.table.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.*; import java.util.concurrent.atomic.*; import java.util.concurrent.*; import java.util.regex.*; import java.util.List; import java.util.zip.*; import java.util.*; public class main { public static void main(String[] args) throws Exception { showFrame("Yo vgrid!", vgrid("Hello", "world", newTypeWriterTextArea("Type something!"))); } static JPanel vgrid(Object... parts) { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(parts.length, 1)); smartAdd(panel, parts); return panel; } 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 void smartAdd(JPanel panel, Object... parts) { for (Object o : parts) { Component c; if (o instanceof String) c = new JLabel((String) o); else if (o instanceof Component) c = wrap((Component) o); else continue; panel.add(c); } } 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; } static Component wrap(Component c) { if (c instanceof JTable || c instanceof JList || c instanceof JTextArea) return new JScrollPane(c); return c; } }