java - Wrong packing of JFrame using JPanel in borderlayout -


I am writing a simple application in java which simulates some particles on the bunch of sheep (do not ask). For this, I want a window with a JPNL for graphics (which is a simple combo box, which has some standard resolution) and some other elements such as buttons, simulation etc. to start and stop.

My question: I am using the JeffreyPak method so that everything can be well packed using the borderline. But for some reasons JPNell is packed incorrectly, it seems that packing has ignored it, so the window has been changed to fit only the size of two buttons which I now have is wrong Am doing

This is a code so far (a newbie is a bit, so there is no comment on my crush;)):

  public class window {public sheep ; Public ButtonPanel Button Panel; PaintPanel Pentale Public; Public jeffrey frame; Public window (sheep's sheep, width, height of intensity) {this.sheepness = sheep; Frame = new jefframe ("sheep simulation"); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); //frame.setSize (width, height); Border Layout Frame Layout = New Border Layout (); JPN Background = New JPN (Frame Layouts); Background.setBorder (BorderFactory.createEmptyBorder (10, 10, 10, 10)); ButtonPanel = new buttonPanel (this); Background.add (Border Layout. South, Button Panel. Button Box); Pentpanel = New PaintPanel (this); Paint Panel.Sets (600, 600); Background.add (border layout.citter, paintpennel); . Add frame.getContentPane () (background); Frame.pack (); Frame.setResizable (wrong); Frame.setVisible (true); }} Public class PaintPanel JPanel {public window window; Public PaintPanel (Window Window) {this.window = window; } @ Override Public Love Paint Coment (Graphics G) {G. Setler (colored blue); G Filtrate (0, 0, 300, 200); }} Public Square ButtonPanel {Public Window Window; Public box button box; Public pocket startbutt; Public pocket reset button; Public ButtonPanel (Window Window) {this.window = window; Button box = new box (BoxLayout.X_AXIS); StartButton = New Payton ("Start"); StartButton.addActionListener (new start button listener ()); ButtonBox.add (startButton); Reset button = new pocket ("reset"); ResetButton.addActionListener (new reset button listener ()); ButtonBox.add (resetButton); }}  

Try:

  paintPanel. SetPreferredSize (600, 600);  

As Window.pack () gets the size of your subsystem and the size in the preferred sizes of JPanel from its favorite components (There is no one in your case).


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -