List of usage examples for javax.swing SwingUtilities updateComponentTreeUI
public static void updateComponentTreeUI(Component c)
updateUI()
-- that is, to initialize its UI property with the current look and feel. From source file:com.stefanbrenner.droplet.ui.DevicePanel.java
/** * Create the panel.//from w w w .j a va2 s . c o m */ public DevicePanel(final JComponent parent, final IDroplet droplet, final T device) { this.parent = parent; setDevice(device); setLayout(new BorderLayout(0, 5)); setBorder(BorderFactory.createLineBorder(Color.BLACK)); setBackground(DropletColors.getBackgroundColor(device)); BeanAdapter<T> adapter = new BeanAdapter<T>(device, true); // device name textfield txtName = BasicComponentFactory.createTextField(adapter.getValueModel(IDevice.PROPERTY_NAME)); txtName.setHorizontalAlignment(SwingConstants.CENTER); txtName.setColumns(1); txtName.setToolTipText(device.getName()); adapter.addBeanPropertyChangeListener(IDevice.PROPERTY_NAME, new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent event) { txtName.setToolTipText(device.getName()); } }); add(txtName, BorderLayout.NORTH); // actions panel with scroll pane actionsPanel = new JPanel(); actionsPanel.setLayout(new BoxLayout(actionsPanel, BoxLayout.Y_AXIS)); actionsPanel.setBackground(getBackground()); JScrollPane scrollPane = new JScrollPane(actionsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // resize vertical scrollbar scrollPane.getVerticalScrollBar().putClientProperty("JComponent.sizeVariant", "mini"); //$NON-NLS-1$ //$NON-NLS-2$ SwingUtilities.updateComponentTreeUI(scrollPane); // we need no border scrollPane.setBorder(BorderFactory.createEmptyBorder()); add(scrollPane, BorderLayout.CENTER); { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); createAddButton(panel); // remove button JButton btnRemove = new JButton(Messages.getString("ActionDevicePanel.removeDevice")); //$NON-NLS-1$ btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent action) { int retVal = JOptionPane.showConfirmDialog(DevicePanel.this, Messages.getString("ActionDevicePanel.removeDevice") + " '" + device.getName() + "'?", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ StringUtils.EMPTY, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (retVal == JOptionPane.YES_OPTION) { droplet.removeDevice(device); } } }); btnRemove.setFocusable(false); panel.add(btnRemove); add(panel, BorderLayout.SOUTH); } }
From source file:com.alvermont.terraj.util.ui.LookAndFeelUtils.java
/** * Change the look and feel to either the native one or the cross * platform Java one//from w ww .ja v a2s . c o m * * @param wantSystem If <pre>true</pre> then we are selecting the native * look and feel * @param topLevel The top level component for the main frame * @return <pre>true</pre> if the look and feel was successfully changed */ public boolean setSystemLookAndFeel(boolean wantSystem, Window topLevel) { boolean ok = true; try { if (wantSystem) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } SwingUtilities.updateComponentTreeUI(topLevel); topLevel.pack(); final LookAndFeelChangedEvent event = new LookAndFeelChangedEvent(this); fireLookAndFeelChangedEventListenerHandleLookAndFeelChangedEvent(event); } catch (UnsupportedLookAndFeelException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (ClassNotFoundException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (IllegalAccessException ex) { log.error("Failed to set LAF", ex); ok = false; } catch (InstantiationException ex) { log.error("Failed to set LAF", ex); ok = false; } return ok; }
From source file:ShowComponent.java
/** * This static method queries the system to find out what Pluggable * Look-and-Feel (PLAF) implementations are available. Then it creates a * JMenu component that lists each of the implementations by name and allows * the user to select one of them using JRadioButtonMenuItem components. * When the user selects one, the selected menu item traverses the component * hierarchy and tells all components to use the new PLAF. *//* www. ja va 2 s. c o m*/ public static JMenu createPlafMenu(final JFrame frame) { // Create the menu JMenu plafmenu = new JMenu("Look and Feel"); // Create an object used for radio button mutual exclusion ButtonGroup radiogroup = new ButtonGroup(); // Look up the available look and feels UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); // Loop through the plafs, and add a menu item for each one for (int i = 0; i < plafs.length; i++) { String plafName = plafs[i].getName(); final String plafClassName = plafs[i].getClassName(); // Create the menu item JMenuItem item = plafmenu.add(new JRadioButtonMenuItem(plafName)); // Tell the menu item what to do when it is selected item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Set the new look and feel UIManager.setLookAndFeel(plafClassName); // Tell each component to change its look-and-feel SwingUtilities.updateComponentTreeUI(frame); // Tell the frame to resize itself to the its // children's new desired sizes frame.pack(); } catch (Exception ex) { System.err.println(ex); } } }); // Only allow one menu item to be selected at once radiogroup.add(item); } return plafmenu; }
From source file:fxts.stations.util.preferences.PreferencesManager.java
public void showPreferencesDialog() { init();/*from w w w . j ava 2 s . c o m*/ SwingUtilities.updateComponentTreeUI(mDialogPanel); PreferencesDialog dlg = new PreferencesDialog(TradeApp.getInst().getMainFrame(), mDialogPanel, mUserName); dlg.showModal(); }
From source file:eu.europa.ec.markt.dss.applet.SignatureApplet.java
@Override public void init() { String lang = getParameter("lang"); if ("nl".equals(lang)) { java.util.Locale.setDefault(new java.util.Locale("nl", "NL")); } else {//from w w w.java2 s . com java.util.Locale.setDefault(new java.util.Locale("en", "EN")); } BACK_TEXT = getResourceString("BACK"); NEXT_TEXT = getResourceString("NEXT"); FINISH_TEXT = getResourceString("FINISH"); CANCEL_TEXT = getResourceString("CANCEL"); super.init(); model.setServiceUrl(getParameter("serviceUrl")); if (getParameter("pkcs12File") != null) { model.setPkcs12FilePath(getParameter("pkcs12File")); } if (getParameter("pkcs11Library") != null) { model.setPkcs11LibraryPath(getParameter("pkcs11Library")); } if (getParameter(PRECONFIGURED_TOKEN_TYPE) != null) { SignatureTokenType type = SignatureTokenType.valueOf(getParameter(PRECONFIGURED_TOKEN_TYPE)); model.setTokenType(type); model.setPreconfiguredTokenType(true); } if (getParameter(SIGNATURE_POLICY) != null) { String value = getParameter(SIGNATURE_POLICY); if (SignaturePolicy.IMPLICIT.equals(value)) { model.setSignaturePolicyType(SignaturePolicy.IMPLICIT); } else { model.setSignaturePolicyType(SignaturePolicy.EXPLICIT); model.setSignaturePolicy(value); model.setSignaturePolicyAlgo(getParameter(SIGNATURE_POLICY_ALGO)); model.setSignaturePolicyValue(Base64.decodeBase64(getParameter(SIGNATURE_POLICY_HASH))); } } if (getParameter(STRICT_RFC3370) != null) { String value = getParameter(STRICT_RFC3370); try { model.setStrictRFC3370Compliance(Boolean.parseBoolean(value)); } catch (Exception ex) { LOG.warning( "Invalid value of " + STRICT_RFC3370 + " stick to " + model.isStrictRFC3370Compliance()); } } try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals("Nimbus")) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(this); } } } catch (Exception exception) { LOG.warning("Look and feel Nimbus cannot be installed"); } String usage = getParameter("usage"); if (usage == null) { usage = "all"; } if (usage.equalsIgnoreCase("all")) { registerWizardPanel(new ActivityPanel(model)); registerWizardPanel(new SelectDocumentForSignaturePanel(model)); registerWizardPanel(new ChooseSignaturePanel(model)); registerWizardPanel(new SignatureTokenAPIPanel(model)); registerWizardPanel(new PKCS11ParamsPanel(model)); registerWizardPanel(new PKCS12ParamsPanel(model)); registerWizardPanel(new MOCCAParamsPanel(model)); registerWizardPanel(new ChooseCertificatePanel(model)); registerWizardPanel(new PersonalDataPanel(model)); registerWizardPanel(new SaveDocumentPanel(model)); registerWizardPanel(new WizardFinishedPanel(model)); registerWizardPanel(new SelectDocumentForVerificationPanel(model)); registerWizardPanel(new SignatureValidationReportPanel(model)); registerWizardPanel(new SelectDocumentForExtensionPanel(model)); setInitialPanel(ActivityPanel.ID); setCurrentPanel(ActivityPanel.ID, true); } else if (usage.equalsIgnoreCase("sign")) { registerWizardPanel(new SelectDocumentForSignaturePanel(model)); registerWizardPanel(new ChooseSignaturePanel(model)); registerWizardPanel(new SignatureTokenAPIPanel(model)); registerWizardPanel(new PKCS11ParamsPanel(model)); registerWizardPanel(new PKCS12ParamsPanel(model)); registerWizardPanel(new MOCCAParamsPanel(model)); registerWizardPanel(new ChooseCertificatePanel(model)); registerWizardPanel(new PersonalDataPanel(model)); registerWizardPanel(new SaveDocumentPanel(model)); registerWizardPanel(new WizardFinishedPanel(model)); setInitialPanel(SelectDocumentForSignaturePanel.ID); setCurrentPanel(SelectDocumentForSignaturePanel.ID, true); model.setWizardUsage(WizardUsage.SIGN); model.setUsageParameterFound(true); setNextFinishButtonEnabled(true); } else if (!isUsageParameterValid(usage) || usage.equalsIgnoreCase("verify")) { registerWizardPanel(new SelectDocumentForVerificationPanel(model)); registerWizardPanel(new SignatureValidationReportPanel(model)); setInitialPanel(SelectDocumentForVerificationPanel.ID); setCurrentPanel(SelectDocumentForVerificationPanel.ID, true); model.setWizardUsage(WizardUsage.VERIFY); model.setUsageParameterFound(true); setNextFinishButtonEnabled(true); } else if (usage.equalsIgnoreCase("extend")) { registerWizardPanel(new SelectDocumentForExtensionPanel(model)); setInitialPanel(SelectDocumentForExtensionPanel.ID); setCurrentPanel(SelectDocumentForExtensionPanel.ID, true); model.setWizardUsage(WizardUsage.EXTEND); model.setUsageParameterFound(true); setNextFinishButtonEnabled(true); } registerWizardPanel(new ErrorPanel(model)); setFinishedId(WizardFinishedPanel.ID); setErrorPanel(ErrorPanel.ID); }
From source file:InternalFrameListenerDemo.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == m_newFrame) newFrame();// w w w . j a v a 2 s .c o m else if (e.getSource() == m_eventTimer) { m_ifEventCanvas.render(getCounts()); clearCounts(); } else if (e.getSource() == m_UIBox) { try { m_UIBox.hidePopup(); //BUG WORKAROUND UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception ex) { System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName()); } } }
From source file:DesktopManagerDemo.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == m_newFrame) newFrame();//w w w.j a v a 2 s.c om else if (e.getSource() == m_eventTimer) { m_dmEventCanvas.render(m_myDesktopManager.getCounts()); m_myDesktopManager.clearCounts(); } else if (e.getSource() == m_UIBox) { try { m_UIBox.hidePopup(); //BUG WORKAROUND UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception ex) { System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName()); } } }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
public void setLookAndFeel(String uiclassname) { try {//from w w w .j ava2s. c o m UIManager.setLookAndFeel(uiclassname); SwingUtilities.updateComponentTreeUI(this); Prefs.setString("looknfeel", uiclassname); Prefs.save(); } catch (ClassNotFoundException e1) { LOG.warning("Unable to set Look and Feel (it is missing)."); } catch (InstantiationException e1) { LOG.warning("Unable to set Look and Feel (cannot be instantiated by JRE)."); } catch (IllegalAccessException e1) { LOG.warning("Unable to set Look and Feel (cannot be used by JRE)."); } catch (UnsupportedLookAndFeelException e1) { LOG.warning("Unable to set Look and Feel (not supported by JRE)."); } }
From source file:com.willwinder.universalgcodesender.uielements.panels.ControllerProcessorSettingsPanel.java
/** * ------------------------------//from w w w .java 2 s .c o m * | [ controller ] | * | [ ] front processor 1 | * | [ ] front processor 2 | * | [ ] end processor 1 | * | [ ] end processor 2 | * * | [+] [-] | * | ________________________ | * | | Enabled | Pattern | | * | | [y] | T\d+ | | * | | [n] | M30 | | * | ------------------------ | * |____________________________| */ @Override protected void updateComponentsInternal(Settings s) { this.removeAll(); initCustomRemoverTable(customRemoverTable); setLayout(new MigLayout("wrap 1, inset 5, fillx", "fill")); super.addIgnoreChanges(controllerConfigs); ConfigTuple ct = configFiles.get(controllerConfigs.getSelectedItem()); ProcessorConfigGroups pcg = ct.loader.getProcessorConfigs(); System.out.println(ct.file); for (ProcessorConfig pc : pcg.Front) { add(new ProcessorConfigCheckbox(pc, CommandProcessorLoader.getHelpForConfig(pc))); } for (ProcessorConfig pc : pcg.End) { add(new ProcessorConfigCheckbox(pc, CommandProcessorLoader.getHelpForConfig(pc))); } JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new MigLayout("wrap 3", "grow, fill", "")); add(buttonPanel, add); add(buttonPanel, new JLabel()); add(buttonPanel, remove); addIgnoreChanges(buttonPanel); DefaultTableModel model = (DefaultTableModel) this.customRemoverTable.getModel(); for (ProcessorConfig pc : pcg.Custom) { Boolean enabled = pc.enabled; String pattern = ""; if (pc.args != null && !pc.args.get("pattern").isJsonNull()) { pattern = pc.args.get("pattern").getAsString(); } model.addRow(new Object[] { enabled, pattern }); } addIgnoreChanges(new JScrollPane(customRemoverTable), "height 100"); SwingUtilities.updateComponentTreeUI(this); }
From source file:de.topobyte.livecg.LiveCG.java
private void setLookAndFeel(String lookAndFeel) { try {/*from w w w . j av a 2 s .c o m*/ UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { logger.error("error while setting look and feel '" + lookAndFeel + "': " + e.getClass().getSimpleName() + ", message: " + e.getMessage()); } for (Window window : JFrame.getWindows()) { SwingUtilities.updateComponentTreeUI(window); // window.pack(); } }