|
| ||||||||||
| Tags: box, box class, box class concept, class, java, java box class, java class, java classes |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| What is the use of Box class?
I need you help to sort-out my query which is related to the java classes. I want to be aware about the 'Box class' of java programming. I don't know anything about the use of Box class. I have referred many java book for Box class, but nothing was helpful. I wonder if you are able to provide me some information about the Box class of java along with suitable example for the same. I am waiting for your reply. |
|
#2
| ||||
| ||||
| Re: What is the use of Box class? Box class is a lightweight container that uses a BoxLayout object as its layout manager. Box provides several class methods that are useful for containers using BoxLayout - even non-Box containers. The Box class can create several kinds of invisible components that affect layout: glue, struts, and rigid areas. If all the components your Box contains have a fixed size, you might want to use a glue component (returned by createGlue) to control the components' positions. |
|
#3
| |||
| |||
| Re: What is the use of Box class?
Hi friend, I suggest you to refer following example of 'Box class', which will give you something idea about the use of this class: Code: import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JTextField;
public class BoxDM
{
public static void main(String argsw[]) {
JFrame verticalFrame1 = new JFrame("Vertical");
verticalFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Box verticalBox1 = Box.createVerticalBox();
verticalBox1.add(new JLabel("Top"));
verticalBox1.add(new JTextField("Middle"));
verticalBox1.add(new JButton("Bottom"));
verticalFrame1.add(verticalBox, BorderLayout.CENTER);
verticalFrame1.setSize(250, 150);
verticalFrame1.setVisible(true);
}
} |
|
#4
| ||||
| ||||
| Re: What is the use of Box class?
Please review following some of the important methods of 'Box class':
|
|
#5
| ||||
| ||||
| Re: What is the use of Box class?
In following example I have used different methods of Box class of java: Code: import javax.swing.Box;
import javax.swing.JTextField;
public class SampleBox
{
public static void main(String argvs[])
{
JFrame hf = new JFrame("Horizontal");
hf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Box hb = Box.createHorizontalBox();
hb.add(new JLabel("Left"));
hb.add(new JTextField("Middle"));
hb.add(new JButton("Right"));
hf.add(hb, BorderLayout.CENTER);
hf.setSize(150, 150);
hf.setVisible(true);
}
} |
|
#6
| ||||
| ||||
| Re: What is the use of Box class?
Hello friend, If you want to use the properties of Box class, then you need to be aware about the following nested classes:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "What is the use of Box class?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Upgrade Sony Ericsson Xperia Play Micro SD card from class 2 8GB to class 4 32GB | Aaryan2011 | Portable Devices | 8 | 08-10-2011 11:06 PM |
| What is the difference between Local class and global class in C++? | Dėfrim | Software Development | 4 | 03-01-2011 09:44 PM |
| How to initialize a derived class with an instance of the base class in c#? | KAIRU26 | Software Development | 5 | 12-02-2010 05:23 PM |
| Ultra solid drives:Imation M-Class and S-Class | Regina | Portable Devices | 1 | 03-04-2009 10:34 AM |
| Good news for CBSE CLASS X & CLASS IX - visit learnnext | surya_expert | Education Career and Job Discussions | 0 | 13-12-2008 11:09 AM |