Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Netbeans "form" code is uneditable unless copy/paste into new java file (http://www.velocityreviews.com/forums/t951404-netbeans-form-code-is-uneditable-unless-copy-paste-into-new-java-file.html)

clusardi2k@aol.com 08-26-2012 02:44 PM

Netbeans "form" code is uneditable unless copy/paste into new java file
 
How can I modify the code automatically created by Netbeans. Some of that code appears to be uneditable.

Instead, I can copy the code, delete the form file it was in, and paste the code into a new class. But, the form disappears. At this code I have all the code, but I lose the "Design" view entirely.

Ok experts, what can I do.

The reason I want to do this is the Swing pallet (in design view) doesn't have things that I need such as modal window capabilities (jdialogs), and Jlayer capabilities (for a light box effect). Am I wrong about this.

Thank you,

Arne Vajh°j 08-26-2012 02:50 PM

Re: Netbeans "form" code is uneditable unless copy/paste into newjava file
 
On 8/26/2012 10:44 AM, clusardi2k@aol.com wrote:
> How can I modify the code automatically created by Netbeans. Some of that code appears to be uneditable.
>
> Instead, I can copy the code, delete the form file it was in, and paste the code into a new class. But, the form disappears. At this code I have all the code, but I lose the "Design" view entirely.
>
> Ok experts, what can I do.
>
> The reason I want to do this is the Swing pallet (in design view) doesn't have things that I need such as modal window capabilities (jdialogs), and Jlayer capabilities (for a light box effect). Am I wrong about this.


NetBeans GUI Builder has traditional been one way.

Maybe you should do like most other Java GUI developers do: use the
GUI builder to learn things but write the real code yourself.

Arne



markspace 08-26-2012 06:23 PM

Re: Netbeans "form" code is uneditable unless copy/paste into newjava file
 
On 8/26/2012 7:44 AM, clusardi2k@aol.com wrote:
> How can I modify the code automatically created by Netbeans. Some of
> that code appears to be uneditable.
>
> Instead, I can copy the code, delete the form file it was in, and
> paste the code into a new class. But, the form disappears. At this
> code I have all the code, but I lose the "Design" view entirely.
>
> Ok experts, what can I do.
>
> The reason I want to do this is the Swing pallet (in design view)
> doesn't have things that I need such as modal window capabilities
> (jdialogs), and Jlayer capabilities (for a light box effect). Am I
> wrong about this.



First, don't make JFrames forms. Make JPanels. You can add a JPanel to
a JDialog. I haven't played with JLayer, but a quick read-through of
their docs makes it appear that you can reasonably expect to add a
JPanel to one as well.

Then, when you still need to modify code for you JPanel forms, just
don't modify the code the IDE generates. There's an initComponents()
method where all the non-modifiable code goes. After initComponents()
method is called, put your code there.

MyJPanel() {
initComponents();
... add your code here...
}

initComponents() {
... can't modify this ..
}

Likewise, you can just add arbitrary methods to the JPanel to do
whatever you need.

void changeMyProperty( SomeProperty p ) {
// ... do stuff...
jLabel1.setText( p.someString() );
jTextField1 = new JTextField();
}

// Instance fields added by NetBeans
private void JLabel jLabel1;
private void JTextField jTextField1;


Basically you have to know Java programming, and then just do the
obvious thing. But I realize it can be hard to get started sometimes,
so the above few hints should help you out.


John B. Matthews 08-26-2012 06:54 PM

Re: Netbeans "form" code is uneditable unless copy/paste into new java file
 
In article <08941df4-43d5-4db8-acad-62149e87263c@googlegroups.com>,
clusardi2k@aol.com wrote:

> How can I modify the code automatically created by Netbeans.
> Some of that code appears to be uneditable.


Anything you can't change in an appropriate Code Property?
Or the component's Customize Code dialog?

[...]

> The reason I want to do this is the [Palette] (in design view)
> doesn't have things that I need such as modal window capabilities
> (jdialogs),


Dialog & Option Pane are under Swing Windows.

[...]

Nothing says you have to use it for _everything_.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Lew 08-27-2012 03:40 AM

Re: Netbeans "form" code is uneditable unless copy/paste into newjava file
 
markspace wrote:
> clusardi2k@aol.com wrote:
>> How can I modify the code automatically created by Netbeans. Some of
>> that code appears to be uneditable.
>>
>> Instead, I can copy the code, delete the form file it was in, and
>> paste the code into a new class. But, the form disappears. At this
>> code I have all the code, but I lose the "Design" view entirely.
>>
>> Ok experts, what can I do.
>>
>> The reason I want to do this is the Swing pallet (in design view)
>> doesn't have things that I need such as modal window capabilities
>> (jdialogs), and Jlayer capabilities (for a light box effect). Am I
>> wrong about this.

>
>
> First, don't make JFrames forms. Make JPanels. You can add a JPanel to a
> JDialog. I haven't played with JLayer, but a quick read-through of their docs
> makes it appear that you can reasonably expect to add a JPanel to one as well.
>
> Then, when you still need to modify code for you JPanel forms, just don't
> modify the code the IDE generates. There's an initComponents() method where
> all the non-modifiable code goes. After initComponents() method is called,
> put your code there.
>
> MyJPanel() {
> initComponents();
> ... add your code here...
> }
>
> initComponents() {
> ... can't modify this ..
> }
>
> Likewise, you can just add arbitrary methods to the JPanel to do whatever you
> need.
>
> void changeMyProperty( SomeProperty p ) {
> // ... do stuff...
> jLabel1.setText( p.someString() );
> jTextField1 = new JTextField();
> }
>
> // Instance fields added by NetBeans
> private void JLabel jLabel1;
> private void JTextField jTextField1;
>
>
> Basically you have to know Java programming, and then just do the obvious
> thing. But I realize it can be hard to get started sometimes, so the above
> few hints should help you out.


Apropos of markspace's advice, the NetBeans GUI builder lets you link your
custom methods to the events you want to handle via the properties pages for
your screens. So you wire up those arbitrary methods to be called by the
uneditable parts that MB provides. Best of both worlds.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg

John B. Matthews 08-27-2012 05:47 AM

Re: Netbeans "form" code is uneditable unless copy/paste into new java file
 
In article <k1eq7g$5hg$1@news.albasani.net>, Lew <noone@lewscanon.com>
wrote:

> markspace wrote:
> > clusardi2k@aol.com wrote:
> >> How can I modify the code automatically created by Netbeans. Some
> >> of that code appears to be uneditable.
> >>
> >> Instead, I can copy the code, delete the form file it was in, and
> >> paste the code into a new class. But, the form disappears. At this
> >> code I have all the code, but I lose the "Design" view entirely.
> >>
> >> Ok experts, what can I do.
> >>
> >> The reason I want to do this is the Swing pallet (in design view)
> >> doesn't have things that I need such as modal window capabilities
> >> (jdialogs), and Jlayer capabilities (for a light box effect). Am I
> >> wrong about this.

> >
> >
> > First, don't make JFrames forms. Make JPanels. You can add a
> > JPanel to a JDialog. I haven't played with JLayer, but a quick
> > read-through of their docs makes it appear that you can reasonably
> > expect to add a JPanel to one as well.
> >
> > Then, when you still need to modify code for you JPanel forms, just
> > don't modify the code the IDE generates. There's an
> > initComponents() method where all the non-modifiable code goes.
> > After initComponents() method is called, put your code there.
> >
> > MyJPanel() {
> > initComponents();
> > ... add your code here...
> > }
> >
> > initComponents() {
> > ... can't modify this ..
> > }
> >
> > Likewise, you can just add arbitrary methods to the JPanel to do
> > whatever you need.
> >
> > void changeMyProperty( SomeProperty p ) {
> > // ... do stuff...
> > jLabel1.setText( p.someString() );
> > jTextField1 = new JTextField();
> > }
> >
> > // Instance fields added by NetBeans
> > private void JLabel jLabel1;
> > private void JTextField jTextField1;
> >
> >
> > Basically you have to know Java programming, and then just do the
> > obvious thing. But I realize it can be hard to get started
> > sometimes, so the above few hints should help you out.

>
> Apropos of markspace's advice, the NetBeans GUI builder lets you link
> your custom methods to the events you want to handle via the
> properties pages for your screens. So you wire up those arbitrary
> methods to be called by the uneditable parts that MB provides. Best
> of both worlds.


Exactly; there's a related example here:

<http://stackoverflow.com/a/10468877/230513>

Also, add editor-managed panel(s) to a conventional top-level container,
as shown here:

<http://stackoverflow.com/a/2561540/230513>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Nigel Wade 09-03-2012 09:39 AM

Re: Netbeans "form" code is uneditable unless copy/paste into newjava file
 
On 26/08/12 15:44, clusardi2k@aol.com wrote:
> How can I modify the code automatically created by Netbeans. Some of
> that code appears to be uneditable.


You can't. It's created by NetBeans as determined by the properties of
each of the palette components in the form. If you start making ad hoc
changes to the code the relationship between the form and the code will
be broken.

NetBeans provides you with many facilities to modify the code which is
generated. Much of the functionality of the component is set in the
Properties window for that component. The most flexible customization is
in available in the "Code" tab of the Properties window. Here you can
enter your own code at specific points during the
construction/initialization steps of the component.

>
> Instead, I can copy the code, delete the form file it was in, and
> paste the code into a new class. But, the form disappears. At this
> code I have all the code, but I lose the "Design" view entirely.


Of course, by doing this you have explicitly broken the relationship
between the form and the Java code created from it.

>
> Ok experts, what can I do.


Look at all the properties of the component and see if any of them can
do what you require.

>
> The reason I want to do this is the Swing pallet (in design view)
> doesn't have things that I need such as modal window capabilities
> (jdialogs), and Jlayer capabilities (for a light box effect). Am I
> wrong about this.


If this is related to you other question regarding modal dialogs, then I
would recommend you start here:
http://docs.oracle.com/javase/tutori...ts/dialog.html

The simplest modal dialog is the JOptionPane.

Otherwise you can create your own JDialog. This might be in the main
GUI, as the "Other Components" section of the form, or a separate class
auto-created by the "new JDialog form". A JDialog in the form editor
does have the modal property, which is a toggle button in the main
Properties for the object. I have no knowledge of JLayer, but you can
probably do what you want via the Properties/Code tab of whatever
component in the form is most suitable.

--
Nigel Wade




All times are GMT. The time now is 10:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.