List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:SimpleBorder.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Aaaaaaaaaaa"); button.setBorder(new SimpleBorder()); frame.add(button);//from ww w . ja v a 2s . c om frame.pack(); frame.setVisible(true); }
From source file:SimpleFTF.java
public static void main(String argv[]) { if (argv.length > 0) { // change to command-line locale if (argv[0].equalsIgnoreCase("canada")) java.util.Locale.setDefault(java.util.Locale.CANADA); if (argv[0].equalsIgnoreCase("canada_french")) java.util.Locale.setDefault(java.util.Locale.CANADA_FRENCH); if (argv[0].equalsIgnoreCase("china")) java.util.Locale.setDefault(java.util.Locale.CHINA); if (argv[0].equalsIgnoreCase("france")) java.util.Locale.setDefault(java.util.Locale.FRANCE); if (argv[0].equalsIgnoreCase("germany")) java.util.Locale.setDefault(java.util.Locale.GERMANY); if (argv[0].equalsIgnoreCase("italy")) java.util.Locale.setDefault(java.util.Locale.ITALY); if (argv[0].equalsIgnoreCase("japan")) java.util.Locale.setDefault(java.util.Locale.JAPAN); if (argv[0].equalsIgnoreCase("korea")) java.util.Locale.setDefault(java.util.Locale.KOREA); if (argv[0].equalsIgnoreCase("prc")) java.util.Locale.setDefault(java.util.Locale.PRC); if (argv[0].equalsIgnoreCase("taiwan")) java.util.Locale.setDefault(java.util.Locale.TAIWAN); if (argv[0].equalsIgnoreCase("uk")) java.util.Locale.setDefault(java.util.Locale.UK); if (argv[0].equalsIgnoreCase("us")) java.util.Locale.setDefault(java.util.Locale.US); }//w w w .ja v a 2 s . c o m String localeString = java.util.Locale.getDefault().getDisplayName(); JFrame f = new JFrame("SimpleFTF " + localeString); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(new SimpleFTF()); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { int cp = 0;/*w ww. ja v a2 s. c om*/ StyledDocument doc; JTextPane jta = new JTextPane(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); doc = jta.getStyledDocument(); JScrollPane jsp = new JScrollPane(jta); jsp.setPreferredSize(new Dimension(400, 400)); String[] fnt = ge.getAvailableFontFamilyNames(); MutableAttributeSet mas = jta.getInputAttributes(); for (int i = 0; i < fnt.length; i++) { StyleConstants.setBold(mas, false); StyleConstants.setItalic(mas, false); StyleConstants.setFontFamily(mas, fnt[i]); StyleConstants.setFontSize(mas, 16); doc.insertString(cp, fnt[i] + "\n", mas); StyleConstants.setBold(mas, true); doc.insertString(cp, fnt[i] + "bold \n", mas); StyleConstants.setItalic(mas, true); doc.insertString(cp, fnt[i] + "bold and italic\n", mas); StyleConstants.setBold(mas, false); doc.insertString(cp, fnt[i] + "italic\n", mas); } JFrame frm = new JFrame(); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setLayout(new BorderLayout()); frm.add(jsp, BorderLayout.CENTER); frm.setLocation(100, 100); frm.pack(); frm.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); int treeSelectedRows[] = { 3, 1 }; tree.setSelectionRows(treeSelectedRows); TreeSelectionListener treeSelectionListener = new TreeSelectionListener() { @Override//from w w w. j a v a 2s. com public void valueChanged(TreeSelectionEvent treeSelectionEvent) { JTree treeSource = (JTree) treeSelectionEvent.getSource(); System.out.println("Min: " + treeSource.getMinSelectionRow()); System.out.println("Max: " + treeSource.getMaxSelectionRow()); System.out.println("Lead: " + treeSource.getLeadSelectionRow()); System.out.println("Row: " + treeSource.getSelectionRows()[0]); } }; tree.addTreeSelectionListener(treeSelectionListener); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setPreferredSize(new Dimension(380, 320)); frame.setLocation(150, 150); frame.pack(); frame.setVisible(true); }
From source file:brainflow.core.ImageBrowser.java
public static void main(String[] args) { com.jidesoft.utils.Lm.verifyLicense("UIN", "BrainFlow", "S5XiLlHH0VReaWDo84sDmzPxpMJvjP3"); //com.jidesoft.plaf.LookAndFeelFactory.installDefaultLookAndFeel(); //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2007_STYLE); URL url1 = BF.getDataURL("data/icbm452_atlas_probability_insula.hdr"); URL url2 = BF.getDataURL("data/icbm452_atlas_probability_white.hdr"); try {/* w ww.j av a 2 s .c om*/ UIManager.setLookAndFeel(new NimbusLookAndFeel()); IImageSource dsource1 = BrainIO.loadDataSource(VFS.getManager().resolveFile(url1.toURI().toString())); IImageSource dsource2 = BrainIO.loadDataSource(VFS.getManager().resolveFile(url2.toURI().toString())); ImageBrowser browser = new ImageBrowser(Arrays.asList(dsource1, dsource2)); JFrame frame = new JFrame(); frame.add(browser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } //List<IImageDataSource> dsource2 = BrainIO.loadDataSources(new File("/home/brad/data/sub30072/anat/mprage_anonymized.nii.gz"), // new File("/home/brad/data/sub54329/anat/mprage_anonymized.nii.gz")); // List<List<IImageDataSource>> sourceList = Arrays.asList(dsource1, dsource2); // ImageBrowser browser = new ImageBrowser(sourceList); // JFrame frame = new JFrame(); // frame.add(browser, BorderLayout.CENTER); // frame.pack(); // frame.setVisible(true); }
From source file:BorderLayoutPane.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w .jav a 2 s. c o m } }); f.setContentPane(new BorderLayoutPane()); f.pack(); f.setVisible(true); }
From source file:SwingListExample.java
public static void main(String s[]) { JFrame frame = new JFrame("List Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new SwingListExample()); frame.pack(); frame.setVisible(true);/*from ww w . java2 s . c om*/ }
From source file:LabelForComboBox.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w . j av a 2 s.co m } }); f.getContentPane().add(new LabelForComboBox()); f.pack(); f.setSize(new Dimension(300, 200)); f.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setPreferredSize(new Dimension(300, 280)); Main ch = new Main(); ch.setDate(new Date()); frame.getContentPane().add(ch);// ww w . ja va 2 s . c o m frame.setUndecorated(true); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new GridLayout(N, N)); for (int i = 0; i < N * N; i++) { frame.add(new CirclePanel()); }/*w ww .ja v a2 s . c om*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }