Solved

variable to replace .statement

Posted on 2004-04-23
7
194 Views
Last Modified: 2010-03-31
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
Comment
Question by:Drop_of_Rain
  • 4
  • 2
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10905735
sorry don't understand what u mean
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10905747
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
 

Author Comment

by:Drop_of_Rain
ID: 10905761
Setting a variable like this so I could type: jCheckBox1.textLeft instead of

jCheckBox1.setHorizontalTextPosition(SwingConstants.LEFT);

I was just curious is all?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10905779
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
 
LVL 92

Expert Comment

by:objects
ID: 10905788
the other option would be subclass JCheckBox:

public class MyCheckBox extends JCheckBox
{
   public void textLeft()
   {
      setHorizontalTextPosition(SwingConstants.LEFT);
   }
}
0
 

Author Comment

by:Drop_of_Rain
ID: 10905794
Thanks that answers the question, I didn't think that could be done I just wanted to know.

Thanks
Christopher
0
 
LVL 92

Expert Comment

by:objects
ID: 10905833
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now