Article View: borland.public.jbuilder.java.swing
Article #9838Re: How to add a 2D-GrafikComponent to a JPanel ???
From: Paul Furbacher [TeamB]
Date: Fri, 07 Jan 2000 00:00
Date: Fri, 07 Jan 2000 00:00
52 lines
1971 bytes
1971 bytes
Mirko Kรคmpf wrote: > > I tryed to create a 2D-BarChart - in its own JFrame it works fine. > But I need the Chart in a JPanel to add it to different frames. > > My ChartObjectClass extends the Component.class. > > To add the Chart to the JFrame I used: > frame.getContntPane().add(ChartObject); > > How can I show this ChartObject in a JPanel ? Assuming you have placed a JPanel called "myPanel" onto a JFrame in the JBuilder Designer, place a dummy control, perhaps another JPanel into "myPanel". Name it "dummyPanel" in the Property Inspector. Then, simply switch to the code editor and find the change the following line found somewhere in the jbInit() method: myPanel.add(dummyPanel, ...); to myPanel.add(myChartObject, ...); Please realize that "..." represent some kind of layout constraints. I don't write them here because they will be different for each type of layout (flow, border, pane, gridbag, etc.). The reason you place the dummy object onto the panel is to get JBuilder to write the layout constraints for you. This saves you a good bit of work. I use this technique frequently since I can never remember how write all the parameters for something like the GridBagLayout -- the layout which I use almost exclusively. Paul Furbacher (TeamB)
Technical Details
Message-ID:
<3876BAE1.5F4BB58@bilbo.bio.purdue.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<84r22i$d9m2@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,ee83c67b4a666407 X-Google-Attributes: gid111d45,public From: "Paul Furbacher [TeamB]" <pf@bilbo.bio.purdue.edu> Subject: Re: How to add a 2D-GrafikComponent to a JPanel ??? Date: 2000/01/07 Message-ID: <3876BAE1.5F4BB58@bilbo.bio.purdue.edu> X-Deja-AN: 569848409 Content-Transfer-Encoding: quoted-printable References: <84r22i$d9m2@bornews.borland.com> Content-Type: text/plain; charset=iso-8859-1 Organization: Reverse Alchemy, Inc. Mime-Version: 1.0 Reply-To: pf@bilbo.bio.purdue.edu Newsgroups: borland.public.jbuilder.java.swing