类java.awt.LayoutManager源码实例Demo

下面列出了怎么用java.awt.LayoutManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码2 项目: openjdk-jdk8u-backup   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
private JPanel getMainJPanel() {

        JPanel mainJPanel = new JPanel();

        LayoutManager layout = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS);
        mainJPanel.setLayout(layout);

        JPanel settingsJPanel = getSettingsJPanel();
        JPanel buttonsJPanel = getButtonsJPanel();

        mainJPanel.add(settingsJPanel);
        mainJPanel.add(Box.createRigidArea(new Dimension(4, 2)));
        mainJPanel.add(buttonsJPanel);
        mainJPanel.add(Box.createRigidArea(new Dimension(4, 4)));
        // mainJPanel.add(Box.createHorizontalGlue());

        return mainJPanel;
    }
 
源代码4 项目: jdk8u-dev-jdk   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码5 项目: TencentKona-8   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码6 项目: JDKSourceCode1.8   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码7 项目: openjdk-jdk8u   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码8 项目: Bytecoder   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码9 项目: openjdk-8   文件: NimbusLookAndFeel.java
/**
 * Package private method which returns either BorderLayout.NORTH,
 * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending
 * on the location of the toolbar in its parent. The toolbar might be
 * in PAGE_START, PAGE_END, CENTER, or some other position, but will be
 * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar
 * actually IS, with CENTER being NORTH.
 *
 * This code is used to determine where the border line should be drawn
 * by the custom toolbar states, and also used by NimbusIcon to determine
 * whether the handle icon needs to be shifted to look correct.
 *
 * Toollbars are unfortunately odd in the way these things are handled,
 * and so this code exists to unify the logic related to toolbars so it can
 * be shared among the static files such as NimbusIcon and generated files
 * such as the ToolBar state classes.
 */
static Object resolveToolbarConstraint(JToolBar toolbar) {
    //NOTE: we don't worry about component orientation or PAGE_END etc
    //because the BasicToolBarUI always uses an absolute position of
    //NORTH/SOUTH/EAST/WEST.
    if (toolbar != null) {
        Container parent = toolbar.getParent();
        if (parent != null) {
            LayoutManager m = parent.getLayout();
            if (m instanceof BorderLayout) {
                BorderLayout b = (BorderLayout)m;
                Object con = b.getConstraints(toolbar);
                if (con == SOUTH || con == EAST || con == WEST) {
                    return con;
                }
                return NORTH;
            }
        }
    }
    return NORTH;
}
 
源代码10 项目: jdk1.8-source-analysis   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码11 项目: openjdk-jdk9   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码12 项目: mzmine3   文件: ScrollablePanel.java
/**
 * Constuctor for specifying the LayoutManager of the panel.
 *
 * @param layout the LayountManger for the panel
 */
public ScrollablePanel(LayoutManager layout) {
  super(layout);

  IncrementInfo block = new IncrementInfo(IncrementType.PERCENT, 100);
  IncrementInfo unit = new IncrementInfo(IncrementType.PERCENT, 10);

  setScrollableBlockIncrement(HORIZONTAL, block);
  setScrollableBlockIncrement(VERTICAL, block);
  setScrollableUnitIncrement(HORIZONTAL, unit);
  setScrollableUnitIncrement(VERTICAL, unit);
}
 
源代码13 项目: dragonwell8_jdk   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码14 项目: gcs   文件: DockTab.java
@Override
public void setLayout(LayoutManager mgr) {
    if (mgr instanceof PrecisionLayout) {
        super.setLayout(mgr);
    } else {
        throw new IllegalArgumentException("Must use a PrecisionLayout.");
    }
}
 
源代码15 项目: openjdk-8-source   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码16 项目: ghidra   文件: CheckBoxBasedAncillaryFilter.java
protected JComponent createComponent() {
	LayoutManager manager = createLayoutManager();
	JPanel panel = new JPanel();
	panel.setLayout(manager);
	panel.setBorder(BorderFactory.createTitledBorder(filterName));

	addCheckBoxes(panel);

	return createFilterPanel(panel);
}
 
源代码17 项目: binnavi   文件: AbstractScriptPanel.java
public AbstractScriptPanel(final LayoutManager layout) {
  super(layout);

  languageBox = new LanguageBox(getManager());
  languageBox.addActionListener(new InternalLanguageBoxListener());

  m_inputPane.setEditable(true);
  m_inputPane.setBackground(new Color((float) .97, (float) .97, 1));
  m_inputPane.setFont(new Font(GuiHelper.getMonospaceFont(), 0, 13));

  m_OutputPane.setDocument(m_PythonStdoutDocument);

  m_OutputPane.setEditable(false);
  m_OutputPane.setBackground(new Color((float) .97, (float) .97, 1));
  final JScrollPane inputScrollPane = new JScrollPane(m_inputPane);

  final TitledBorder inputAreaBorder =
      new TitledBorder(new LineBorder(Color.LIGHT_GRAY, 1, true), "Command Line");
  inputScrollPane.setBorder(inputAreaBorder);
  inputScrollPane.setPreferredSize(new Dimension(600, 200));

  final JScrollPane m_OutputScrollPane = new JScrollPane(m_OutputPane);

  final TitledBorder outputAreaBorder =
      new TitledBorder(new LineBorder(Color.LIGHT_GRAY, 1, true), "Output");
  m_OutputScrollPane.setBorder(outputAreaBorder);
  m_OutputScrollPane.setPreferredSize(new Dimension(600, 200));

  add(languageBox, BorderLayout.NORTH);
  add(new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, inputScrollPane, m_OutputScrollPane));

}
 
源代码18 项目: jdk8u-jdk   文件: JToolBar.java
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
源代码19 项目: jdk8u60   文件: JToolBar.java
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
源代码20 项目: openjdk-8-source   文件: JToolBar.java
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
源代码21 项目: JDKSourceCode1.8   文件: JToolBar.java
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
源代码22 项目: lizzie   文件: MainFrame.java
public String getToolBarPosition() {
  LayoutManager layout = getContentPane().getLayout();
  if (layout instanceof LizzieLayout) {
    Lizzie.config.toolbarPosition = (String) ((LizzieLayout) layout).getConstraints(toolBar);
  } else if (layout instanceof BorderLayout) {
    Lizzie.config.toolbarPosition = (String) ((BorderLayout) layout).getConstraints(toolBar);
  }
  return Lizzie.config.toolbarPosition;
}
 
源代码23 项目: snap-desktop   文件: GridBagUtils.java
/**
 * Adds a component to a panel with a grid bag layout.
 *
 * @param panel the panel to which to add the component
 * @param comp  the component to be added
 * @param gbc   the grid bag constraints to be used, can be <code>null</code> if <code>code</code> is not
 *              <code>null</code>
 */
public static void addToPanel(JPanel panel, Component comp, GridBagConstraints gbc) {
    LayoutManager layoutManager = panel.getLayout();
    if (!(layoutManager instanceof GridBagLayout)) {
        throw new IllegalArgumentException("'panel' does not have a GridBagLayout manager");
    }
    GridBagLayout gbl = (GridBagLayout) layoutManager;
    gbl.setConstraints(comp, gbc);
    panel.add(comp);
}
 
源代码24 项目: filthy-rich-clients   文件: ReflectionPanel.java
@Override
public void setLayout(LayoutManager mgr) {
    if (initialized) {
        contentPane.setLayout(mgr);
    } else {
        super.setLayout(mgr);
    }
}
 
源代码25 项目: openjdk-8   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码26 项目: jdk8u-jdk   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
源代码27 项目: brModelo   文件: Controler.java
public void PopuleBarra(JComponent obj) {
    ButtonGroup buttons = new ButtonGroup();
    Barra = obj;

    Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
    JToggleButton btn = arrume(new JToggleButton(ac));
    buttons.add(btn);
    obj.add(btn);
    btn.setSelected(true);
    ac.IDX = -1;
    this.BtnNothing = btn;
    int i = 0;
    for (ConfigAcao ca : Lista) {
        if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
            ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
            ac.IDX = i++;
            btn = arrume(new JToggleButton(ac));
            buttons.add(btn);
            //obj.add(btn);
            listaBotoes.put(ca.command, btn);
        }
    }
    menuComandos c = menuComandos.cmdDel;
    String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
    ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
    ListaDeAcoesEditaveis.add(ac);
    ac.normal = false;
    JButton btn2 = new JButton(ac);
    btn2.setHideActionText(true);
    btn2.setFocusable(false);
    btn2.setPreferredSize(new Dimension(40, 40));
    obj.add(btn2);

    LayoutManager la = obj.getLayout();
    if (la instanceof GridLayout) {
        ((GridLayout) la).setRows(i + 2);
    }
}
 
源代码28 项目: gcs   文件: DropPanel.java
/**
 * Creates a standard panel with a drop shadow.
 *
 * @param layout                  The layout to use.
 * @param title                   The title to use.
 * @param font                    The font to use for the title.
 * @param onlyReportPreferredSize Whether or not minimum and maximum size is reported as
 *                                preferred size or not.
 */
public DropPanel(LayoutManager layout, String title, Font font, boolean onlyReportPreferredSize) {
    super(layout);
    setOpaque(true);
    setBackground(Color.WHITE);
    mTitledBorder = new TitledBorder(font, title);
    setBorder(new CompoundBorder(mTitledBorder, new EmptyBorder(0, 2, 1, 2)));
    setAlignmentY(TOP_ALIGNMENT);
    mOnlyReportPreferredSize = onlyReportPreferredSize;
}
 
源代码29 项目: littleluck   文件: RoundedPanel.java
public RoundedPanel(LayoutManager layout, int cornerRadius) {
    super(layout);
    this.cornerRadius = cornerRadius;
    this.roundBounds = new RoundRectangle2D.Float(0,0,0,0,
            cornerRadius, cornerRadius);
    this.contentAreaFilled = true;
    setOpaque(false);
}
 
源代码30 项目: openjdk-jdk8u-backup   文件: MotifPopupMenuUI.java
public Dimension getPreferredSize(JComponent c) {
    LayoutManager layout = c.getLayout();
    Dimension d = layout.preferredLayoutSize(c);
    String title = ((JPopupMenu)c).getLabel();
    if (titleFont == null) {
        UIDefaults table = UIManager.getLookAndFeelDefaults();
        titleFont = table.getFont("PopupMenu.font");
    }
    FontMetrics fm = c.getFontMetrics(titleFont);
    int         stringWidth = 0;

    if (title!=null) {
        stringWidth += SwingUtilities2.stringWidth(c, fm, title);
    }

    if (d.width < stringWidth) {
        d.width = stringWidth + 8;
        Insets i = c.getInsets();
        if (i!=null) {
            d.width += i.left + i.right;
        }
        if (border != null) {
            i = border.getBorderInsets(c);
            d.width += i.left + i.right;
        }

        return d;
    }
    return null;
}
 
 类所在包
 同包方法