private static Component createDescription(Example example, ExampleGroup group) { Color foreground = group.getPreferredForeground(); WebLabel titleLabel = new WebLabel(example.getTitle(), JLabel.TRAILING); titleLabel.setDrawShade(true); titleLabel.setForeground(foreground); if (foreground.equals(Color.WHITE)) { titleLabel.setShadeColor(Color.BLACK); } if (example.getDescription() == null) { return titleLabel; } else { WebLabel descriptionLabel = new WebLabel(example.getDescription(), WebLabel.TRAILING); descriptionLabel.setForeground(Color.GRAY); SwingUtils.changeFontSize(descriptionLabel, -1); WebPanel vertical = new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, 0, 0, true, false)); vertical.setOpaque(false); vertical.add(titleLabel); vertical.add(descriptionLabel); return vertical; } }
public static WebTabbedPane createExampleTabs(WebLookAndFeelDemo owner, WebProgressDialog load) { // All example groups load.setText("Loading groups list"); List<ExampleGroup> exampleGroups = getExampleGroups(); load.setMinimum(0); load.setMaximum(exampleGroups.size() + 1); load.setProgress(0); // Example tabs WebTabbedPane exampleTabs = new WebTabbedPane(); exampleTabs.setTabbedPaneStyle(TabbedPaneStyle.attached); // exampleTabs.setTabLayoutPolicy ( WebTabbedPane.SCROLL_TAB_LAYOUT ); // Progress component IconProgress ip = (IconProgress) load.getMiddleComponent(); // Creating all examples int progress = 1; for (ExampleGroup group : exampleGroups) { // Updating progress state load.setText("Loading group: " + group.getGroupName()); load.setProgress(progress); progress++; // Updating progress icons Icon gi = group.getGroupIcon(); ip.addLoadedElement(gi); // Adding group view to new tab exampleTabs.addTab(group.getGroupName(), gi, createGroupView(owner, group)); // Applying foreground settings exampleTabs.setSelectedForegroundAt( exampleTabs.getTabCount() - 1, group.getPreferredForeground()); // Applying specific group settings to tab group.modifyExampleTab(exampleTabs.getTabCount() - 1, exampleTabs); } load.setProgress(progress); return exampleTabs; }