Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Moving To JDialog From JFrame: NetBeans Design View Has JFrameWithout A Variable Name

Reply
Thread Tools

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

 
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-27-2012
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,
 
Reply With Quote
 
 
 
 
clusardi2k@aol.com
Guest
Posts: n/a
 
      08-27-2012
When I put the folowing code into "InitComponents ()", it tells me "frame0".

System.out.println ("Variable name " + this.toString());
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      08-27-2012
On 8/27/2012 10:10 AM, 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
d
 
Reply With Quote
 
FredK
Guest
Posts: n/a
 
      08-27-2012
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" );
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted ASP .Net 0 01-06-2008 04:45 AM
"Variable variable name" or "variable lvalue" mfglinux Python 11 09-12-2007 03:08 AM
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
NetBeans - JDialog does not appear as a choice Dom Java 2 11-28-2006 01:54 PM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM



Advertisments