List of usage examples for javax.swing JFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:Main.java
public static void main(String[] args) { NumberFormat numberFormatGuFalse = NumberFormat.getNumberInstance(); numberFormatGuFalse.setGroupingUsed(false); JFormattedTextField jftFieldGuFalse = new JFormattedTextField(numberFormatGuFalse); NumberFormat numberFormatGuTrue = NumberFormat.getNumberInstance(); // numberFormatGuFalse.setGroupingUsed(true); // not necessary as is default JFormattedTextField jftFieldGuTrue = new JFormattedTextField(numberFormatGuTrue); JPanel panel = new JPanel(new BorderLayout()); panel.add(jftFieldGuFalse, BorderLayout.NORTH); panel.add(jftFieldGuTrue, BorderLayout.SOUTH); JFrame frame = new JFrame(); frame.getContentPane().add(panel);/* w w w .j av a2 s . co m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 300);// w w w. j av a2 s .com f.setLocationRelativeTo(null); f.setUndecorated(true); f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); JPanel panel = new JPanel(); panel.setBackground(java.awt.Color.white); f.setContentPane(panel); MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme()); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(f); f.setVisible(true); }
From source file:TreeRowHeight15.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(15);// w w w . j a va 2 s . co m JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.setUI(new SpacedTabbedPaneUI()); pane.addTab("One", new JPanel()); pane.addTab("Two", new JPanel()); pane.addTab("Threeeeeee", new JPanel()); pane.addTab("Four", new JPanel()); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(pane);/*from ww w.j a va 2 s. c o m*/ frame.setSize(500, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Points.java
public static void main(String[] args) { Points points = new Points(); JFrame frame = new JFrame("Points"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(points);//from w ww. ja va 2s . c o m frame.setSize(250, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("Hello"); label.setOpaque(true);//www . j a va 2 s . c om label.setBackground(Color.red); JPanel bottomPanel = new JPanel(new BorderLayout()); bottomPanel.add(label, BorderLayout.LINE_END); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(bottomPanel, BorderLayout.PAGE_END); mainPanel.setPreferredSize(new Dimension(400, 400)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Basic Shapes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.setSize(350, 250);// ww w . j av a 2 s .c om frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Text attributes"); frame.add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(620, 190);// w w w . j a v a2 s . c om frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeRowHeightCache.java
public static void main(String[] argv) { JTree tree = new JTree(); if (tree.getRowHeight() <= 0) { tree.setRowHeight(1);//from ww w . j av a 2 s .com } tree.setRowHeight(0); JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:ResizeRectangle.java
public static void main(String[] args) { JFrame frame = new JFrame("Resize Rectangle"); frame.add(new ResizeRectangle()); frame.setSize(300, 300);/*from ww w .ja v a 2 s.c o m*/ frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }