@Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); String pp = getPropertyPrefix(); // b.setOpaque(QuaquaManager.getBoolean(pp+"opaque")); QuaquaUtilities.installProperty(b, "opaque", UIManager.get(pp + "opaque")); b.setRequestFocusEnabled(UIManager.getBoolean(pp + "requestFocusEnabled")); b.setFocusable(UIManager.getBoolean(pp + "focusable")); }
protected void installDefaults(JFileChooser fc) { installIcons(fc); installStrings(fc); usesSingleFilePane = UIManager.getBoolean("FileChooser.usesSingleFilePane"); readOnly = UIManager.getBoolean("FileChooser.readOnly"); TransferHandler th = fc.getTransferHandler(); if (th == null || th instanceof UIResource) { fc.setTransferHandler(defaultTransferHandler); } LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE); }
@Override public void addNotify() { super.addNotify(); if (UIManager.getBoolean("Sheet.showAsSheet") && !isExperimentalSheet()) { QuaquaUtilities.setWindowAlpha(this, 240); } }
public void focusGained(FocusEvent event) { QuaquaUtilities.repaintBorder((JComponent) event.getComponent()); final JTextComponent tc = (JTextComponent) event.getSource(); if (tc.isEditable() && tc.isEnabled()) { String uiProperty; if (tc instanceof JPasswordField) { uiProperty = "PasswordField.autoSelect"; } else if (tc instanceof JFormattedTextField) { uiProperty = "FormattedTextField.autoSelect"; } else { uiProperty = "TextField.autoSelect"; } if (tc.getClientProperty("Quaqua.TextComponent.autoSelect") == Boolean.TRUE || tc.getClientProperty("Quaqua.TextComponent.autoSelect") == null && UIManager.getBoolean(uiProperty)) { if (event instanceof CausedFocusEvent) { CausedFocusEvent cfEvent = (CausedFocusEvent) event; if (cfEvent.getCause() == Cause.TRAVERSAL_FORWARD || cfEvent.getCause() == Cause.TRAVERSAL_BACKWARD) { tc.selectAll(); } } } } if (KeyboardFocusManager.getCurrentKeyboardFocusManager() instanceof QuaquaKeyboardFocusManager) { QuaquaKeyboardFocusManager kfm = (QuaquaKeyboardFocusManager) KeyboardFocusManager.getCurrentKeyboardFocusManager(); kfm.setLastKeyboardTraversingComponent(null); } }
private void init() { isExperimentalSheet = UIManager.getBoolean("Sheet.experimentalSheet"); if (getOwner() != null && isShowAsSheet()) { if (isNativeSheetSupported()) { // J2SE 7 requires that we set undecorated to true. setUndecorated(true); getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE); } else if (isExperimentalSheet()) { setUndecorated(true); } else { setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.NONE); getRootPane().setBorder(UIManager.getBorder("Sheet.border")); } if (isDocumentModalitySupported()) { Methods.invokeIfExistsWithEnum( this, "setModalityType", "java.awt.Dialog$ModalityType", "DOCUMENT_MODAL"); } } // We move the sheet when the user moves the owner, so that it // will always stay centered below the title bar of the owner. // If the user has moved the owner, we 'forget' the shift back location, // and don't shift the owner back to the place it was, when we opened // the sheet. ownerMovementHandler = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent evt) { Window owner = getOwner(); Point newLocation = owner.getLocation(); if (!newLocation.equals(oldLocation)) { setLocation( newLocation.x + (owner.getWidth() - getWidth()) / 2, newLocation.y + owner.getInsets().top); shiftBackLocation = null; oldLocation = newLocation; } } }; // If the sheet is experimental, we need some special handling // so that the JSheet is handled correctly windowEventHandler = new WindowAdapter() { // public void windowIconified(WindowEvent e) { // TODO The sheet is reshown when the parent window is iconified. // setVisible(false) on the sheet only deiconifies the owner window. // } @Override public void windowActivated(WindowEvent e) { if (JSheet.this.isVisible() && JSheet.this.getOwner() == e.getWindow()) JSheet.this.toFront(); } }; }
@Override public void setPopupVisible(boolean visible) { if (!isSwingPopup()) { if (visible && (myJBPopup == null || myJBPopup.isDisposed())) { final JBList list = createJBList(getModel()); myJBPopup = JBPopupFactory.getInstance() .createListPopupBuilder(list) .setItemChoosenCallback( new Runnable() { @Override public void run() { final Object value = list.getSelectedValue(); if (value != null) { configureEditor(getEditor(), value); IdeFocusManager.getGlobalInstance().requestFocus(ComboBox.this, true); assert myJBPopup != null; ComboBox.this.getUI().setPopupVisible(ComboBox.this, false); myJBPopup.cancel(); } } }) .setFocusOwners(new Component[] {this}) .setMinSize(new Dimension(getWidth(), -1)) .createPopup(); list.setBorder(IdeBorderFactory.createEmptyBorder()); myJBPopup.showUnderneathOf(this); list.addFocusListener( new FocusAdapter() { @Override public void focusLost(FocusEvent e) { ComboBox.this.getUI().setPopupVisible(ComboBox.this, false); myJBPopup.cancel(); } }); } return; } if (getModel().getSize() == 0 && visible) return; if (visible && JBPopupFactory.getInstance().getChildFocusedPopup(this) != null) return; final boolean wasShown = isPopupVisible(); super.setPopupVisible(visible); if (!wasShown && visible && isEditable() && !UIManager.getBoolean("ComboBox.isEnterSelectablePopup")) { final ComboBoxEditor editor = getEditor(); final Object item = editor.getItem(); final Object selectedItem = getSelectedItem(); if (isSwingPopup() && (item == null || item != selectedItem)) { configureEditor(editor, selectedItem); } } }
protected void installListeners() { super.installListeners(); handler = new AquaFocusHandler(); final JTextComponent c = getComponent(); c.addFocusListener(handler); c.addPropertyChangeListener(handler); LookAndFeel.installProperty(c, "opaque", UIManager.getBoolean(getPropertyPrefix() + "opaque")); AquaUtilControlSize.addSizePropertyListener(c); AquaTextFieldSearch.installSearchFieldListener(c); }
/** {@inheritDoc} */ @Override protected void installListeners(JScrollPane c) { super.installListeners(c); c.addPropertyChangeListener(this); if (UIManager.getBoolean("ScrollPane.useChildTextComponentFocus")) { viewportViewFocusHandler = new ViewportViewFocusHandler(); c.getViewport().addContainerListener(viewportViewFocusHandler); Component view = c.getViewport().getView(); if (view instanceof JTextComponent) { view.addFocusListener(viewportViewFocusHandler); } } }
/** Adds a new group to our tree and element model. */ final void addNewGroup() { DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel(); boolean groupSummaryVisibleByDefault = UIManager.getBoolean(GROUP_SUMMARY_VISIBLE_DEFAULT); boolean scopeVisibleByDefault = UIManager.getBoolean(ANALOG_SCOPE_VISIBLE_DEFAULT); int groupCount = this.model.getGroups().size(); String name = String.format("Group %d", Integer.valueOf(groupCount + 1)); // Create model structure... ElementGroup newGroup = this.model.addGroup(name); newGroup.setVisible(true); SignalElement groupSummaryElement = SignalElement.createGroupSummaryElement(newGroup); groupSummaryElement.setEnabled(groupSummaryVisibleByDefault); newGroup.addElement(groupSummaryElement); SignalElement analogScopeElement = SignalElement.createAnalogScopeElement(newGroup); analogScopeElement.setEnabled(scopeVisibleByDefault); newGroup.addElement(analogScopeElement); // Create tree structure... ElementTreeNode rootNode = (ElementTreeNode) model.getRoot(); ElementTreeNode groupNode = new ElementTreeNode(newGroup); rootNode.add(groupNode); groupNode.add(new ElementTreeNode(groupSummaryElement)); groupNode.add(new ElementTreeNode(analogScopeElement)); int index = rootNode.getIndex(groupNode); model.nodesWereInserted(rootNode, new int[] {index}); model.nodeStructureChanged(groupNode); this.tree.expandRow(index); }
/** {@inheritDoc} */ public void setArmed(boolean b) { if (isMenuItem() && UIManager.getBoolean("MenuItem.disabledAreNavigable")) { if ((isArmed() == b)) { return; } } else { if ((isArmed() == b) || !isEnabled()) { return; } } if (b) { stateMask |= ARMED; } else { stateMask &= ~ARMED; } fireStateChanged(); }
private boolean showDialog(Component root, String title, boolean decorated) { if (dialog != null) { throw new IllegalStateException("Dialog already exists"); } dialog = Util.newJDialog(root, title, modal); if (!decorated) { dialog.setUndecorated(true); } JRootPane rootPane = dialog.getRootPane(); JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // Do this to reorder buttons so "cancel" and "ok" are last! // For Windows L&F, cancel button is on the right. For Nimbus // check the "isYesLast" option. boolean cancelonright = Util.isLAFWindows() || !UIManager.getBoolean("OptionPane.isYesLast"); if (actions.containsKey("cancel") && !cancelonright) { actions.put("cancel", actions.remove("cancel")); } if (actions.containsKey("ok")) { actions.put("ok", actions.remove("ok")); } if (actions.containsKey("cancel") && cancelonright) { actions.put("cancel", actions.remove("cancel")); } for (Iterator<Map.Entry<String, Action>> i = actions.entrySet().iterator(); i.hasNext(); ) { Map.Entry<String, Action> e = i.next(); String name = e.getKey(); Action action = e.getValue(); rootPane.getActionMap().put(name, action); buttonpanel.add(new JButton(action)); for (Iterator<Map.Entry<KeyStroke, String>> j = keystrokes.entrySet().iterator(); j.hasNext(); ) { Map.Entry<KeyStroke, String> e2 = j.next(); if (e2.getValue().equals(name)) { rootPane .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(e2.getKey(), e2.getValue()); } } } GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = gbc.REMAINDER; gbc.anchor = gbc.EAST; gbc.weighty = 0.01; add(buttonpanel, gbc); dialog.setContentPane(this); dialog.setResizable(true); dialog.pack(); dialog.setLocationRelativeTo(root); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { if (actions.containsKey("cancel")) { cancelDialog(); } else { acceptDialog(); } } }); dialog.setVisible(true); return response; }
/** Constructs a new instance. */ public MetalSliderUI() { super(null); filledSlider = UIManager.getBoolean(SLIDER_FILL); darkShadowColor = MetalLookAndFeel.getControlDarkShadow(); highlightColor = MetalLookAndFeel.getControlHighlight(); }
protected boolean isShowAsSheet() { return UIManager.getBoolean("Sheet.showAsSheet"); }