List of usage examples for javax.swing JFrame JFrame
public JFrame(String title) throws HeadlessException
Frame
with the specified title. From source file:Main.java
public static void main(String[] argv) throws Exception { final String title = "Testing: \u30CD"; JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JLabel label = new JLabel(title); label.setSize(200, 100);/* w ww . j a v a 2s .co m*/ frame.setContentPane(label); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JPanel panel2 = new JPanel(new BorderLayout()); panel2.add(new JButton("NORTH"), BorderLayout.NORTH); panel2.add(new JButton("CENTER")); panel.add(panel2);/*from ww w .ja va 2 s.c om*/ panel.add(new JButton("SOUTH"), BorderLayout.SOUTH); panel.add(new JButton("EAST"), BorderLayout.EAST); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("ProgressBars"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar dJProgressBar = new JProgressBar(JProgressBar.VERTICAL); dJProgressBar.setValue(100);/* ww w . ja va2s . co m*/ dJProgressBar.setBorderPainted(false); dJProgressBar.setString("Ack"); dJProgressBar.setStringPainted(true); frame.add(dJProgressBar, BorderLayout.WEST); frame.setSize(300, 200); frame.setVisible(true); }
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 w w w. ja va 2s. c o m frame.add(checkBox, BorderLayout.NORTH); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JTable Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rows[][] = { { "A", "Name 1", "38.94" }, { "B", "Name 2", "7.70" }, { "C", "Name 3", "112.65" } }; Object columns[] = { "Symbol", "Name", "Price" }; JTable table = new JTable(rows, columns); JScrollPane scrollPane = new JScrollPane(table); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200);/*w ww.ja va 2 s . com*/ f.setVisible(true); }
From source file:DualModal.java
public static void main(String args[]) { final JFrame frame1 = new JFrame("Left"); final JFrame frame2 = new JFrame("Right"); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button1 = new JButton("Left"); JButton button2 = new JButton("Right"); frame1.add(button1);//from w w w . j a va2s . c o m frame2.add(button2); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { JButton source = (JButton) e.getSource(); JOptionPane pane = new JOptionPane("New label", JOptionPane.QUESTION_MESSAGE); pane.setWantsInput(true); JDialog dialog = pane.createDialog(frame2, "Enter Text"); // dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL); dialog.setVisible(true); String text = (String) pane.getInputValue(); if (!JOptionPane.UNINITIALIZED_VALUE.equals(text) && text.trim().length() > 0) { source.setText(text); } } }; button1.addActionListener(listener); button2.addActionListener(listener); frame1.setBounds(100, 100, 200, 200); frame1.setVisible(true); frame2.setBounds(400, 100, 200, 200); frame2.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("BorderLayout Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container container = frame.getContentPane(); // Add a button to each of the five areas of the BorderLayout container.add(new JButton("North"), BorderLayout.NORTH); container.add(new JButton("South"), BorderLayout.SOUTH); container.add(new JButton("East"), BorderLayout.EAST); container.add(new JButton("West"), BorderLayout.WEST); container.add(new JButton("Center"), BorderLayout.CENTER); frame.pack();//from w w w. j a v a 2 s . co m frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Popup JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new BasicArrowButton(BasicArrowButton.NORTH), BorderLayout.NORTH); frame.add(new BasicArrowButton(BasicArrowButton.EAST), BorderLayout.EAST); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH), BorderLayout.SOUTH); frame.add(new BasicArrowButton(BasicArrowButton.WEST), BorderLayout.WEST); frame.setSize(300, 200);//w w w .ja v a 2 s. com frame.setVisible(true); }
From source file:ButtonFocus.java
public static void main(String args[]) { JFrame frame = new JFrame("Action Sample"); JButton focusButton = new JButton("Focused"); JButton notFocusButton = new JButton("Not Focused"); Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout()); contentPane.add(focusButton);//from ww w .j av a 2 s . co m contentPane.add(notFocusButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JEditorPane Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane editor = new JEditorPane("text/html", "<H3>Help</H3><center>www.java2s.com</center><li>One<li><i>Two</i><li><u>Three</u>"); editor.setEditable(false);// w ww .j av a 2s .c om JScrollPane scrollPane = new JScrollPane(editor); f.add(scrollPane, BorderLayout.CENTER); f.setSize(300, 200); f.setVisible(true); }