예제 #1
0
 /*
  * (non-Javadoc)
  *
  * @see javax.swing.JFrame#setLayout(java.awt.LayoutManager)
  */
 @Override
 public void setLayout(LayoutManager manager) {
   if (manager.getClass() != RibbonFrameLayout.class) {
     LayoutManager currManager = getLayout();
     if (currManager != null) {
       throw new IllegalArgumentException("Can't set a custom layout manager on JRibbonFrame");
     }
   }
   super.setLayout(manager);
 }
예제 #2
0
파일: Test.java 프로젝트: curtcox/dbbrowser
 public Test(LayoutManager layout, JComponent[] components) {
   super(layout.getClass().getName());
   JPanel panel = new JPanel(layout);
   // --- code needed to add the components
   // less than using a GridBagLayout
   for (JComponent component : components) {
     panel.add(component);
   }
   // ---
   panel.setBorder(new EtchedBorder());
   setContentPane(new JScrollPane(panel));
   pack();
   show();
 }
예제 #3
0
  /**
   * Creation and initialization of a layout delegate for a new container.
   *
   * @param initialize
   * @return false if suitable layout delegate is not found
   * @throws java.lang.Exception
   * @throw IllegalArgumentException if the container instance is not empty
   */
  public boolean prepareLayoutDelegate(boolean initialize) throws Exception {
    LayoutSupportDelegate delegate = null;
    LayoutManager lmInstance = null;

    // first try to find a dedicated layout delegate (for the container)
    Class<?> layoutDelegateClass =
        LayoutSupportRegistry.getSupportClassForContainer(radContainer.getBeanClass());

    if (layoutDelegateClass != null) {
      delegate = (LayoutSupportDelegate) layoutDelegateClass.newInstance();
      /*
      if (!delegate.checkEmptyContainer(getPrimaryContainer())) {
          RuntimeException ex = new IllegalArgumentException();
          org.openide.ErrorManager.getDefault().annotate(
                  ex, AbstractLayoutSupport.getBundle().getString(
                          "MSG_ERR_NonEmptyContainer")); // NOI18N
          throw ex;
      }
      */
    } else {
      Container contDel = getPrimaryContainerDelegate();
      // if (contDel.getComponentCount() == 0) {
      // we can still handle only empty containers ...
      lmInstance = contDel.getLayout();
      delegate = LayoutSupportRegistry.createSupportForLayout(lmInstance.getClass());
      /*
      } else {
          RuntimeException ex = new IllegalArgumentException();
          org.openide.ErrorManager.getDefault().annotate(
                  ex, AbstractLayoutSupport.getBundle().getString(
                          "MSG_ERR_NonEmptyContainer")); // NOI18N
          throw ex;
      }
          */
    }

    if (delegate != null) {
      if (initialize) {
        setLayoutDelegate(delegate);
      } else {
        layoutDelegate = delegate;
        needInit = true;
        initializeFromInstance = lmInstance != null;
      }
      return true;
    } else {
      return false;
    }
  }
 public void testLayout() {
   CalculatorPanel c = new CalculatorPanel();
   LayoutManager layout = c.getLayout();
   assertEquals(FlowLayout.class, layout.getClass());
 }