List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setMnemonic((int) 'P'); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);//from w w w . ja va2 s. c om f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setFocusPainted(false);/*from ww w. j a v a 2 s. com*/ JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> rowOne = new Vector<String>(); rowOne.addElement("Row1-Column1"); rowOne.addElement("Row1-Column2"); rowOne.addElement("Row1-Column3"); Vector<String> rowTwo = new Vector<String>(); rowTwo.addElement("Row2-Column1"); rowTwo.addElement("Row2-Column2"); rowTwo.addElement("Row2-Column3"); Vector<Vector> rowData = new Vector<Vector>(); rowData.addElement(rowOne);// ww w . j a v a 2s . c o m rowData.addElement(rowTwo); Vector<String> columnNames = new Vector<String>(); columnNames.addElement("Column One"); columnNames.addElement("Column Two"); columnNames.addElement("Column Three"); JTable table = new JTable(rowData, columnNames); table.setValueAt("aa", 0, 0); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); final JSlider slider = new JSlider(0, 150, 0); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); slider.setPreferredSize(new Dimension(150, 30)); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { int value = slider.getValue(); if (value == 0) { System.out.println("0"); } else if (value > 0 && value <= 30) { System.out.println("value > 0 && value <= 30"); } else if (value > 30 && value < 80) { System.out.println("value > 30 && value < 80"); } else { System.out.println("max"); }//ww w. ja va 2s . c o m } }); f.add(slider); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); System.out.println(jb.getRolloverIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w w w . java 2s . c o m*/ f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); System.out.println(jb.getSelectedIcon()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);//ww w. ja va 2s. c o m f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); Container container = frame.getContentPane(); GridBagLayout gbl = new GridBagLayout(); container.setLayout(gbl);//from w w w . ja v a 2s.c o m GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; JButton component = new JButton("a"); gbl.setConstraints(component, gbc); container.add(component); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("JLabel Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 12)); label.setForeground(Color.GRAY); frame.add(label);/*from w w w.j av a2s .co m*/ 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); JDialog dialog = new JDialog(frame, false); dialog.setSize(200, 50);// www.ja v a 2 s . c o m frame.addComponentListener(new ComponentAdapter() { Point lastLocation; @Override public void componentMoved(ComponentEvent e) { if (lastLocation == null && frame.isVisible()) { lastLocation = frame.getLocation(); } else { Point newLocation = frame.getLocation(); int dx = newLocation.x - lastLocation.x; int dy = newLocation.y - lastLocation.y; dialog.setLocation(dialog.getX() + dx, dialog.getY() + dy); lastLocation = newLocation; } } }); frame.setSize(400, 200); frame.setVisible(true); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setDisplayedMnemonicIndex(1);/* w w w. ja va 2s. c o m*/ JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }