Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2005

Tip: Looking for answers? Try searching our database.

NetBeans

Thread view: 
A.Tamboer - 16 Feb 2005 11:17 GMT
Hi, I am a newbie

I make a JFrame application Lframe in the IDE of NetBeans 4.0. I will call
this frame with a name. How do I get a variable in constructor of the
LFrame? Working with the IDE I do not see a possibility and also when the
application has been made there is no possibility in the property window.
When I do it by myself in the constructor LFrame(String titel) there is a
problem in the main method at the internal class new
LFrame().setVisible(true) made in the main method.

I guess there must be a possibility to make an application in the IDE with a
variable but I can not find it.

Thanks for help Arie Tamboer
Adam - 17 Feb 2005 00:35 GMT
I don't think you can in the IDE directly, though I could be wrong.
What is it that you are trying to do?  If it is just setting the title,
as your example suggests, then you should use the title property in the
properties window when the jFrame is selected in the inspector.  For
most any other component you would use the "Custom Creation Code"
property to modify the constructor.

Adam

> Hi, I am a newbie
>
[quoted text clipped - 10 lines]
>
> Thanks for help Arie Tamboer
A.Tamboer - 17 Feb 2005 11:02 GMT
What I want is that when LFrame is called from a different part of an
application I can see on the title from which part it is called. So when is
called from part x the title of LFrame is 'x' and when from y it is 'y'

Thanks for the help

Arie Tamboer

> Hi, I am a newbie
>
[quoted text clipped - 10 lines]
>
> Thanks for help Arie Tamboer
Roland - 17 Feb 2005 12:21 GMT
> What I want is that when LFrame is called from a different part of an
> application I can see on the title from which part it is called. So when is
[quoted text clipped - 18 lines]
>>
>>Thanks for help Arie Tamboer

There are several possibilities.
1. Add an additional contructor
    public LFrame(String title) {
        this(); // calls other constructor that initializes frame
        setTitle(title);
    }
Then, from x
   new LFrame("x").setVisible(true);
And from y
   new LFrame("y").setVisible(true);

2. Call setTitle() after creating two different instances:
From x:
    LFrame yourFrameFromX = new LFrame();
    yourFrameFromX.setTitle("x");
    yourFrameFromX.setVisible(true);
And from y:
    LFrame yourFrameFromY = new LFrame();
    yourFrameFromY.setTitle("y");
    yourFrameFromY.setVisible(true);

3. Have only one LFrame instance and call setTitle() before setting
frame visible:
    LFrame yourFrame = new LFrame();
Then from x:
    yourFrame.setTitle("x");
    yourFrame.setVisible(true);
And from y:
    yourFrame.setTitle("y");
    yourFrame.setVisible(true);
Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.