Solved

variable to replace .statement

Posted on 2004-04-23
7
193 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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.

707 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

17 Experts available now in Live!

Get 1:1 Help Now