List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToolBar toolBar = new JToolBar("Still draggable"); toolBar.setFloatable(false);/*from w w w. j a v a 2s.c o m*/ toolBar.setRollover(true); toolBar.add(new JButton("New")); toolBar.addSeparator(); toolBar.add(new JButton("Open")); frame.add(toolBar, "North"); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); JTextArea ta = new JTextArea(5, 32); ta.setText("That's one small step for man...\nOne giant leap for mankind."); ta.setLineWrap(true);/*from w w w . j ava 2 s. c o m*/ ta.setWrapStyleWord(true); f.getContentPane().add(ta); f.setSize(100, 100); f.setVisible(true); ((AbstractDocument) ta.getDocument()).dump(System.out); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); oneJSlider.setValue(27);// w ww .ja v a 2 s. c o m int value = oneJSlider.getValue(); System.out.println(value); oneJSlider.setPaintTicks(true); frame.add(oneJSlider, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Button"); frame.add(button);//from w ww .j a v a 2s. c o m frame.setAlwaysOnTop(true); frame.setSize(500, 500); frame.setLocation(500, 500); button.addActionListener(e -> { JOptionPane optionPane = new JOptionPane("Option Pane"); optionPane.showMessageDialog(frame, "Message!"); }); 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.setSize(600, 400);/*from ww w.j av a 2 s . c om*/ frame.setVisible(true); Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { System.out.println(frame.getLocation()); }, 0, 1000, TimeUnit.MILLISECONDS); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane newsTextPane = new JTextPane(); newsTextPane.setEditable(false);//from w w w . j a v a 2s . co m JScrollPane scrollPane = new JScrollPane(newsTextPane); frame.add(scrollPane); frame.setSize(300, 250); frame.setVisible(true); System.out.println("Height : " + scrollPane.getViewport().getSize().height + "\nWidth :" + scrollPane.getViewport().getSize().width); }
From source file:GraphicsDrawChars.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setSize(400, 400);/* w ww . jav a 2 s . com*/ f.add(new GraphicsDrawChars()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setSize(800, 600);//from w ww . j a v a2 s . com f.setLocationRelativeTo(null); JTabbedPane p = new JTabbedPane(); p.addTab("T1", new JPanel()); p.addTab("T2", new JPanel()); p.addTab("T3", new JPanel()); p.addChangeListener(e -> { System.out.println("" + p.getSelectedIndex()); // Index starts at 0, so Index 2 = Tab3 if (p.getSelectedIndex() == 2) { // do your stuff on Tab 3 } }); f.add(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); int newValue = 2; int newExtent = 10; int newMin = 0; int newMax = 10; oneJSlider.getModel().setRangeProperties(newValue, newExtent, newMin, newMax, true); int value = oneJSlider.getValue(); System.out.println(value);/*from ww w . jav a 2 s . c o m*/ oneJSlider.setPaintTicks(true); frame.add(oneJSlider, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); aWindow.getContentPane().setBackground(Color.PINK); aWindow.setVisible(true);//from w ww.j ava2 s. c om }