• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

variable to replace .statement

Hello everyone out there I hope someone can help me with this simple question!

I want to know if I can set up a variable to replace this:   .setHorizontalTextPosition(SwingConstants.LEFT);
                                                                      to this: .variable


jCheckBox1.setHorizontalTextPosition(SwingConstants.LEFT);
0
Drop_of_Rain
Asked:
Drop_of_Rain
  • 4
  • 2
1 Solution
 
objectsCommented:
sorry don't understand what u mean
0
 
mmuruganandamCommented:
there is no such option available in Java.

you are asking like

with (textArea)
{
      .setText("A");
      .setLocation(10,10);
}

This is not available in java and is not pure object oriented then...



Regards,
Muruga
0
 
Drop_of_RainAuthor Commented:
Setting a variable like this so I could type: jCheckBox1.textLeft instead of

jCheckBox1.setHorizontalTextPosition(SwingConstants.LEFT);

I was just curious is all?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
objectsCommented:
no u cant do that.

you could create a helper method:

public class Utes
{
   public static textLeft(JCheckBox cb)
   {
      cb.setHorizontalTextPosition(SwingConstants.LEFT);
   }
}

you could then do:

Utes.textLeft(jCheckBox1);
0
 
objectsCommented:
the other option would be subclass JCheckBox:

public class MyCheckBox extends JCheckBox
{
   public void textLeft()
   {
      setHorizontalTextPosition(SwingConstants.LEFT);
   }
}
0
 
Drop_of_RainAuthor Commented:
Thanks that answers the question, I didn't think that could be done I just wanted to know.

Thanks
Christopher
0
 
objectsCommented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now