|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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.
~
__________________
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)));}} |
|
#3
|
|||
|
|||
|
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()
{
...
}
}
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Swing - Can a variable be referenced by another variable? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|