Solved

variable to replace .statement

Posted on 2004-04-23
7
196 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
map related example 6 59
xampp tool 12 60
jsp insert to database example 2 65
netbeans can not run self signed app 8 14
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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