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 MyPanel() {
    this.setLayout(new GridLayout());
    this.setPreferredSize(new Dimension(W, H));
    int w = W / 2;
    int h = H / 2;
    int r = w / 5;
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics();
    g.setColor(Color.gray);//  w  w  w. j  a  va2s. c  o  m
    g.fillRect(0, 0, w, h);
    g.setColor(Color.blue);
    g.fillRect(w / 2 - r, h / 2 - r / 2, 2 * r, r);
    g.dispose();
    this.add(new JLabel(new ImageIcon(bi), JLabel.CENTER));
}

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

public YIntervalChartDemo1(String s) {
    super(s);//from w  w w  .  j  a  va2  s.c  om
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 300));
    setContentPane(jpanel);
}

From source file:Main.java

public Main() {
    addTabButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            add();//from   w w w  .j  a va  2  s.  com
        }
    });
    closeButtonSize = new Dimension(closeXIcon.getIconWidth() + 2, closeXIcon.getIconHeight() + 2);

    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.add(addTabButton, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.pack();
    frame.setMinimumSize(new Dimension(300, 300));
    frame.setVisible(true);

}

From source file:Main.java

ImagePanel(String name) {
    super(true);// w ww .  ja  v  a2s .c o m
    try {
        img = ImageIO.read(new File(name));
        this.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

public XYPolygonAnnotationDemo1(String s) {
    super(s);//  w w  w.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.XYStepRendererDemo1.java

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

From source file:SplashScreen.java

public SplashScreen(final BufferedImage img) {
    JPanel panel = new JPanel() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2d = (Graphics2D) g.create();

            g2d.drawImage(img, 0, 0, img.getWidth(), img.getHeight(), SplashScreen.this);
        }// w  w w . j a v  a2  s.  com
    };
    panel.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));

    Container content = getContentPane();
    content.setLayout(new BorderLayout());
    content.add(panel, BorderLayout.NORTH);
    content.add(label = new JLabel(), BorderLayout.CENTER);
    content.add(bar = new JProgressBar(), BorderLayout.SOUTH);
    pack();
    setLocationRelativeTo(null);
}

From source file:Center.java

License:asdf

public void addNotify() {
    super.addNotify();
    int maxWidth = 0;
    FontMetrics fm = getFontMetrics(getFont());
    for (int i = 0; i < text.length; i++) {
        maxWidth = Math.max(maxWidth, fm.stringWidth(text[i]));
    }/*from   w w w . j av  a 2s  .c o  m*/
    Insets inset = getInsets();
    dim = new Dimension(maxWidth + inset.left + inset.right,
            text.length * fm.getHeight() + inset.top + inset.bottom);
    setSize(dim);
}

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

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

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

public StackedXYAreaChartDemo1(String s) {
    super(s);/* w  w  w. j  av a2 s  .  co m*/
    JPanel jpanel = createDemoPanel();
    jpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(jpanel);
}