List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); String f = fileChooser.getDescription(new File(".")); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//from w w w. ja va 2 s . c o m }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortUtilizationPanel.java
/** * Starting point for the demonstration application. * * @param args/*from w ww .j a v a 2 s . c om*/ * ignored. */ public static void main(String[] args) { JFrame demo = new JFrame("Port Utilization"); JPanel content = new PortUtilizationPanel(); demo.setContentPane(content); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Bring me to top after 3 seconds"); button.addActionListener(e -> triggerBringToFront(f, 3000)); f.getContentPane().add(button);//from w ww .j ava 2s .c o m f.pack(); f.setVisible(true); }
From source file:MenuExample.java
public static void main(String s[]) { MenuExample example = new MenuExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar);/*from www . j a v a 2s. c o m*/ frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); boolean b = fileChooser.getControlButtonsAreShown(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//from ww w. j a va2 s . c om }
From source file:Main.java
public static void main(String[] args) { JCheckBox a = new JCheckBox("A"); a.setSelected(true);/*from www . j a v a2 s. c om*/ a.setMnemonic(KeyEvent.VK_A); JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Car Features")); frame.add(a); frame.add(b); frame.add(c); frame.add(d); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JRadioButton button1 = new JRadioButton("Red"); JRadioButton button2 = new JRadioButton("Green"); button2.setMnemonic(KeyEvent.VK_G); JRadioButton button3 = new JRadioButton("Blue"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(button1);//from www . j a v a2 s . com colorButtonGroup.add(button2); colorButtonGroup.add(button3); button1.setSelected(true); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Color:")); frame.add(button1); frame.add(button2); frame.add(button3); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); ActionListener[] lis = fileChooser.getActionListeners(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);/* w ww.j a v a 2s .c om*/ }
From source file:KeymapExample.java
public static void main(String[] args) { JTextArea area = new JTextArea(6, 32); Keymap parent = area.getKeymap(); Keymap newmap = JTextComponent.addKeymap("KeymapExampleMap", parent); KeyStroke u = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK); Action actionU = new UpWord(); newmap.addActionForKeyStroke(u, actionU); Action actionList[] = area.getActions(); Hashtable lookup = new Hashtable(); for (int j = 0; j < actionList.length; j += 1) lookup.put(actionList[j].getValue(Action.NAME), actionList[j]); KeyStroke L = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK); Action actionL = (Action) lookup.get(DefaultEditorKit.selectLineAction); newmap.addActionForKeyStroke(L, actionL); KeyStroke W = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK); Action actionW = (Action) lookup.get(DefaultEditorKit.selectWordAction); newmap.addActionForKeyStroke(W, actionW); area.setKeymap(newmap);/*from w w w .ja v a2 s. c o m*/ JFrame f = new JFrame("KeymapExample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(area), BorderLayout.CENTER); area.setText("This is a test."); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame mainFrame = new JFrame(); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MyCanvas sadraGraphics = new MyCanvas(); sadraGraphics.setPreferredSize((new Dimension(640, 480))); mainFrame.getContentPane().add(sadraGraphics); mainFrame.pack(); mainFrame.setVisible(true);//from w w w. ja va 2 s . c om }