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() {
    super(new BorderLayout());
    textArea.setEditable(false);/*from   ww w . j av  a  2  s.  co m*/

    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(400, 250));
    add(scrollPane, BorderLayout.CENTER);

    textArea.addMouseWheelListener(this);

    setPreferredSize(new Dimension(450, 350));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:Main.java

Main() {
    Object[][] data = { { "A", "B", "Snowboarding", new Integer(5) }, { "C", "D", "Pool", new Integer(10) } };
    Object[] columnNames = { "firstname", "lastname", "age" };
    final JTable table = new JTable(data, columnNames) {
        @Override/* w w w .  j  a  v a 2 s  .c  om*/
        public Dimension getPreferredScrollableViewportSize() {
            Dimension d = getPreferredSize();
            int n = getRowHeight();
            return new Dimension(d.width, (n * ROWS));
        }
    };
    JPanel jPanel = new JPanel();
    jPanel.setLayout(new GridLayout());
    JScrollPane sp = new JScrollPane(table);
    jPanel.add(sp);
    JDialog jdialog = new JDialog();
    jdialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    jdialog.setContentPane(jPanel);

    jdialog.pack();
    jdialog.setVisible(true);
}

From source file:Main.java

public Main() {
    setPreferredSize(new Dimension(320, 240));
    add(odometer);/*from  ww w . j av a2 s.co m*/
    JComboBox colorBox = new JComboBox(new String[] { "a", "b" });
    colorBox.addActionListener(e -> {
        tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), "my full new title");
    });
    this.add(colorBox);
    timer = new Timer(250, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            km += random.nextInt(100);
            odometer.setText(df.format(km));
        }
    });
    timer.start();
}

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

public NormalDistributionDemo1(String s) {
    super(s);//from w w  w .jav  a 2 s  . c o m
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

From source file:Main.java

@Override
public Dimension getMinimumSize() {
    return new Dimension(100, 100);
}

From source file:Main.java

@Override
public Dimension getPreferredSize() {
    return new Dimension(PREF_W, PREF_H);
}

From source file:Main.java

public Main() {
    ok.addActionListener(this);
    JPanel panel = new JPanel();
    panel.add(ok);// w  w w  . j a  v  a2s.c  o m

    getContentPane().add(panel, "South");
    addComponentListener(this);
    setVisible(true);
    setSize(new Dimension(200, 200));
    validate();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

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

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

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

public SymbolAxisDemo1(String s) {
    super(s);/*from  w ww.j  a  v a 2  s  .  c  o m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 300));
    setContentPane(jpanel);
}

From source file:Main.java

public Main() {
    this.setLayout(new FlowLayout());
    this.add(new JButton("test"));
    this.add(new JCheckBox("test"));
    this.add(new JRadioButton("test"));
    this.add(new JProgressBar(0, 100));
    JPanel panel = new JPanel() {
        @Override//from w ww .j  a v a 2  s  .com
        public Dimension getPreferredSize() {
            return new Dimension(400, 300);
        }

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.red);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    panel.add(new JLabel("Label"));
    add(panel);
    setSize(new Dimension(400, 300));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}