Example usage for java.awt Dimension Dimension

List of usage examples for java.awt Dimension Dimension

Introduction

In this page you can find the example usage for java.awt Dimension Dimension.

Prototype

public Dimension(int width, int height) 

Source Link

Document

Constructs a Dimension and initializes it to the specified width and specified height.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(333, 666));
    add(panel);/*from   w w  w .j a  v a  2 s . co m*/
    pack();
    if (Toolkit.getDefaultToolkit().isFrameStateSupported(MAXIMIZED_BOTH)) {
        setExtendedState(MAXIMIZED_BOTH);
    } else {
        Dimension max = Toolkit.getDefaultToolkit().getScreenSize();
        max.height -= 20;
        setSize(max);
        setLocation(0, 20);
    }
    setVisible(true);
}

From source file:Main.java

public Main() {
    setPreferredSize(new Dimension(200, 250));
    console = new JTextArea(15, 15);

    vertical = new JScrollPane(console);
    vertical.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    add(vertical);//from w  ww  . j  a  v  a  2s .  c  om
}

From source file:Main.java

public Main() {
    tabbedPane = new JTabbedPane();
    tabbedPane.setPreferredSize(new Dimension(300, 200));
    getContentPane().add(tabbedPane);// www . ja  va 2s . c  o  m
    JTextField one = new JTextField("one");
    tabbedPane.add(one, "one");
    JTextField two = new JTextField("two");
    tabbedPane.add(two, "<html>T<br>i<br>t<br>t<br>l<br>e <br> 1 </html>");
    tabbedPane.setEnabledAt(2, false);

    tabbedPane.setTabPlacement(JTabbedPane.LEFT);
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    Rectangle r = new Rectangle(new Dimension(10, 10));

    g2.fill(r);//w  w  w  .  j  a  va  2  s .  c  om
    System.out.println(r.isEmpty());
}

From source file:Main.java

public Main() {
    super(new GridLayout(N, N));
    this.setPreferredSize(new Dimension(N * SIZE, N * SIZE));
    for (int i = 0; i < N * N; i++) {
        this.add(new ChessButton(i));
    }//  w w  w  .ja v a2s .co  m
}

From source file:Main.java

public Main() {
    setPreferredSize(new Dimension(2000, 2000));
}

From source file:Main.java

public Main() {
    tabbedPane.setPreferredSize(new Dimension(300, 200));
    getContentPane().add(tabbedPane);//  w  w w. j a  v  a2s  . c  om
    JPanel panel = new JPanel();
    tabbedPane.add(panel, "null");
    JTextField one = new JTextField("one");
    tabbedPane.add(one, "one");
    JTextField two = new JTextField("two");
    tabbedPane.add(two, "<html> Tittle  1 </html>");
    tabbedPane.setEnabledAt(2, false);
    tabbedPane.setTitleAt(2, "<html><font color=" + (tabbedPane.isEnabledAt(2) ? "black" : "red") + ">"
            + tabbedPane.getTitleAt(2) + "</font></html>");
    tabbedPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(200, 200));
    add(label, BorderLayout.CENTER);
    setUndecorated(true);/*from ww  w  . java2s.com*/
    getRootPane().setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.RED));
    setVisible(true);

}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    Rectangle r = new Rectangle(new Point(10, 10), new Dimension(40, 40));

    g2.fill(r);//from  w  w w. jav  a2 s. c  o  m

}

From source file:com.taunova.app.libview.components.ImageHelpers.java

public static Dimension getScaledDimension(Image image, int width) {
    double k = ((double) image.getHeight(null)) / image.getWidth(null);
    int height = (int) (width * k);

    return new Dimension(width, height);
}