Example usage for javax.swing JFrame getHeight

List of usage examples for javax.swing JFrame getHeight

Introduction

In this page you can find the example usage for javax.swing JFrame getHeight.

Prototype

public int getHeight() 

Source Link

Document

Returns the current height of this component.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    final JTree tree = new JTree(getTreeModel());
    tree.setCellRenderer(new MyTreeCellRenderer());
    HyperlinkMouseListener listener = new HyperlinkMouseListener(tree);
    tree.addMouseListener(listener);/* w ww  . j av a2  s.  c o m*/
    tree.addMouseMotionListener(listener);
    JFrame f = new JFrame(Main.class.getSimpleName());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new JScrollPane(tree), BorderLayout.CENTER);
    f.pack();
    f.setSize(f.getWidth() + 100, f.getHeight() + 100);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame(Main.class.getSimpleName());
    DefaultTreeModel model = getTreeModel();
    JTree tree1 = new JTree(model);
    JTree tree2 = new JTree(model);
    frame.add(new JScrollPane(tree1), BorderLayout.WEST);
    frame.add(new JScrollPane(tree2), BorderLayout.EAST);
    frame.pack();/*from w  ww . ja  va  2 s .  co m*/
    frame.setSize(frame.getWidth() + 50, frame.getHeight() + 140);
    frame.setVisible(true);
    Timer t = new Timer(2000, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
            root.add(new DefaultMutableTreeNode("A new node"));
            model.nodesWereInserted(root, new int[] { root.getChildCount() - 1 });
            tree1.expandRow(0);
            tree2.expandRow(0);
            frame.revalidate();
        }
    });
    t.start();
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Line Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border thinBorder = LineBorder.createBlackLineBorder();

    JButton thinButton = new JButton("1 Pixel");
    thinButton.setBorder(thinBorder);/*from w  ww. j  av  a 2  s  .c o m*/

    Container contentPane = frame.getContentPane();
    contentPane.add(thinButton, BorderLayout.NORTH);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Line Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border thickBorder = new LineBorder(Color.WHITE, 12);

    JButton thickButton = new JButton("12 Pixel");
    thickButton.setBorder(thickBorder);//from   w  ww . ja  v  a  2s.  c o  m

    Container contentPane = frame.getContentPane();
    contentPane.add(thickButton, BorderLayout.NORTH);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
    statusBar.setBorder(new CompoundBorder(new LineBorder(Color.DARK_GRAY), new EmptyBorder(4, 4, 4, 4)));
    final JLabel status = new JLabel();
    statusBar.add(status);/*  w  w w .  j a  v a 2 s  . c om*/

    JLabel content = new JLabel("Content in the middle");
    content.setHorizontalAlignment(JLabel.CENTER);

    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(content);
    frame.add(statusBar, BorderLayout.SOUTH);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            status.setText(frame.getWidth() + "x" + frame.getHeight());
        }
    });

    frame.setBounds(20, 20, 200, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Line Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border roundedBorder = new LineBorder(Color.BLACK, 12, true);

    JButton roundedButton = new JButton("Rounded 12 Pixel");
    roundedButton.setBorder(roundedBorder);

    Container contentPane = frame.getContentPane();
    contentPane.add(roundedButton, BorderLayout.SOUTH);
    frame.pack();//from  w w w  .j a  v  a  2  s  .c  om
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JPanel panel = (JPanel) frame.getContentPane();
    panel.setLayout(new BorderLayout());
    JTextField field = new JTextField(20);
    Main spinner = new Main();

    panel.add(field, "Center");
    panel.add(spinner, "East");

    Dimension dim = frame.getToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getWidth() / 2, dim.height / 2 - frame.getHeight() / 2);
    frame.pack();/* www .jav  a 2s  .c  o m*/
    frame.show();
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Empty Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border emptyBorder = BorderFactory.createEmptyBorder(20, 20, 0, 0);
    JButton emptyButton = new JButton("With Empty");
    emptyButton.setBorder(emptyBorder);/* w w w  . ja  va2  s.c o m*/
    JButton nonemptyButton = new JButton("Without Empty");
    Container contentPane = frame.getContentPane();
    contentPane.add(emptyButton, BorderLayout.NORTH);
    contentPane.add(nonemptyButton, BorderLayout.SOUTH);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
}

From source file:AnEmptyBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Empty Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border emptyBorder = BorderFactory.createEmptyBorder(20, 20, 0, 0);
    JButton emptyButton = new JButton("With Empty");
    emptyButton.setBorder(emptyBorder);//from  w  w w .  j av a 2s  .  c  om

    JButton nonemptyButton = new JButton("Without Empty");

    Container contentPane = frame.getContentPane();
    contentPane.add(emptyButton, BorderLayout.NORTH);
    contentPane.add(nonemptyButton, BorderLayout.SOUTH);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override/* w w w.j  ava 2 s  .com*/
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }

    });
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
    int x = (int) rect.getMaxX() - f.getWidth();
    int y = (int) rect.getMaxY() - f.getHeight();
    f.setLocation(x, y);
    f.setVisible(true);
}