當前位置: 首頁>>代碼示例>>Java>>正文


Java MigPanel類代碼示例

本文整理匯總了Java中net.sf.freecol.client.gui.panel.MigPanel的典型用法代碼示例。如果您正苦於以下問題:Java MigPanel類的具體用法?Java MigPanel怎麽用?Java MigPanel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MigPanel類屬於net.sf.freecol.client.gui.panel包,在下文中一共展示了MigPanel類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AbstractUnitOptionUI

import net.sf.freecol.client.gui.panel.MigPanel; //導入依賴的package包/類
/**
 * Creates a new {@code AbstractUnitOptionUI} for the given
 * {@code AbstractUnitOption}.
 *
 * @param option The {@code AbstractUnitOption} to make a
 *     user interface for
 * @param editable boolean whether user can modify the setting
 */
public AbstractUnitOptionUI(final AbstractUnitOption option,
                            final boolean editable) {
    super(option, editable);

    this.panel = new MigPanel();
    this.panel.setLayout(new MigLayout());

    IntegerOption numberOption = option.getNumber();
    UnitTypeOption typeOption = option.getUnitType();
    StringOption roleOption = option.getRole();
    boolean numberEditable = editable
        && (numberOption.getMaximumValue() > numberOption.getMinimumValue());
    this.numberUI = new IntegerOptionUI(numberOption, numberEditable);
    Utility.localizeToolTip(this.numberUI.getComponent(), "number");
    this.panel.add(this.numberUI.getComponent(), "width 30%");

    boolean typeEditable = editable
        && typeOption.getChoices().size() > 1;
    this.typeUI = new UnitTypeOptionUI(typeOption, typeEditable);
    Utility.localizeToolTip(this.typeUI.getComponent(), "unitType");
    this.typeUI.getComponent().addItemListener(this);
    this.panel.add(this.typeUI.getComponent(), "width 35%");

    roleEditable = editable
        && roleOption.getChoices().size() > 1;
    this.roleUI = new StringOptionUI(roleOption, roleEditable);
    Utility.localizeToolTip(this.roleUI.getComponent(), "model.role.name");
    this.roleUI.getComponent().setRenderer(new RoleRenderer());
    this.panel.add(this.roleUI.getComponent(), "width 35%");

    initialize();
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:41,代碼來源:AbstractUnitOptionUI.java

示例2: OptionGroupUI

import net.sf.freecol.client.gui.panel.MigPanel; //導入依賴的package包/類
/**
 * The constructor that will add the items to this panel.
 *
 * @param gui The enclosing {@code GUI}.
 * @param group The {@code OptionGroup} encapsulate.
 * @param editable Is the group editable.
 */
public OptionGroupUI(GUI gui, OptionGroup group, boolean editable) {
    super("ReportPanelUI");

    this.gui = gui;
    this.group = group;
    this.editable = editable;

    setLayout(new MigLayout("fill", "[200:]unrelated[550:, grow, fill]",
                            "[top]"));

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(group);
    buildTree(group, root);

    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel) {
            @Override
            public Dimension getPreferredSize() {
                return new Dimension(200, super.getPreferredSize().height);
            }
            @Override
            public String convertValueToText(Object value,
                boolean selected, boolean expanded,
                boolean leaf, int row, boolean hasFocus) {
                DefaultMutableTreeNode node
                    = (DefaultMutableTreeNode)value;
                Option option = (Option)node.getUserObject();
                return Messages.getName(option.getId());
            }
        };

    tree.setOpaque(false);
    tree.addTreeSelectionListener(this);
    DefaultTreeCellRenderer renderer
        = (DefaultTreeCellRenderer)tree.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(new Color(0, 0, 0, 1));

    add(tree);
    detailPanel = new MigPanel();
    detailPanel.setLayout(new MigLayout("wrap 2", "[fill]related[fill]"));
    detailPanel.setOpaque(false);
    add(detailPanel, "grow");
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:50,代碼來源:OptionGroupUI.java


注:本文中的net.sf.freecol.client.gui.panel.MigPanel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。