Article View: borland.public.jbuilder.java.swing
Article #9900Re: Simple Question
From: Trey Campbell campbell
Date: Sat, 01 Jan 2000 00:00
Date: Sat, 01 Jan 2000 00:00
61 lines
2952 bytes
2952 bytes
Jeff,
It looks like you're adding the buttons to the TNSwapToolPanel itself
instead of its content pane. In setInsertButton(), replace the line
"this.add(button, new XYConstraints(8, 12, 67, -1));" with
"this.getContentPane().add(button, new XYConstraints(8, 12, 67, -1));" and
you should start seeing buttons. Another observation: if you're going to use
"this," you don't need to pass in a reference to the panel.
Regards,
Trey
"Jeff Marendo" <marendoj@commos.com> wrote in message
news:83tdra$t506@forums.borland.com...
> Hello,
>
> I'm looking at my code right now, and I think I'm losing my mind. I
created
> a class in JBuilder3 that extends from JPanel. My class has three
JButtons
> that I'm trying to add to it. These buttons aren't special, really. I
just
> want to add them to my panel, but what I'm trying to is to have a 'set'
> function for each button that is called from jbInit( ). This way I don't
> have a ton of extraneous lines of code there. The problem is that my
> buttons are not being added to my panel. Here is code for one of my
> buttons:
>
> public class TNSwapToolPanel extends JPanel {
> XYLayout tnSwapToolPanelLayout = new XYLayout();
> JButton btn_insert = new JButton();
> ...
>
> private void jbInit() throws Exception {
> this.setLayout(tnSwapToolPanelLayout);
> this.setBackground(Color.white);
> setInsertButton(btn_insert, this);
> ...
>
> private void setInsertButton(JButton button, TNSwapToolPanel panel) {
> button.setText("Insert");
> button.setFont(new java.awt.Font("Dialog", Font.BOLD, 14));
> button.setBorder(BorderFactory.createLineBorder(Color.black));
> button.setBackground(Color.blue);
> button.setForeground(Color.white);
> button.setMnemonic('i');
> // button.addMouseListener(cursDet);
> this.add(button, new XYConstraints(8, 12, 67, -1));
> }
>
> Maybe I'm going about this the wrong way, but it seems like it should
work.
> I can clearly see that the buttons aren't being added to the panel when I
go
> to the 'Design' tab in JBuilder3. Please steer me in the right direction
if
> anyone can see what I'm doing wrong. Thanks in advance.
>
> Jeff
>
>
Technical Details
Message-ID:
<8qtb4.1249$lu1.31777@typhoon.midsouth.rr.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<83tdra$t506@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,48efee8c83d81be2 X-Google-Attributes: gid111d45,public From: "Trey Campbell" <<no spam>campbell@midsouth.rr.com> Subject: Re: Simple Question Date: 2000/01/01 Message-ID: <8qtb4.1249$lu1.31777@typhoon.midsouth.rr.com> X-Deja-AN: 567200667 References: <83tdra$t506@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Complaints-To: abuse@rr.com X-Trace: typhoon.midsouth.rr.com 946758404 24.24.100.179 (Sat, 01 Jan 2000 14:26:44 CST) Organization: RoadRunner - Midsouth X-MSMail-Priority: Normal NNTP-Posting-Date: Sat, 01 Jan 2000 14:26:44 CST Newsgroups: borland.public.jbuilder.java.swing