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.MultipleAxisDemo4.java

public MultipleAxisDemo4(String s) {
    super(s);/*from   w w  w  .  j  a  v  a2s.  c  o m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(600, 270));
    setContentPane(jpanel);
}

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

public BarChartDemo10(String s) {
    super(s);/*  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.HighLowChartDemo3.java

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

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

public OverlaidXYPlotDemo1(String s) {
    super(s);/*  w ww .j ava  2  s  .  co  m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

public XYBarChartDemo1(String s) {
    super(s);//from   w w  w.j a v  a2s.com
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}

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

public XYBarChartDemo5(String s) {
    super(s);/*from   www .  ja va2  s . c  o m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 300));
    setContentPane(jpanel);
}

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

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

From source file:Main.java

public Main() {
    JPanel parentPanel = new JPanel();
    parentPanel.setLayout(new BorderLayout(10, 10));

    JPanel childPanel1 = new JPanel();
    childPanel1.setBackground(Color.red);
    childPanel1.setPreferredSize(new Dimension(300, 40));

    JPanel childPanel2 = new JPanel();
    childPanel2.setBackground(Color.blue);
    childPanel2.setPreferredSize(new Dimension(800, 600));

    JButton myButton = new JButton("Add Component ");
    myButton.addActionListener(e -> {
        parentPanel.remove(childPanel1);
        parentPanel.add(childPanel2, BorderLayout.CENTER);
        parentPanel.revalidate();/*from   www.j ava2 s . c  om*/
        parentPanel.repaint();
        pack();
    });
    setLocation(10, 200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    parentPanel.add(childPanel1, BorderLayout.CENTER);
    parentPanel.add(myButton, BorderLayout.SOUTH);
    add(parentPanel);
    pack();
    setVisible(true);
}

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

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

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

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