Board index » jbuilder » added component not visible

added component not visible


2003-10-05 12:38:19 PM
jbuilder7
I have a contentPane to which I add an extended JPanels. This object
doesn't appear on the screen when I run the application.
// Definitions
JPanel cP; // contentPane
jKeyPad kPad = new jKeyPad(); // Create instance of Panel
// Init Section
cP = (JPanel) this.getContentPane(); //
cP.add(kPad);
This compiles & runs OK .. I just don't get to see my keypad anywhere,
where did it go & how to I put it where I want ?
Thanx
 
 

Re:added component not visible

On 10/5/2003 at 12:38:19 AM, James Christie wrote:
Quote
I have a contentPane to which I add an extended JPanels. This
object doesn't appear on the screen when I run the application.

// Definitions
JPanel cP; // contentPane
jKeyPad kPad = new jKeyPad(); // Create instance of Panel

// Init Section
cP = (JPanel) this.getContentPane(); //
cP.add(kPad);

This compiles & runs OK .. I just don't get to see my keypad anywhere,
where did it go & how to I put it where I want ?
There are a number of things that could be going wrong. Perhaps the
most common is for the size of the component to be zero. You can check
this by pressing Ctrl+Shift+F1, which will cause the top-level window
to do a list() on itself. If the size is zero, it may be a problem
with the layout manager, or possibly because the component is not
reporting a reasonable preferred size.
Another possibility is that the component is not painting itself
properly. One way to check this is to set the background color for
your component to an obvious color such as red. That way, if the
component is showing, you will be able to see it.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html
 

Re:added component not visible

Hi John,
Thanks for your reply.
It seems to be something with the layout manager .... at least I set the
layout to null and things started happening.
Coming from C++ Builder the layout manager has me really confused !
I'll get it sorted eventually however.
James
"John McGrath [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
On 10/5/2003 at 12:38:19 AM, James Christie wrote:

>I have a contentPane to which I add an extended JPanels. This
>object doesn't appear on the screen when I run the application.
>
>// Definitions
>JPanel cP; // contentPane
>jKeyPad kPad = new jKeyPad(); // Create instance of Panel
>
>// Init Section
>cP = (JPanel) this.getContentPane(); //
>cP.add(kPad);
>


>This compiles & runs OK .. I just don't get to see my keypad anywhere,
>where did it go & how to I put it where I want ?

There are a number of things that could be going wrong. Perhaps the
most common is for the size of the component to be zero. You can check
this by pressing Ctrl+Shift+F1, which will cause the top-level window
to do a list() on itself. If the size is zero, it may be a problem
with the layout manager, or possibly because the component is not
reporting a reasonable preferred size.

Another possibility is that the component is not painting itself
properly. One way to check this is to set the background color for
your component to an obvious color such as red. That way, if the
component is showing, you will be able to see it.

--
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html
 

{smallsort}

Re:added component not visible

On 10/6/2003 at 9:06:15 PM, James Christie wrote:
Quote
It seems to be something with the layout manager .... at least I
set the layout to null and things started happening.
Coming from C++ Builder the layout manager has me really confused
! I'll get it sorted eventually however.
If the layout manager is set to null, then you will need to explicitly
set the bounds (location and size) of the component. By default, the
location and size will be [0,0].
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
www.JPMcGrath.net/newsgroups/e-mail.html