Wednesday 15 April 2015

java - GridBagLayout doesn't display JPanel component -


I need help because my JPNL component does not appear in other components. I used to work with that layout, so I have some experience in it but still there is a problem in that matter. Please do not reply to use other Layout Manager. Most of my project is based on gridbagh layout.

Then this is my original container:

  Public category Maeniera WorkAiria Extended {Private Static Last Long Serial VisseroneUID = 1 L; Private Gridbank Consultants GBC; Private People Logo; Public Menaria () {GBC = New Gridbag Consultants (); Logo = new logon (); JTextField tf = new JTextField (20); Gbc.gridx = 0; Gbc.gridy = 0; (Logo, GBC); Gbc.gridx = 0; Gbc.gridy = 1; (Tf, GBC); }}   

The layout manager is set to workarray class and to ensure that it has been corrected. JTextField I was only added to the tests and it is shown exactly opposite to the logo. Here is the logo code:

  Public class Logonnell extends JPNell {Private Buffett Image Image; Public PeoplePanel () {file image file = new file ("picture / logo.jpg"); Try {image = imageIO.read (imageFile); } Grip (IOE EXPRESS E) {System.err.println ("Blood Odcetu Logo"); E.printStackTrace (); }} @ Override Public Voice Paint Coment (Graphics G) {Graphics 2DG2D = (Graphics 2D); Screen screen = Screen.getInstance (); G2d.drawImage (image, screen .getScreenWidth () / 2-200, screen.getScreenHeight () / 2-100, this); }}   

Please help me I do not know what can be wrong here, I have not followed the method after trying again and adding, but not the result with.

override public dimension GetPreferredSize () in your LogoPanel class so that the gridout layout How to make your panel grow

And as the @nice cove tells, always call super.paintComponent (g) in your paintComponent () method as the first line .

No comments:

Post a Comment