Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Confused with OverlayLayout class

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-02-2010
Member
 
Join Date: Dec 2009
Posts: 67
Confused with OverlayLayout class
  

Hi All,

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.

Reply With Quote
  #2  
Old 12-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,993
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'.
Reply With Quote
  #3  
Old 12-02-2010
Member
 
Join Date: May 2008
Posts: 2,283
Re: Confused with OverlayLayout class

Hi,

I recommend you to go through some following methods of OverlayLayout class:
  1. removeLayoutComponent(Component cmp)
  2. preferredLayoutSize(Container tgt)
  3. maximumLayoutSize(Container tgt)
  4. addLayoutComponent(String nm, Component cmp)
  5. addLayoutComponent(Component cmp, Object cstrn)
Reply With Quote
  #4  
Old 12-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,385
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);
  }
}
Reply With Quote
  #5  
Old 12-02-2010
Member
 
Join Date: May 2008
Posts: 2,373
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.
Reply With Quote
  #6  
Old 12-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,842
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);
  }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Confused with OverlayLayout class"
Thread Thread Starter Forum Replies Last Post
Confused about Scrollbar class Jagruti23 Software Development 5 06-03-2010 03:18 PM
Confused about the List class Jagruti23 Software Development 5 05-03-2010 03:17 PM
Confused with JInternalFrame class Truster Software Development 5 17-02-2010 08:58 AM
Confused with JSpinner class Bottlenecked Software Development 4 15-02-2010 08:51 AM
Confused with 'Class SpinnerNumberModel' Khan Baba Software Development 5 11-02-2010 10:08 AM


All times are GMT +5.5. The time now is 04:51 PM.