Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18327 > unrolled thread

Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name

Started byclusardi2k@aol.com
First post2012-08-27 07:10 -0700
Last post2012-08-27 07:58 -0700
Articles 4 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name clusardi2k@aol.com - 2012-08-27 07:10 -0700
    Re: Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-27 10:24 -0400
    Re: Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name clusardi2k@aol.com - 2012-08-27 07:23 -0700
      Re: Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name FredK <fred.l.kleinschmidt@gmail.com> - 2012-08-27 07:58 -0700

#18327 — Moving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name

Fromclusardi2k@aol.com
Date2012-08-27 07:10 -0700
SubjectMoving To JDialog From JFrame: NetBeans Design View Has JFrame Without A Variable Name
Message-ID<5ca38d1b-9ee4-4ffe-a6c3-566820e7ffac@googlegroups.com>
If I can't obtain the name of a JFrame variable what can I do.

I created a form using NetBean's Design view. The JFrame doesn't appear to have a variable name associated with it. Can I obtain a variable name for it somehow.

If I copy the entire project to another file with the same name and delete the old file the project still runs. In the file, there is no explicit reference to a JFrame at all. But, the JFrame class is inherited in a number of places.

I need the name of the JFrame variable because I want to use it in a JDialog extended class using:

public class Test extends JDialog 
{ ...
     public Test(Frame parent) 
     { 
         super(parent, "Login", true);
...
     }
...

The above "parent" was created using:

         final JFrame frame = new JFrame("Testing");

I pass frame to Test:

         Test tst = new Test(frame); 

Thank you, 

[toc] | [next] | [standalone]


#18328

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2012-08-27 10:24 -0400
Message-ID<k1fvvo$pcc$1@dont-email.me>
In reply to#18327
On 8/27/2012 10:10 AM, clusardi2k@aol.com wrote:
> If I can't obtain the name of a JFrame variable what can I do.

     Invent one?

> I created a form using NetBean's Design view. The JFrame doesn't appear to have a variable name associated with it. Can I obtain a variable name for it somehow.

     You created a *class* using NetBeans: Data fields, initializers,
methods -- and one or more constructors.  When you want an instance
of that class, construct one with `new', just as you would with any
other class.  And if you want to retain a reference to that instance,
store it in a variable with a name of your own choosing.

> If I copy the entire project to another file with the same name and delete the old file the project still runs. In the file, there is no explicit reference to a JFrame at all. But, the JFrame class is inherited in a number of places.

     Sorry; I can't figure out what you mean by "copy the entire project"
or by "the project still runs."  Also, while it makes sense that your
class might extend JFrame, I don't understand how it can do so "in a
number of places."

> I need the name of the JFrame variable because I want to use it in a JDialog extended class using:
>
> public class Test extends JDialog
> { ...
>       public Test(Frame parent)
>       {
>           super(parent, "Login", true);
> ...
>       }
> ...
>
> The above "parent" was created using:
>
>           final JFrame frame = new JFrame("Testing");

     Problem solved: `frame' is the name of the variable that
refers to your JFrame.  (Yet I can't escape the feeling that
something's been garbled: This new instance is a plain vanilla
JFrame, not a class of your own or your own "form" or whatever.)

> I pass frame to Test:
>
>           Test tst = new Test(frame);

     Looks fine.  What's the problem?

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


#18329

Fromclusardi2k@aol.com
Date2012-08-27 07:23 -0700
Message-ID<1f6c61c0-95a5-420d-9179-ed3432a06fdb@googlegroups.com>
In reply to#18327
When I put the folowing code into "InitComponents ()", it tells me "frame0".
 
       System.out.println ("Variable name " + this.toString());

[toc] | [prev] | [next] | [standalone]


#18331

FromFredK <fred.l.kleinschmidt@gmail.com>
Date2012-08-27 07:58 -0700
Message-ID<34ba3c1e-1fd7-4f96-bfd5-fc5ef5a4826a@googlegroups.com>
In reply to#18329
On Monday, August 27, 2012 7:23:58 AM UTC-7, (unknown) wrote:
> When I put the folowing code into "InitComponents ()", it tells me "frame0". System.out.println ("Variable name " + this.toString());

The first frame you create will have the name "frame0", the next one "frame1", etc. You need to give your instance a name if you want something other than "frameN":

this.setName( "myName" );

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web