Results 1 to 6 of 6

Thread: Confused with OverlayLayout class

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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. #3
    Join Date
    May 2008
    Posts
    2,297

    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)

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    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. #5
    Join Date
    May 2008
    Posts
    2,389

    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. #6
    Join Date
    Feb 2008
    Posts
    1,852

    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);
      }
    }

Similar Threads

  1. Confused about Scrollbar class
    By Jagruti23 in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 04:18 PM
  2. Confused about the List class
    By Jagruti23 in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 04:17 PM
  3. Confused with JInternalFrame class
    By Truster in forum Software Development
    Replies: 5
    Last Post: 17-02-2010, 09:58 AM
  4. Confused with JSpinner class
    By Bottlenecked in forum Software Development
    Replies: 4
    Last Post: 15-02-2010, 09:51 AM
  5. Confused with 'Class SpinnerNumberModel'
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 11:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,638,652.02569 seconds with 17 queries