private static SynthContext getSynthContext () { try { JButton dummyButton = getDummyButton(); ButtonUI bui = dummyButton.getUI(); if (bui instanceof SynthUI) { return ((SynthUI) bui).getContext(dummyButton); } else { throw new IllegalStateException ("I don't have a SynthButtonUI to play with"); //NOI18N } } catch (Exception e) { functioning = Boolean.FALSE; if (log) { e.printStackTrace(); } return null; } }
private static WindowsMenuItemUIAccessor getAccessor( JMenuItem menuItem) { WindowsMenuItemUIAccessor rv = null; ButtonUI uiObject = (menuItem != null) ? menuItem.getUI() : null; if (uiObject instanceof WindowsMenuItemUI) { rv = ((WindowsMenuItemUI) uiObject).accessor; } else if (uiObject instanceof WindowsMenuUI) { rv = ((WindowsMenuUI) uiObject).accessor; } else if (uiObject instanceof WindowsCheckBoxMenuItemUI) { rv = ((WindowsCheckBoxMenuItemUI) uiObject).accessor; } else if (uiObject instanceof WindowsRadioButtonMenuItemUI) { rv = ((WindowsRadioButtonMenuItemUI) uiObject).accessor; } return rv; }
public void actionPerformed(ActionEvent e) { AbstractButton button = (AbstractButton)e.getSource(); ButtonUI ui = button.getUI(); if(ui instanceof FilledButtonUI) { FilledButtonUI fui = (FilledButtonUI)ui; List<PaintUIEffect> effects = fui.getEffects(button); boolean hasZoom = false; for(int a = 0; a<effects.size(); a++) { PaintUIEffect effect = effects.get(a); if(effect instanceof ZoomIconPaintUIEffect && effect.getComponent()==button) hasZoom = true; } if(!hasZoom) effects.add(new ZoomIconPaintUIEffect(button)); } }
/** Kill the effects if the user moused over the component * really quickly. */ @Override public void mouseExited(MouseEvent e) { AbstractButton button = (AbstractButton)e.getSource(); ButtonUI ui = button.getUI(); if(ui instanceof FilledButtonUI) { FilledButtonUI fui = (FilledButtonUI)ui; List<PaintUIEffect> list = fui.getEffects(button); int ctr = 0; while(ctr<list.size()) { PaintUIEffect effect = list.get(ctr); if(effect instanceof ShimmerPaintUIEffect && effect.getProgress()<.2f && effect.getComponent()==button) { list.remove(ctr); } else { ctr++; } } } }
/** * Sets given icon to display between checkbox icon and text. * * @return true in case of success and false otherwise */ public boolean setTextIcon(@NotNull Icon icon) { if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) { return false; } ButtonUI ui = getUI(); if (ui instanceof BasicRadioButtonUI) { Icon defaultIcon = ((BasicRadioButtonUI) ui).getDefaultIcon(); if (defaultIcon != null) { MergedIcon mergedIcon = new MergedIcon(defaultIcon, 10, icon); setIcon(mergedIcon); return true; } } return false; }
public void configure(AbstractButton button, AbstractCommand command, CommandFaceDescriptor faceDescriptor) { Assert.notNull(button, "The button to configure cannot be null."); Assert.notNull(faceDescriptor, "The command face descriptor cannot be null."); if (StringUtils.hasText(faceDescriptor.getDescription())) button.setText(faceDescriptor.getDescription()); else button.setText(faceDescriptor.getText()); button.setToolTipText(faceDescriptor.getCaption()); if (faceDescriptor.getLargeIcon() != null) faceDescriptor.configureIconInfo(button, true); else faceDescriptor.configureIcon(button); try { button.setUI((ButtonUI) Class.forName((String) UIManager.get("LinkButtonUI")).newInstance()); } catch (Exception e) { } }
@Nonnull @RequiredDispatchThread public TabInfo addTab(@Nonnull String tabName, @Nonnull JComponent component, @Nullable JComponent preferredFocusableComponent) { StaticAnchoredButton button = new StaticAnchoredButton(tabName, ToolWindowAnchor.LEFT); button.addItemListener(myItemListener); button.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); button.setBackground(new Color(247, 243, 239)); button.setUI((ButtonUI)DesktopStripeButtonUI.createUI(button)); myTabPanel.add(button); TabInfo tabInfo = new TabInfo(button, component, preferredFocusableComponent); button.putClientProperty(TabInfo.class, tabInfo); myButtonGroup.add(button); myContentPanel.add(component, tabName); if(myButtonGroup.getSelection() == null) { tabInfo.select(); } return tabInfo; }
@Override public void updateUI () { SlidingTabDisplayerButtonUI ui = null; try { ui = (SlidingTabDisplayerButtonUI) UIManager.getUI(this); setUI (ui); return; } catch (Error e) { System.err.println ("Error getting sliding button UI: " + e.getMessage()); } catch (Exception ex) { System.err.println ("Exception getting button UI: " + ex.getMessage()); } setUI ((ButtonUI) SlidingTabDisplayerButtonUI.createUI(this)); }
/** * Maps {@code AbstractButton.getUI()} through queue */ public ButtonUI getUI() { return (runMapping(new MapAction<ButtonUI>("getUI") { @Override public ButtonUI map() { return ((AbstractButton) getSource()).getUI(); } })); }
/** * Maps {@code AbstractButton.setUI(ButtonUI)} through queue */ public void setUI(final ButtonUI buttonUI) { runMapping(new MapVoidAction("setUI") { @Override public void map() { ((AbstractButton) getSource()).setUI(buttonUI); } }); }
void addTab(JOutlookBar tabs, String title) { JPanel panel = new JPanel(); panel.setLayout(new PercentLayout(PercentLayout.VERTICAL, 0)); panel.setOpaque(false); String[] buttons = new String[] {"Inbox", "icons/outlook-inbox.gif", "Outbox", "icons/outlook-outbox.gif", "Drafts", "icons/outlook-inbox.gif", "Templates", "icons/outlook-inbox.gif", "Deleted Items", "icons/outlook-trash.gif",}; for (int i = 0, c = buttons.length; i < c; i += 2) { JButton button = new JButton(buttons[i]); try { button.setUI((ButtonUI)Class.forName( (String)UIManager.get("OutlookButtonUI")).newInstance()); } catch (Exception e) { e.printStackTrace(); } button.setIcon(new ImageIcon(OutlookBarMain.class .getResource(buttons[i + 1]))); panel.add(button); } JScrollPane scroll = tabs.makeScrollPane(panel); tabs.addTab("", scroll); // this to test the UI gets notified of changes int index = tabs.indexOfComponent(scroll); tabs.setTitleAt(index, title); tabs.setToolTipTextAt(index, title + " Tooltip"); }
public XPDirectoryControls(LocationPaneUI paneUI) { super(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 0; add(paneUI.comboBox, c); c.gridx++; add(paneUI.backButton, c); c.gridx++; add(paneUI.upButton, c); c.gridx++; add(paneUI.newFolderButton, c); c.gridx++; add(listButton); JPanel fluff = new JPanel(); fluff.setOpaque(false); c.gridx++; c.weightx = 1; add(fluff, c); Dimension d = paneUI.comboBox.getPreferredSize(); d.width = 525; paneUI.comboBox.setPreferredSize(d); paneUI.backButton.setIcon(BACK_ICON); paneUI.upButton.setIcon(UP_ICON); paneUI.newFolderButton.setIcon(NEW_FOLDER_ICON); paneUI.backButton.setText(""); paneUI.upButton.setText(""); paneUI.newFolderButton.setText(""); listButton.setText(""); ButtonUI ui = new XPSubtleButtonUI(); paneUI.backButton.setUI(ui); paneUI.upButton.setUI(ui); paneUI.newFolderButton.setUI(ui); listButton.setUI(ui); }
/** Sets the ButtonUI for all the non-checkbox buttons * in this search bar. * @param ui the button UI to use for all non-checkbox buttons. */ public void setButtonUI(ButtonUI ui) { for(int a = 0; a<getComponentCount(); a++) { if(getComponent(a) instanceof JButton) { ((JButton)getComponent(a)).setUI(ui); } else if(getComponent(a) instanceof JCheckBox) { //do nothing } else if(getComponent(a) instanceof JToggleButton) { ((JToggleButton)getComponent(a)).setUI(ui); } } updateLayout(); //must update the UI of the close button correctly }
/** A new shimmer to the effects list. */ @Override public void mouseEntered(MouseEvent e) { AbstractButton button = (AbstractButton)e.getSource(); ButtonUI ui = button.getUI(); if(ui instanceof FilledButtonUI) { FilledButtonUI fui = (FilledButtonUI)ui; fui.getEffects(button).add(new ShimmerPaintUIEffect(button)); } }
/** * This method resets the radio button's UI delegate to the default UI for * the current look and feel. */ public void updateUI() { /* I can't see any difference between this and the superclass one, but Sun reimplements it... there is no RadioButtonUI class for it to be cast to. */ setUI((ButtonUI) UIManager.getUI(this)); }
@Override public void setUI(ButtonUI ui) { if (ui instanceof StickyButtonUI) { super.setUI(ui); } else { super.setUI(createUI()); } }
@Override public void setUI(final ButtonUI ui) { super.setUI(ui); setBorder(BorderFactory.createEmptyBorder()); setHorizontalTextPosition(SwingConstants.CENTER); setVerticalAlignment(SwingConstants.CENTER); setMargin(ZERO_INSETS); setFocusPainted(false); putClientProperty("Plastic.is3D", Boolean.FALSE); updateUIFromType(); }
/** * Set the indicated JComponent to transparent or not transparent. * * @return true iff this call has changed the state */ protected static boolean setTransparent(JComponent child, boolean t) { boolean ret = false; if (child instanceof JPanel) { child.setOpaque(!t); ret |= child.isOpaque() == t; } if (child instanceof JToolBar) { child.setOpaque(!t); ret |= child.isOpaque() == t; } if (child instanceof AbstractButton) { AbstractButton b = (AbstractButton) child; if (t) { if (!(b.getUI() instanceof TransparentButtonUI)) { b.setContentAreaFilled(false); b.setUI((ButtonUI) TransparentButtonUI.createUI(b)); ret = true; } } else { if (b.getUI() instanceof TransparentButtonUI) { b.setContentAreaFilled(true); b.setUI((ButtonUI) UIManager.getUI(b)); ret = true; } } } for (int i = 0; i < child.getComponentCount(); i++) { Object o = child.getComponent(i); if (o instanceof JComponent) { JComponent c = (JComponent) o; ret |= setTransparent(c, t); } } return ret; }
@Override public void testUpdateUI() { ButtonUI ui = new ButtonUI() { }; jbutton.setUI(ui); assertEquals(ui, jbutton.getUI()); jbutton.updateUI(); assertNotSame(ui, jbutton.getUI()); }
public void testUpdateUI() { ButtonUI ui = new ButtonUI() { }; button.setUI(ui); assertEquals(ui, button.getUI()); button.updateUI(); assertNotSame(ui, button.getUI()); }