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:org.jfree.chart.demo.WindChartDemo1.java

public WindChartDemo1(String s) {
    super(s);
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

From source file:org.jfree.chart.demo.RingChartDemo1.java

public RingChartDemo1(String s) {
    super(s);
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

From source file:Main.java

/** Constructs a JToggleButton with an icon from the given file id. */
public static JToggleButton makeToggleButton(final Object owner, final String id, final String altText,
        final int wpad, final int hpad) {
    final URL url = owner.getClass().getResource(id);
    ImageIcon icon = null;/*www  .  ja v a  2  s . c  o  m*/
    if (url != null)
        icon = new ImageIcon(url);
    JToggleButton button;
    if (icon == null)
        button = new JToggleButton(altText);
    else {
        button = new JToggleButton(icon);
        button.setPreferredSize(new Dimension(icon.getIconWidth() + wpad, icon.getIconHeight() + hpad));
    }
    return button;
}

From source file:JBenchFrame.java

public JBenchFrame() {
    this.getContentPane().setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    fillButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ListData ld = new ListData();
            long tmStart = System.currentTimeMillis();
            list1.setModel(ld);/*  w w w .java2  s. c  o m*/
            list1.repaint();
            long tmEnd = System.currentTimeMillis();
            System.out.println(tmEnd - tmStart);

        }
    });
    fillButton.setText("Fill");
    this.getContentPane().add(new JScrollPane(list1), BorderLayout.CENTER);
    this.getContentPane().add(fillButton, BorderLayout.SOUTH);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setVisible(true);
}

From source file:Main.java

private static void doSetSizeInEDT(final Component component, final int width, final int height) {
    component.setMaximumSize(new Dimension(width, height));
    component.setMinimumSize(new Dimension(width, height));
    component.setPreferredSize(new Dimension(width, height));
    component.setSize(new Dimension(width, height));
}

From source file:Main.java

public FieldComponent() {
    this.time = 1200;
    this.setPreferredSize(new Dimension(width, height));
}

From source file:Main.java

public Main() {
    mainPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    mainPanel.setLayout(null);/*from w  w  w  .j  ava  2  s . com*/

    MyMouseAdapter myMouseAdapter = new MyMouseAdapter();
    for (int i = 0; i < LABEL_STRINGS.length; i++) {
        JLabel label = new JLabel(LABEL_STRINGS[i], SwingConstants.CENTER);
        label.setSize(new Dimension(LBL_WIDTH, LBL_HEIGHT));
        label.setOpaque(true);
        Random random = new Random();
        label.setLocation(random.nextInt(WIDTH - LBL_WIDTH), random.nextInt(HEIGHT - LBL_HEIGHT));
        label.setBackground(
                new Color(150 + random.nextInt(105), 150 + random.nextInt(105), 150 + random.nextInt(105)));
        label.addMouseListener(myMouseAdapter);
        label.addMouseMotionListener(myMouseAdapter);

        mainPanel.add(label);
    }
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(200, 200);/*from   w w  w  . ja v a 2  s .  com*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    DocumentFilter filter = new UppercaseDocumentFilter();

    JTextField firstName = new JTextField();
    firstName.setPreferredSize(new Dimension(100, 20));
    ((AbstractDocument) firstName.getDocument()).setDocumentFilter(filter);

    JTextField lastName = new JTextField();
    lastName.setPreferredSize(new Dimension(100, 20));
    ((AbstractDocument) lastName.getDocument()).setDocumentFilter(filter);

    add(firstName);
    add(lastName);
}

From source file:ImageTest.java

public ImagePanel(Image img) {
    this.img = img;
    Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
    setPreferredSize(size);//from  w  w  w .  j  ava 2s .c o  m
    setMinimumSize(size);
    setMaximumSize(size);
    setSize(size);
    setLayout(null);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 400);//w w w  .  j  a  v  a 2 s . co m
    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setDividerLocation(200);
    add(split);

    JPanel panel1 = new JPanel();
    panel1.setLayout(new BorderLayout());
    panel1.add(new JLabel("top panel"), BorderLayout.NORTH);

    JPanel myDrawPanel = new JPanel();
    myDrawPanel.setPreferredSize(new Dimension(100, 100));
    myDrawPanel.add(new JLabel("draw panel here!"));
    panel1.add(new JScrollPane(myDrawPanel), BorderLayout.CENTER);

    split.setTopComponent(panel1);

    JPanel panel2 = new JPanel();
    panel2.add(new JLabel("bottom panel"));
    split.setBottomComponent(panel2);
    setVisible(true);
}