List of usage examples for javax.swing JFrame show
@Deprecated public void show()
From source file:SpringFormTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Spring"); Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout);/* w ww .ja va 2s .c o m*/ Component left = new JLabel("Left"); Component right = new JTextField(15); contentPane.add(left); contentPane.add(right); layout.putConstraint(SpringLayout.WEST, left, 10, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, left, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.NORTH, right, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, right, 20, SpringLayout.EAST, left); frame.setSize(300, 100); frame.show(); }
From source file:ColorSink.java
/** This is a simple test program for ColorSource and ColorSink */ public static void main(String[] args) { // Create a window JFrame f = new JFrame("ColorSourceTest"); f.getContentPane().setLayout(new BorderLayout()); // Add some ColorSources JPanel panel = new JPanel(); f.getContentPane().add(panel, BorderLayout.NORTH); panel.add(new ColorSource(Color.yellow)); panel.add(new ColorSource(Color.pink)); panel.add(new ColorSource(Color.white)); panel.add(new ColorSource(Color.gray)); // Add a ColorSink ColorSink sink = new ColorSink(); f.getContentPane().add(sink, BorderLayout.CENTER); // Pop it all up f.setSize(400, 300);//from www .j a v a 2 s . co m f.show(); }
From source file:EditabilityExample.java
public static void main(String[] args) { try {//from w w w . j a v a 2 s .com UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Editability Example"); f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS)); f.getContentPane().add(firstField); JTextField tf = new JTextField("A read-only text field", 20); tf.setEditable(false); f.getContentPane().add(tf); JTextArea ta = new JTextArea("An editable\ntext area", 2, 20); ta.setBorder(BorderFactory.createLoweredBevelBorder()); f.getContentPane().add(ta); ta = new JTextArea("A read-only\ntext area", 2, 20); ta.setBorder(BorderFactory.createLoweredBevelBorder()); ta.setEditable(false); f.getContentPane().add(ta); f.pack(); f.show(); if (args.length == 1 && args[0].equals("disable")) { // Toggle the enabled state of the first // text field every 10 seconds Timer t = new Timer(10000, new ActionListener() { public void actionPerformed(ActionEvent evt) { firstField.setEnabled(!firstField.isEnabled()); firstField.setText(firstFieldText + (firstField.isEnabled() ? "" : " (disabled)")); } }); t.start(); } }
From source file:SimpleSoundCapture.java
public static void main(String s[]) { SimpleSoundCapture ssc = new SimpleSoundCapture(); ssc.open();/* ww w . jav a 2s .c o m*/ JFrame f = new JFrame("Capture/Playback"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add("Center", ssc); f.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int w = 360; int h = 170; f.setLocation(screenSize.width / 2 - w / 2, screenSize.height / 2 - h / 2); f.setSize(w, h); f.show(); }
From source file:Command.java
public static void main(String[] args) throws IOException { javax.swing.JFrame f = new javax.swing.JFrame("Command Test"); javax.swing.JButton b1 = new javax.swing.JButton("Tick"); javax.swing.JButton b2 = new javax.swing.JButton("Tock"); javax.swing.JLabel label = new javax.swing.JLabel("Hello world"); java.awt.Container pane = f.getContentPane(); pane.add(b1, java.awt.BorderLayout.WEST); pane.add(b2, java.awt.BorderLayout.EAST); pane.add(label, java.awt.BorderLayout.NORTH); b1.addActionListener(Command.parse(label, "setText(\"tick\");")); b2.addActionListener(Command.parse(label, "setText(\"tock\");")); f.pack();/*from w ww.j a va 2 s .co m*/ f.show(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("UIDefaults Example"); frame.setDefaultCloseOperation(3);//from ww w. ja v a2 s . co m Container c = frame.getContentPane(); UIManager.put("Button.background", Color.red); UIManager.put("Button.foreground", Color.white); Font f = new Font("Serif", Font.ITALIC, 24); UIManager.put("Button.font", f); JButton north = new JButton("North"); JButton south = new JButton("South"); JButton east = new JButton("East"); JButton west = new JButton("West"); JButton center = new JButton("Center"); c.add(north, BorderLayout.NORTH); c.add(south, BorderLayout.SOUTH); c.add(east, BorderLayout.EAST); c.add(west, BorderLayout.WEST); c.add(center, BorderLayout.CENTER); frame.pack(); frame.show(); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); Container pane = f.getContentPane(); Icon icon = new RedOvalIcon(); final Action action = new MyAction("Hello", icon); // Add tooltip action.putValue(Action.SHORT_DESCRIPTION, "World"); JToolBar jt1 = new JToolBar(); JButton b1 = new JButton(action); jt1.add(b1);/*from w w w . ja v a 2 s. com*/ pane.add(jt1, BorderLayout.NORTH); JToolBar jt2 = new JToolBar(); JButton b2 = new JButton(action); jt2.add(b2); pane.add(jt2, BorderLayout.SOUTH); JButton jb = new JButton("Toggle Action"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { action.setEnabled(!action.isEnabled()); } }); pane.add(jb, BorderLayout.CENTER); f.setSize(200, 200); f.show(); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java
public static void main(String[] args) { MIResultPanel p = new MIResultPanel(null, "test", new ArrayList<MIResult>(), "test", new MIQuery()); JFrame f = new JFrame(); f.setSize(1024, 800);/*w w w. j ava 2 s . com*/ f.add(p); f.show(); }
From source file:GridBagWithWeight.java
public static void main(String[] args) { JFrame f = new JFrame("Demonstrates the use of weightx, weighty constraints"); JPanel p = new JPanel(); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); p.setLayout(new GridBagLayout()); c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weighty = 1.0;// ww w .j ava 2s . c om c.weightx = 1.0; c.gridx = 0; c.gridy = 0; p.add(new JButton("Java"), c); c.gridx = 1; p.add(new JButton("Source"), c); c.gridx = 0; c.gridy = 1; p.add(new JButton("and"), c); c.gridx = 1; p.add(new JButton("Support."), c); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; f.addWindowListener(wndCloser); f.getContentPane().add(p); f.setSize(600, 200); f.show(); }
From source file:HyperlinkTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); final JEditorPane ep = new JEditorPane(); try {//from ww w. jav a 2s . c o m ep.setPage("http://www.java2s.com"); } catch (IOException e) { System.err.println("Bad URL: " + e); System.exit(-1); } HyperlinkListener listener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { ep.setPage(e.getURL()); } catch (IOException ioe) { System.err.println("Error loading: " + ioe); } } } }; ep.addHyperlinkListener(listener); ep.setEditable(false); JScrollPane pane = new JScrollPane(ep); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(640, 480); frame.show(); }