List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] args) { JPanel topPanel = new JPanel(); topPanel.setPreferredSize(new Dimension(200, 200)); topPanel.setBackground(Color.WHITE); JTextArea chatArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(chatArea); JPanel mainPanel = new JPanel(new BorderLayout(5, 5)); mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); mainPanel.add(topPanel, BorderLayout.CENTER); mainPanel.add(scrollPane, BorderLayout.SOUTH); chatArea.getDocument().addDocumentListener(new DocumentListener() { @Override/*from www. jav a 2s. c om*/ public void insertUpdate(DocumentEvent e) { updateLineCount(); } @Override public void removeUpdate(DocumentEvent e) { updateLineCount(); } @Override public void changedUpdate(DocumentEvent e) { updateLineCount(); } private void updateLineCount() { int lineCount = chatArea.getLineCount(); if (lineCount <= 4) { chatArea.setRows(lineCount); mainPanel.revalidate(); } } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(mainPanel); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new BorderLayout()); f.add(new TestPane()); f.pack(); f.setVisible(true);//from ww w .j a v a 2 s . co m }
From source file:Main.java
public static void main(String s[]) { JFrame frame1 = new JFrame("2D Images "); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add("Center", new Main()); frame1.pack(); frame1.setSize(new Dimension(300, 300)); frame1.setVisible(true);//from w w w. j a v a 2s. co m }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); final JButton activate = new JButton("Show"); frame.add(activate);//w w w .j ava 2 s. c o m frame.pack(); frame.setVisible(true); final Main glass = new Main(frame); frame.setGlassPane(glass); activate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { glass.setVisible(true); } }); }
From source file:JListBackground.java
public static void main(String[] args) { JFrame frame = new JFrame("Brute Force Algorithm"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addComponentsToPane(frame.getContentPane()); frame.pack(); frame.setSize(800, 600);/*from w ww.j a va 2s .c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new MyPanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//from www .j a va 2 s . c o m }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new PopupMenu()); frame.validate();//from w ww.j a va 2 s . c om 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); frame.setContentPane(new Main()); frame.validate();/*from w w w . j a va2s .com*/ 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); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.pack(); frame.setVisible(true);/*from w ww . ja v a 2s . co m*/ System.out.println("Frame size = " + frame.getSize()); }
From source file:Main.java
public static void main(String[] args) { JEditorPane htmlPane = new JEditorPane(); String description = "<html><body>Hello<table border=1>" + "<tr><td><img alt='Bad' src='http://www.java2s.com/style/download.png'/></tr></td></table></body></html>"; htmlPane.setContentType("text/html"); htmlPane.setText(description);// w ww. j a v a2 s.c o m JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JScrollPane(htmlPane)); frame.pack(); frame.setVisible(true); }