Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #18320 > unrolled thread
| Started by | clusardi2k@aol.com |
|---|---|
| First post | 2012-08-26 07:44 -0700 |
| Last post | 2012-09-03 10:39 +0100 |
| Articles | 7 — 6 participants |
Back to article view | Back to comp.lang.java.programmer
Netbeans "form" code is uneditable unless copy/paste into new java file clusardi2k@aol.com - 2012-08-26 07:44 -0700
Re: Netbeans "form" code is uneditable unless copy/paste into new java file Arne Vajhøj <arne@vajhoej.dk> - 2012-08-26 10:50 -0400
Re: Netbeans "form" code is uneditable unless copy/paste into new java file markspace <-@.> - 2012-08-26 11:23 -0700
Re: Netbeans "form" code is uneditable unless copy/paste into new java file Lew <noone@lewscanon.com> - 2012-08-26 20:40 -0700
Re: Netbeans "form" code is uneditable unless copy/paste into new java file "John B. Matthews" <nospam@nospam.invalid> - 2012-08-27 01:47 -0400
Re: Netbeans "form" code is uneditable unless copy/paste into new java file "John B. Matthews" <nospam@nospam.invalid> - 2012-08-26 14:54 -0400
Re: Netbeans "form" code is uneditable unless copy/paste into new java file Nigel Wade <nmw@ion.le.ac.uk> - 2012-09-03 10:39 +0100
| From | clusardi2k@aol.com |
|---|---|
| Date | 2012-08-26 07:44 -0700 |
| Subject | Netbeans "form" code is uneditable unless copy/paste into new java file |
| Message-ID | <08941df4-43d5-4db8-acad-62149e87263c@googlegroups.com> |
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,
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-08-26 10:50 -0400 |
| Message-ID | <503a379f$0$285$14726298@news.sunsite.dk> |
| In reply to | #18320 |
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
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-08-26 11:23 -0700 |
| Message-ID | <k1dpiq$2a1$1@dont-email.me> |
| In reply to | #18320 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Lew <noone@lewscanon.com> |
|---|---|
| Date | 2012-08-26 20:40 -0700 |
| Message-ID | <k1eq7g$5hg$1@news.albasani.net> |
| In reply to | #18322 |
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/wikipedia/commons/c/cf/Friz.jpg
[toc] | [prev] | [next] | [standalone]
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Date | 2012-08-27 01:47 -0400 |
| Message-ID | <nospam-ACF080.01473527082012@news.aioe.org> |
| In reply to | #18324 |
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>
[toc] | [prev] | [next] | [standalone]
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Date | 2012-08-26 14:54 -0400 |
| Message-ID | <nospam-694A48.14543026082012@news.aioe.org> |
| In reply to | #18320 |
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>
[toc] | [prev] | [next] | [standalone]
| From | Nigel Wade <nmw@ion.le.ac.uk> |
|---|---|
| Date | 2012-09-03 10:39 +0100 |
| Message-ID | <aajc71Fr0hU1@mid.individual.net> |
| In reply to | #18320 |
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/tutorial/uiswing/components/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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web