当前位置: 首页>>代码示例>>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;未经允许,请勿转载。