Example usage for javax.swing JPanel setPreferredSize

List of usage examples for javax.swing JPanel setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JPanel setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

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

public NormalDistributionDemo1(String s) {
    super(s);/* w ww.ja v a  2  s .  c om*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

From source file:MainClass.java

MainClass() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel p = new JPanel();
    p.setPreferredSize(new Dimension(300, 50));
    JScrollBar jsb;//from  ww w.  ja v a2s. co  m
    jsb = new JScrollBar(Adjustable.HORIZONTAL, 0, 1, 0, 100);
    jsb.setPreferredSize(new Dimension(200, 20));
    p.add(jsb);

    getContentPane().add(p);

    pack();
    setVisible(true);
}

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

public DefaultXYDatasetDemo1(String s) {
    super(s);/*from  ww w. j  av a2s  .  c  o m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

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

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 400);/*from  w ww  .  j a  va2 s. c o  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);
}

From source file:Main.java

public Main() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weighty = 0.0;/*w  ww  . j av a2s .c  o  m*/

    JPanel one = new JPanel();
    one.setPreferredSize(new Dimension(200, 200));
    one.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    JPanel two = new JPanel();
    two.setPreferredSize(new Dimension(200, 200));
    two.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    this.add(one, gbc);

    gbc.gridy = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;

    this.add(two, gbc);

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

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

public GridBandDemo1(String s) {
    super(s);//from w w  w  .  j a v  a 2 s .c o m
    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);/*from w w  w  . j  a v a2  s .  c  o  m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

public Function2DDemo1(String s) {
    super(s);//w  ww  .  j  a  v  a  2 s.  c om
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

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