List of usage examples for javax.swing JFrame setDefaultCloseOperation
@BeanProperty(preferred = true, enumerationValues = { "WindowConstants.DO_NOTHING_ON_CLOSE", "WindowConstants.HIDE_ON_CLOSE", "WindowConstants.DISPOSE_ON_CLOSE", "WindowConstants.EXIT_ON_CLOSE" }, description = "The frame's default close operation.") public void setDefaultCloseOperation(int operation)
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 200);/*from w ww . j a v a2s.c o m*/ f.setVisible(true); FontMetrics metrics = f.getFontMetrics(f.getFont()); int widthX = metrics.charWidth((int) 'C'); System.out.println(widthX); }
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("."); int mode = fileChooser.getFileSelectionMode(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack();/* w w w . java2 s. c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 200);/*from w ww .j a va2 s.c om*/ f.setVisible(true); FontMetrics metrics = f.getFontMetrics(f.getFont()); int widthX = metrics.charWidth('X'); System.out.println(widthX); }
From source file:DrivedFont.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Pick to Change Background"); Font myFont = new Font("Serif", Font.ITALIC | Font.BOLD, 12); Font newFont = myFont.deriveFont(50F); button.setFont(newFont);/* w w w .jav a 2s . c o m*/ f.add(button, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("Pick to Change Background"); Color myBlack = new Color(0, 0, 0); // Color black // Color myWhite = new Color(255,255,255); // Color white // Color myGreen = new Color(0,200,0); // A shade of green button.setBackground(myBlack);/*from ww w . j av a 2 s . co m*/ f.add(button, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JColorChooser Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 200);//from ww w .j a v a2s .c om f.setVisible(true); FontMetrics metrics = f.getFontMetrics(f.getFont()); int widthX = metrics.bytesWidth(new byte[] { 66, 67, 68, 69 }, 1, 2); System.out.println(widthX); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Selecting CheckBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JCheckBox checkBox = new JCheckBox("Hi"); ButtonGroup bg = new ButtonGroup(); checkBox.getModel().setGroup(bg);/*from ww w. j av a2 s. c om*/ frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { String[] columns = { "Name", "Age" }; Object[][] content = { { "R", new Integer(24) }, { "A", new Integer(25) }, { "J", new Integer(30) }, { "A", new Integer(32) }, { "S", new Integer(27) } }; JTable table = new JTable(content, columns); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jPanel = new JPanel(new GridLayout(2, 0)); jPanel.setOpaque(true);/*from w w w . ja va 2 s . co m*/ table.setPreferredScrollableViewportSize(new Dimension(500, 70)); jPanel.add(new JScrollPane(table)); /* Add the panel to the JFrame */ frame.add(jPanel); /* Display the JFrame window */ frame.pack(); frame.setVisible(true); table.print(); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.PINK); JFrame frame = new JFrame(); frame.add(label);/*from w w w .j a va 2 s .co m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); 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("."); fileChooser.ensureFileIsVisible(new File(".")); frame.add(fileChooser, BorderLayout.CENTER); frame.pack();/* ww w .j a v a2 s. com*/ frame.setVisible(true); }