|
| ||||||||||
| Tags: class, class overlaylayout, java, java class, java classes, java overlaylayout class, overlaylayout, overlaylayout class, overlaylayout class concept, overlaylayout class methods |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Confused with OverlayLayout class
I am BSc(IT) student and currently learning advanced java. I am expecting you help to solve my confusion. I want to be aware about the 'OverlayLayout class' of the java programming. I don't know how to use the properties of this java class. Do you have knowledge about the 'OverlayLayout class' of java? If yes then please try to share it. Please also provide proper example this class. |
|
#2
| ||||
| ||||
| Re: Confused with OverlayLayout class
Hi friend, A OverlayLayout class is used to arrange components over the top of each other. The requested size of the container will be the largest requested size of the children, taking alignment needs into consideration. The alignment is based upon what is needed to properly fit the children in the allocation area. The children will be placed such that their alignment points are all on top of each other. This class uses the java package known as 'java.lang.Object'. |
|
#3
| ||||
| ||||
| Re: Confused with OverlayLayout class
Hi, I recommend you to go through some following methods of OverlayLayout class:
|
|
#4
| ||||
| ||||
| Re: Confused with OverlayLayout class
Example of OverlayLayout class: Code: import javax.swing.JPanel;
import javax.swing.OverlayLayout;
public class OverlayDemo {
public static void main(String args[]) {
JFrame frameQ = new JFrame("Overlay Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
public boolean isOptimizedDrawingEnabled() {
return false;
}
};
LayoutManager overlayQ = new OverlayLayout(panel);
panel.setLayout(overlayQ);
JButton buttonQ = new JButton("Small");
buttonQ.setMaximumSize(new Dimension(25, 25));
buttonQ.setBackground(Color.white);
buttonQ.setAlignmentX(0.5f);
buttonQ.setAlignmentY(0.5f);
panel.add(buttonQ);
buttonQ = new JButton("Large");
buttonQ.setMaximumSize(new Dimension(100, 100));
buttonQ.setBackground(Color.black);
buttonQ.setAlignmentX(0.5f);
buttonQ.setAlignmentY(0.5f);
panel.add(button);
frame.add(panel, BorderLayout.CENTER);
frame.setSize(200, 300);
frame.setVisible(true);
}
} |
|
#5
| ||||
| ||||
| Re: Confused with OverlayLayout class
Hello friend, The OverlayLayout() method of OverlayLayout class is used for the construction of a layout manager. This is very essential for to perform the children class overlay arrangement of the. To do this you just need to dedicate the layout manager to the particular container. The valid parameter for OverlayLayout() method is 'target'. The 'target' is nothing but the name of the specified container over which you want to apply this method. |
|
#6
| ||||
| ||||
| Re: Confused with OverlayLayout class
Please refer bewlo java code, which will demonstrate you the use of OverlayLayout class as well as it's methods and constructors: Code: import javax.swing.OverlayLayout;
public class ClSample {
public static void main(String args[]) {
JFrame frameW = new JFrame("Overlay Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
public boolean isOptimizedDrawingEnabled() {
return false;
} };
LayoutManager overlay = new OverlayLayout(panel);
panel.setLayout(overlay);
JButton button = new JButton("Small");
buttonW.setMaximumSize(new Dimension(25, 25));
buttonW.setBackground(Color.white);
panel.add(button);
panel.add(button);
framew.add(panel, BorderLayout.CENTER);
framew.setSize(300, 300);
framew.setVisible(true);
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Confused with OverlayLayout class" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Confused about PageAttributes class | Jagruti23 | Software Development | 4 | 09-03-2010 03:34 PM |
| Confused with JInternalFrame class | Truster | Software Development | 5 | 17-02-2010 08:58 AM |
| Confused about JTabbedPane class | Sonam Goenka | Software Development | 5 | 13-02-2010 01:20 PM |
| Confused with JToolTip class | opaper | Software Development | 5 | 13-02-2010 07:53 AM |
| Confused with 'Class SpinnerNumberModel' | Khan Baba | Software Development | 5 | 11-02-2010 10:08 AM |