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) { JFrame frame = new JFrame("EditorPaneScroll"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.pack(); frame.setLocationByPlatform(true);// w w w.j a v a 2 s. c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { int MAX_CELLS = 30; DefaultListModel<String> listModel = new DefaultListModel<>(); JList<String> myList = new JList<>(listModel); myList.setVisibleRowCount(8);/*from ww w . ja v a 2 s .c om*/ for (int i = 0; i < MAX_CELLS; i++) { listModel.addElement("label " + i); } JTabbedPane jTabbedPane = new JTabbedPane(); jTabbedPane.add("Test", new JScrollPane(myList)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(jTabbedPane); frame.pack(); frame.setVisible(true); }
From source file:InvokeAndWaitExample.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setDefaultCloseOperation(1);/*from ww w . jav a2s . c o m*/ f.add(new InvokeAndWaitExample()); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override// w w w .j a v a 2s . c o m public void run() { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new LoadImage()); f.pack(); f.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); String HTML = "<html>" + "<head>" + "<style type=text/css>" + "body {" + " background-image: http://www.java2s.com/style/download.png;" + " background-repeat:no-repeat;" + " background-position:left top;" + " background-attachment: scroll;" + " color: #BBBBBB;" + "}" + "</style>" + "</head>" + "<body>" + "<h1>Heading 1</h1>"; String PARAGRAPH = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean eu nulla urna. Donec sit amet risus nisl, a porta enim. Quisque luctus, ligula eu scelerisque gravida, tellus quam vestibulum urna, ut aliquet sapien purus sed erat. Pellentesque consequat vehicula magna, eu aliquam magna interdum porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed sollicitudin sapien non leo tempus lobortis. Morbi semper auctor ipsum, a semper quam elementum a. Aliquam eget sem metus."; gui.setPreferredSize(new Dimension(400, 100)); StringBuilder sb = new StringBuilder(); sb.append(HTML);//from w ww . j a v a2 s.co m for (int ii = 0; ii < 10; ii++) { sb.append("<h2>Header 2</h2>"); sb.append(PARAGRAPH); } JEditorPane jep = new JEditorPane(); jep.setOpaque(false); jep.setContentType("text/html"); jep.setText(sb.toString()); JScrollPane jsp = new JScrollPane(jep) { BufferedImage bg = new BufferedImage(350, 50, BufferedImage.TYPE_INT_RGB); @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(bg, 0, 0, this); } }; jsp.getViewport().setOpaque(false); gui.add(jsp); Main bih = new Main(); JFrame f = new JFrame(); f.add(gui); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JComboBox combo = new JComboBox(); combo.setEditable(true);// w w w. j a v a 2 s. com for (int i = 0; i < 10; i++) { combo.addItem(i); } JLabel tip = new JLabel(); tip.setText("Outside combobox"); JPanel panel = new JPanel(); panel.add(combo); panel.add(tip); panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { tip.setText("Outside combobox"); } @Override public void mouseExited(MouseEvent e) { Component c = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); tip.setText(c != null && SwingUtilities.isDescendingFrom(c, combo) ? "Inside combo box" : "Outside combobox"); } }); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//ww w .j a v a 2s . co 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 MyContentPane()); frame.pack(); frame.setLocationByPlatform(true);// w w w. j a va 2s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(new BorderLayout()); final JTree tree = new JTree(); panel.add(new JScrollPane(tree)); JButton btn = new JButton("Press Me"); btn.addActionListener(et -> {//from www.j a v a 2 s.c om for (Enumeration e = ((TreeNode) tree.getModel().getRoot()).children(); e.hasMoreElements();) { TreeNode tn = (TreeNode) e.nextElement(); tree.expandPath(new TreePath(((DefaultTreeModel) tree.getModel()).getPathToRoot(tn))); } }); panel.add(btn, BorderLayout.SOUTH); JFrame frame = new JFrame(""); frame.getContentPane().add(panel); frame.setSize(300, 300); frame.setLocation(100, 100); frame.pack(); frame.show(); }
From source file:InvokeLaterExample.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setDefaultCloseOperation(1);// ww w . j a v a 2 s .co m f.add(new InvokeLaterExample()); f.pack(); f.setVisible(true); }