Re: How do I add my own panel to my desktop application?
Ilan <ilan.tal <at> gmail.com>
2008-01-01 07:32:48 GMT
Thanks Wade,
I used the method to drag DrawGraphics into the form and it works great.
However there is now a new problem, which also must have a simple solution,
but I can't find it.
In the previous method under Eclipse when I changed the initialization I had
a jDraw whose value I knew.
Then to update the drawing was trivial:
jDraw.repaint();
Now the same jDraw is a private member of NMViewView and I don't know how to
cause it to repaint itself.
I defined an additional proceedure
public void repaintImages() {
jDraw.repaint();
}
which gets around the private definition of jDraw, but I am having
difficulty getting to the routine.
Somehow I have the feeling that it shouldn't be this difficult just to ask
it to repaint the panel.
Ilan
Wade Chandler wrote:
>
> Where ever DrawGraphics is just make sure it is built, and then drag it
> from the project view onto your UI form. This will be in NB 6.0. In NB 5.5
> you would have to add it to the Palette to drag and drop. Another way is
> to add a JPanel from the palette then click it and then go to the
> properties window code tab and use the custom initialization section since
> DrawGraphics extends JPanel. You can then use what ever constructor you
> want and in this case you would use "new DrawGraphics()" in the custom
> init editor. Then yet another way is to go to the Palette and go to the
> Beans category. Click the Add Bean or JavaBean or what ever it
> is...generic thing. You'll be presented with a simple input Dialog where
> you type the fully qualified class name. Then as long as it is a valid
> JavaBean (as must be the case in all the other methods but the custom init
> part as in that situation you define the constructor so it doesn't have to
> have a default constructor) NB will
> have one of your classes you can put into the form once you press OK.
>
> Wade
>
> ==================
> Wade Chandler, CCE
> Software Engineer and Developer, Certified Forensic Computer Examiner,
> NetBeans Dream Team Member, and NetBeans Board Member
> http://www.certified-computer-examiner.com
> http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
> http://www.netbeans.org
>
> ----- Original Message ----
> From: Ilan Tal <ilan.tal <at> gmail.com>
> To: nbusers <at> netbeans.org
> Sent: Sunday, December 30, 2007 7:20:01 AM
> Subject: [nbusers] How do I add my own panel to my desktop application?
>
>
> I'm trying to convert my first program from Eclipse to NetBeans desktop
> application.
> For drawing, I use my own class which extends JPanel
>
> class DrawGraphics extends JPanel {
> }
>
> In Eclipse, I used the visual editor to define a JPanel which I called
> jDrawPanel. Then I could manually edit the method which initializes it.
>
>
> /**
> * This method initializes jDrawPanel
> *
> * @return javax.swing.JPanel
> */
> private JPanel getJDrawPanel() {
> if (jDrawPanel == null) {
> jDrawPanel = new JPanel(new GridLayout(1,1));
>
> jDraw = new DrawGraphics();
> jDrawPanel.add(jDraw);
> }
> return jDrawPanel;
> }
>
> NetBeans is more careful about what it lets you edit and I couldn't figure
> out how I could get my DrawGraphics into use in place of a JPanel which I
> dragged into the desired position.
>
> What would be really nice would be if I could drag my own DrawGraphics
> since it extends JPanel, but I can certainly live with the same trick as
> in Eclipse where I put my panel into another panel.
>
> Please tell me the correct way of doing things.
>
>
> Thanks,
> Ilan
>
>
>
>
>
>
--
--
View this message in context: http://www.nabble.com/How-do-I-add-my-own-panel-to-my-desktop-application--tp14546756p14565046.html
Sent from the Netbeans - Users mailing list archive at Nabble.com.