1. JPanel in agreement with dimension of pictures java-forums.org |
2. JPanel in agreement with dimension of pictures java-forums.orgclass Pseudo extends JPanel { BufferedImage image; Dimension size = new Dimension(); Pseudo(BufferedImage image) { this.image = image; size.setSize(image.getWidth(), image.getHeight()); // Option 1: use [i]setPreferredSize[/i] method. setPreferredSize(new Dimension(image.getWidth(), image.getHeight())); } protected void paintComponent(Graphics g) { super.paintComponent(g); // just in case g.drawImage(image,0,0,this); } /** Option 2: override [i]getPreferredSize[/i] method. */ public Dimension getPreferredSize() { return size; } } |
3. How to set a dimension to a JPanel forums.oracle.comCan anyone please give me an example of how can we set a fix dimension to a JPanel? Basically I have a GUI that has a Grid Layout and I have 3 panels for each of them and I don't want my panel to occupy the whole space of a grid......I want them to be only in the center of the ... |