List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] argv) { JFrame frame = new Main(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// w ww. j a v a2 s. com } }); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new Main()); frame.setPreferredSize(new Dimension(500, 400)); frame.pack(); frame.setVisible(true);/*from w w w . ja v a 2s . c o m*/ }
From source file:TextFieldViews.java
public static void main(String[] args) { try {/* w ww . j a va 2 s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Text Field View"); JTextField tf = new JTextField(32); tf.setText("That's one small step for man..."); f.getContentPane().add(tf); f.pack(); f.setVisible(true); ViewDisplayer.displayViews(tf, System.out); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JLabel("Auto Hide")); frame.pack(); frame.setVisible(true);// w w w . j a v a 2 s . co m Timer autoHideTimer = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.dispose(); } }); autoHideTimer.setRepeats(false); frame.addMouseListener(new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { System.out.println("Restart..."); autoHideTimer.restart(); } @Override public void mouseEntered(MouseEvent e) { System.out.println("Stop"); autoHideTimer.stop(); } }); }
From source file:Main.java
public static void main(String[] argv) { DateSpinner textField = new DateSpinner(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(textField); frame.pack(); frame.setVisible(true);/* w ww . j a va2 s.c o m*/ }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override/* www . j av a 2 s . c o m*/ public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Panel panel = new Panel(); frame.setContentPane(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); DrawPanel dp = new DrawPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(dp);// ww w . j a v a 2 s . c om frame.pack(); frame.setLocationByPlatform(true); try { Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); for (int i = 0; i < 120; i += 4) { int d = (int) Math.abs(new Random().nextGaussian() * 24) + 32; track.add(makeEvent(ShortMessage.NOTE_ON, 1, d, 127, i)); track.add(makeEvent(ShortMessage.CONTROL_CHANGE, 1, 127, 0, i)); track.add(makeEvent(ShortMessage.NOTE_OFF, 1, d, 127, i)); } Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(seq); sequencer.addControllerEventListener(dp, new int[] { 127 }); sequencer.start(); } catch (Exception e) { e.printStackTrace(); } frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] argv) { JFrame frame = new MainClass(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from www.j ava 2s. com } }); frame.pack(); frame.setVisible(true); }
From source file:edu.mit.fss.tutorial.part4.ElementGUI.java
/** * The main method./* www . j a v a 2 s . c om*/ * * @param args the arguments * @throws RTIexception the RTI exception */ public static void main(String[] args) throws RTIexception { // Configure the logger and set it to display info messages. BasicConfigurator.configure(); logger.setLevel(Level.INFO); // Use an input dialog to request the element's name. String name = null; while (name == null || name.isEmpty()) { name = JOptionPane.showInputDialog("Enter element name:"); } // Create a MobileElement object instance. The "final" keyword allows // it to be referenced in the GUI thread below. final MobileElement element = new MobileElement(name, new Vector3D(0, 0, 0)); // Create an OnlineTutorialFederate object instance. The "final" // keyword allows it to be referenced in the GUI thread below. final OnlineTutorialFederate fed = new OnlineTutorialFederate(element); // Create the graphical user interface using the Event Dispatch Thread. try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // Create a new ControlPanel object instance. ControlPanel controlPanel = new ControlPanel(); // Bind it to the element above. controlPanel.setBoundElement(element); // Add the control panel as an object change listener. fed.addObjectChangeListener(controlPanel); // Create a new frame to display the panel. Add the panel // as the content, pack it, and make it visible. JFrame frame = new JFrame(); frame.setContentPane(controlPanel); frame.pack(); frame.setVisible(true); // Add a new WindowAdapter object instance to exit the // federate when the window is closing. frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { fed.exit(); } }); } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e); } // Execute the federate. fed.execute(0, Long.MAX_VALUE, 1000); }
From source file:IteratorTest.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(new IteratorTest()); f.pack(); f.setVisible(true);//from ww w .ja v a 2s . c o m }