Java net.miginfocom.swing.MigLayout 代码实例

・1 分钟阅读

以下是展示如何使用net.miginfocom.swing.MigLayout的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀示例。

实例 1


private void refreshFrontEnd() {
    squeezeBoxPanel.cleanPanels();
    for (StatisticsCategory category : categories) {
        //Find uis in this category
        List<UIFrontEnd> uis = new ArrayList<UIFrontEnd>();
        for (UIFrontEnd uife : frontEnds) {
            if (uife.getCategory().equals(category) && uife.isVisible()) {
                uis.add(uife);
            }
        }
        if (uis.size() > 0) {
            //Sort it by position
            Collections.sort(uis, new Comparator() {
                public int compare(Object o1, Object o2) {
                    Integer p1 = ((UIFrontEnd) o1).getStatisticsUI().getPosition();
                    Integer p2 = ((UIFrontEnd) o2).getStatisticsUI().getPosition();
                    return p1.compareTo(p2);
                }
            });
            MigLayout migLayout = new MigLayout("insets 0");
            migLayout.setColumnConstraints("[grow,fill]");
            migLayout.setRowConstraints("[pref!]");
            JPanel innerPanel = new JPanel(migLayout);
            for (UIFrontEnd sui : uis) {
                innerPanel.add(sui.frontEnd, "wrap");
            }
            squeezeBoxPanel.addPanel(innerPanel, category.getName());
        }
    }
}
 

实例 2


private void refreshFrontEnd() {
    squeezeBoxPanel.cleanPanels();
    for (StatisticsCategory category : categories) {
        //Find uis in this category
        List<UIFrontEnd> uis = new ArrayList<UIFrontEnd>();
        for (UIFrontEnd uife : frontEnds) {
            if (uife.getCategory().equals(category) && uife.isVisible()) {
                uis.add(uife);
            }
        }
        if (uis.size() > 0) {
            //Sort it by position
            Collections.sort(uis, new Comparator() {
                public int compare(Object o1, Object o2) {
                    Integer p1 = ((UIFrontEnd) o1).getStatisticsUI().getPosition();
                    Integer p2 = ((UIFrontEnd) o2).getStatisticsUI().getPosition();
                    return p1.compareTo(p2);
                }
            });
            MigLayout migLayout = new MigLayout("insets 0");
            migLayout.setColumnConstraints("[grow,fill]");
            migLayout.setRowConstraints("[pref!]");
            JPanel innerPanel = new JPanel(migLayout);
            for (UIFrontEnd sui : uis) {
                innerPanel.add(sui.frontEnd, "wrap");
            }
            squeezeBoxPanel.addPanel(innerPanel, category.getName());
        }
    }
}
 

实例 3


private void refreshFrontEnd() {
    squeezeBoxPanel.cleanPanels();
    for (StatisticsCategory category : categories) {
        //Find uis in this category
        List<UIFrontEnd> uis = new ArrayList<UIFrontEnd>();
        for (UIFrontEnd uife : frontEnds) {
            if (uife.getCategory().equals(category) && uife.isVisible()) {
                uis.add(uife);
            }
        }
        if (uis.size() > 0) {
            //Sort it by position
            Collections.sort(uis, new Comparator() {
                public int compare(Object o1, Object o2) {
                    Integer p1 = ((UIFrontEnd) o1).getStatisticsUI().getPosition();
                    Integer p2 = ((UIFrontEnd) o2).getStatisticsUI().getPosition();
                    return p1.compareTo(p2);
                }
            });
            MigLayout migLayout = new MigLayout("insets 0");
            migLayout.setColumnConstraints("[grow,fill]");
            migLayout.setRowConstraints("[pref!]");
            JPanel innerPanel = new JPanel(migLayout);
            for (UIFrontEnd sui : uis) {
                innerPanel.add(sui.frontEnd, "wrap");
            }
            squeezeBoxPanel.addPanel(innerPanel, category.getName());
        }
    }
}
 
讨论
淘淘あ西西 profile image