Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 28th, 2009, 10:37 AM
Battery Powered Battery Powered is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 164 Battery Powered User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 20 m 3 sec
Reputation Power: 7
Swing - Can a variable be referenced by another variable?

Good day,

Say I have thisNum=1 is there a way I can reference JProgress1Bar by JProgress+thisNum+Bar ?

I've looked a around a lot and have drawn a blank.

Any help appreciated!
BP

Reply With Quote
  #2  
Old June 28th, 2009, 10:57 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Click here for more information.
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 9,073 Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 4 Weeks 1 Day 11 h 8 m 22 sec
Reputation Power: 2975
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
No. It sounds like you're gong down a "scripty" route and trying to program based on the name of a variable. Don't. If you need to associate names to objects, use a Map.

~
Comments on this post
prometheuzz agrees!
__________________
Yawmark
class Sig{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

Reply With Quote
  #3  
Old June 28th, 2009, 03:34 PM
FluffieBird FluffieBird is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Location: Denmark
Posts: 41 FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level)FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level)FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level)FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level)FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level)FluffieBird User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 20 h 38 m 58 sec
Reputation Power: 30
If you have some logic to control the behavior of the bar, I suggest you place that code in a class that also has a reference to the bar, something like this maybe:

Code:
class BarControl
{
   private JProgressBar bar;

   public BarControl(JProgressBar bar)
   {
      this.bar = bar;
   }

   public void doBarLogic()
   {
      ...
   }
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Swing - Can a variable be referenced by another variable?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT