Package java.awt

Examples of java.awt.LayoutManager2


  public void test(TestHarness harness)   
  {
    JTextField ftf = new JTextField("HELLO WORLD");
    JPanel borderPanel = new JPanel(new java.awt.BorderLayout());
    borderPanel.add(ftf);
    LayoutManager2 lm = (LayoutManager2) borderPanel.getLayout();
    Dimension max = new Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE);

    // Check that the layout manager returns Integer.MAX_VALUE for both
    // max dimensions, regardless of whether or not there's a border
    harness.check (lm.maximumLayoutSize(borderPanel), max);
    borderPanel.setBorder(new javax.swing.border.TitledBorder("HELLO WORLD"));   
    harness.check (lm.maximumLayoutSize(borderPanel), max);

    // Check that maximumLayoutSize isn't affected by the layout size of
    // the contained components
    ftf.setMaximumSize(new Dimension (0,0));
    harness.check (lm.maximumLayoutSize(borderPanel), max);

    // Check that maximumLayoutSize returns Integer.MAX_VALUE even for null
    // arguments
    harness.check (lm.maximumLayoutSize(null), max);

    // Check that a brand new BorderLayout unassociated with any Component
    // also returns Integer.MAX_VALUE for a null argument.
    BorderLayout bl = new BorderLayout();
    harness.check (bl.maximumLayoutSize(null), max);
View Full Code Here


  {
    JTextField ftf = new JTextField("HELLO WORLD");
    JPanel borderPanel = new JPanel();
    borderPanel.setLayout(new BoxLayout(borderPanel, BoxLayout.Y_AXIS));   
    borderPanel.add(ftf);
    LayoutManager2 lm = (LayoutManager2) borderPanel.getLayout();
    Dimension max = new Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE);

    harness.check (lm.maximumLayoutSize(borderPanel), max);
    borderPanel.setBorder(new javax.swing.border.TitledBorder("HELLO WORLD"));   
    harness.check (lm.maximumLayoutSize(borderPanel), max);
  }
View Full Code Here

{

  public void test(TestHarness harness)
  {
    JRootPane rp = new JRootPane();
    LayoutManager2 lm2 = (LayoutManager2) rp.getLayout();

    // Check for the value when nothing is touched.
    harness.check(lm2.getLayoutAlignmentY(rp), 0.0F);

    // Setting the root pane's alignmentY doesn't change anything.
    rp.setAlignmentY(0.5F);
    harness.check(lm2.getLayoutAlignmentY(rp), 0.0F);

    // Setting the content pane's alignmentY doesn't change anything.
    ((JComponent) rp.getContentPane()).setAlignmentY(0.5F);
    harness.check(lm2.getLayoutAlignmentY(rp), 0.0F);

    // Setting the glass pane's alignmentY doesn't change anything.
    ((JComponent) rp.getGlassPane()).setAlignmentY(0.5F);
    harness.check(lm2.getLayoutAlignmentY(rp), 0.0F);

    // Setting the layered pane's alignmentY doesn't change anything.
    ((JComponent) rp.getLayeredPane()).setAlignmentY(0.5F);
    harness.check(lm2.getLayoutAlignmentY(rp), 0.0F);
  }
View Full Code Here

{

  public void test(TestHarness harness)
  {
    JRootPane rp = new JRootPane();
    LayoutManager2 lm2 = (LayoutManager2) rp.getLayout();

    // Check for the value when nothing is touched.
    harness.check(lm2.getLayoutAlignmentX(rp), 0.0F);

    // Setting the root pane's alignmentX doesn't change anything.
    rp.setAlignmentX(0.5F);
    harness.check(lm2.getLayoutAlignmentX(rp), 0.0F);

    // Setting the content pane's alignmentX doesn't change anything.
    ((JComponent) rp.getContentPane()).setAlignmentX(0.5F);
    harness.check(lm2.getLayoutAlignmentX(rp), 0.0F);

    // Setting the glass pane's alignmentX doesn't change anything.
    ((JComponent) rp.getGlassPane()).setAlignmentX(0.5F);
    harness.check(lm2.getLayoutAlignmentX(rp), 0.0F);

    // Setting the layered pane's alignmentX doesn't change anything.
    ((JComponent) rp.getLayeredPane()).setAlignmentX(0.5F);
    harness.check(lm2.getLayoutAlignmentX(rp), 0.0F);
  }
View Full Code Here

      moveFrame(frame, dragBounds.x + dragBounds.width / 2, dragBounds.y + dragBounds.height / 2);
    }
   
    public void moveFrame(JComponent frame, int newX, int newY) {
    JDesktopPane desktop = getDesktopPane(frame);
    LayoutManager2 layoutManager = (LayoutManager2)desktop.getLayout();
    Component componentToDock = desktop.getComponentAt(newX, newY);
    if (componentToDock != null && componentToDock != frame) {
      layoutManager.addLayoutComponent(frame, new DockConstraints(componentToDock, getDockLocation(componentToDock, newX, newY)));
      layoutManager.layoutContainer(desktop);
    }
    if (frame instanceof JInternalFrame) {
      setSelected((JInternalFrame)frame);
    }
    }
View Full Code Here

    }
   
    protected LayoutManager createLayout() {
        //This is in the UI delegate because the layout
        //manager takes into account spacing for the separators between components
        return new LayoutManager2() {
            private Map<Component,Constraint> constraints = new HashMap<Component,Constraint>();
           
            public void addLayoutComponent(String name, Component comp) {addLayoutComponent(comp, null);}
            public void removeLayoutComponent(Component comp) {constraints.remove(comp);}
            public Dimension minimumLayoutSize(Container parent) {return preferredLayoutSize(parent);}
View Full Code Here

TOP

Related Classes of java.awt.LayoutManager2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.