@Override public void setBackgroundAt(int index, Color background) { super.setBackgroundAt(index, background); final Component comp = getTabComponentAt(index); if (comp instanceof TabComponent) ((TabComponent) comp).setBackgroundAll(background); }
public void propertyChange(PropertyChangeEvent e) { if (e.getSource() instanceof PanelThreadMonitor) { if (e.getPropertyName().equals("Status")) { PanelThreadMonitor mntTmp = (PanelThreadMonitor) e.getSource(); int iMonitorIndex = pnlThread.indexOfComponent(mntTmp); if (iMonitorIndex >= 0) { if (e.getNewValue().equals("Started")) { if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(COLOR_STARTED)) { pnlThread.setBackgroundAt(iMonitorIndex, COLOR_STARTED); pnlThread.setForegroundAt(iMonitorIndex, COLOR_STARTED_FG); } } else if (e.getNewValue().equals("Stopped")) { if (!pnlThread.getBackgroundAt(iMonitorIndex).equals(SystemColor.controlShadow)) { pnlThread.setBackgroundAt(iMonitorIndex, UIManager.getColor("TabbedPane.background")); pnlThread.setForegroundAt(iMonitorIndex, SystemColor.textText); } } } } } }
private static void setupTabbedPane(JTabbedPane tabbedPane) { // Simple tab tabbedPane.addTab("Normal 1", new WebLabel()); // Disabled tab tabbedPane.addTab("Disabled 2", new WebLabel()); tabbedPane.setEnabledAt(1, false); // Selected tab tabbedPane.addTab("Selected 3", new WebLabel()); tabbedPane.setSelectedIndex(2); // Colored tab tabbedPane.addTab("Colored 4", new WebLabel()); tabbedPane.setBackgroundAt(3, new Color(255, 212, 161)); }
public static void createTabItem(ActionContext actionContext) { Thing self = (Thing) actionContext.get("self"); JTabbedPane parent = (JTabbedPane) actionContext.get("parent"); Thing thing = self.getThing("Component@0"); if (thing != null) { try { Bindings bindings = actionContext.push(); bindings.put("parent", null); for (Thing child : thing.getChilds()) { Component c = (Component) child.doAction("create", actionContext); if (c != null) { int index = parent.getTabCount(); parent.setComponentAt(index, c); Color background = AwtCreator.createColor(thing, "background", actionContext); if (background != null) { parent.setBackgroundAt(index, background); } Icon disabledIcon = SwingCreator.createIcon(thing, "disabledIcon", actionContext); if (disabledIcon != null) { parent.setDisabledIconAt(index, disabledIcon); } Integer displayedMnemonicIndex = JavaCreator.createInteger(thing, "displayedMnemonicIndex"); if (displayedMnemonicIndex != null) { parent.setDisplayedMnemonicIndexAt(index, displayedMnemonicIndex); } Boolean enabled = JavaCreator.createBoolean(thing, "enabled"); if (enabled != null) { parent.setEnabledAt(index, enabled); } Color foreground = AwtCreator.createColor(thing, "foreground", actionContext); if (foreground != null) { parent.setForeground(foreground); } Icon icon = SwingCreator.createIcon(thing, "icon", actionContext); if (icon != null) { parent.setIconAt(index, icon); } Integer mnemonic = AwtCreator.createMnemonic(thing, "mnemonic"); if (mnemonic != null) { parent.setMnemonicAt(index, mnemonic); } Boolean selected = JavaCreator.createBoolean(thing, "selected"); if (selected != null && selected) { parent.setSelectedIndex(index); } String title = JavaCreator.createText(thing, "title", actionContext); if (title != null) { parent.setTitleAt(index, title); } String toolTipText = JavaCreator.createText(thing, "toolTipText", actionContext); if (toolTipText != null) { parent.setToolTipTextAt(index, toolTipText); } break; } } } finally { actionContext.pop(); } } }