Ejemplo n.º 1
0
  /**
   * If <code>c</code> is the <code>JOptionPane</code> the receiver is contained in, the preferred
   * size that is returned is the maximum of the preferred size of the <code>LayoutManager</code>
   * for the <code>JOptionPane</code>, and <code>getMinimumOptionPaneSize</code>.
   */
  public Dimension getPreferredSize(JComponent c) {
    if (c == optionPane) {
      Dimension ourMin = getMinimumOptionPaneSize();
      LayoutManager lm = c.getLayout();

      if (lm != null) {
        Dimension lmSize = lm.preferredLayoutSize(c);

        if (ourMin != null)
          return new Dimension(
              Math.max(lmSize.width, ourMin.width), Math.max(lmSize.height, ourMin.height));
        return lmSize;
      }
      return ourMin;
    }
    return null;
  }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 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();
 }
 public void testLayout() {
   CalculatorPanel c = new CalculatorPanel();
   LayoutManager layout = c.getLayout();
   assertEquals(FlowLayout.class, layout.getClass());
 }