Java Code Examples for javax.swing.UIManager#getDefaults()

The following examples show how to use javax.swing.UIManager#getDefaults() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwingCommonModule.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Initializes the module. Use this method to perform all initial setup operations. This method is called only once in
 * a modules lifetime. If the initializing cannot be completed, throw a ModuleInitializeException to indicate the
 * error,. The module will not be available to the system.
 *
 * @param subSystem
 *          the subSystem.
 * @throws ModuleInitializeException
 *           if an error ocurred while initializing the module.
 */
public void initialize( final SubSystem subSystem ) throws ModuleInitializeException {
  if ( subSystem.getExtendedConfig().getBoolProperty(
      "org.pentaho.reporting.engine.classic.core.modules.gui.base.SwingDialogTranslation" ) ) { //$NON-NLS-1$
    final ResourceBundle resources = ResourceBundle.getBundle( SwingCommonModule.BUNDLE_NAME );
    final UIDefaults defaults = UIManager.getDefaults();
    final Enumeration en = resources.getKeys();
    while ( en.hasMoreElements() ) {
      try {
        final String keyName = (String) en.nextElement();
        defaults.put( keyName, resources.getObject( keyName ) );
      } catch ( Exception e ) {
        // Ignored; if it happens, we would not care that much ..
      }
    }
  }
}
 
Example 2
Source File: DefaultsDisplay.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public UIDefaultsTableModel() {
    // make a local copy of the defaults table in case the look and feel changes
    defaults = new UIDefaults();
    keys = new ArrayList<Object>();
    UIDefaults realDefaults = UIManager.getDefaults();
    Enumeration keysEnum = realDefaults.keys();
    while (keysEnum.hasMoreElements()) {
        Object key = keysEnum.nextElement();
        if (!defaults.containsKey(key)) {
            keys.add(key);
            defaults.put(key, realDefaults.get(key));
        } else {
            System.out.println("found duplicate key:"+key);
        }
    }
}
 
Example 3
Source File: DefaultsDisplay.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public UIDefaultsTableModel() {
    // make a local copy of the defaults table in case the look and feel changes
    defaults = new UIDefaults();
    keys = new ArrayList<Object>();
    UIDefaults realDefaults = UIManager.getDefaults();
    Enumeration keysEnum = realDefaults.keys();
    while (keysEnum.hasMoreElements()) {
        Object key = keysEnum.nextElement();
        if (!defaults.containsKey(key)) {
            keys.add(key);
            defaults.put(key, realDefaults.get(key));
        } else {
            System.out.println("found duplicate key:"+key);
        }
    }
}
 
Example 4
Source File: Bug6530694.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 5
Source File: Bug6530694.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 6
Source File: Main.java    From i18n-editor with MIT License 5 votes vote down vote up
private static void setUIFont(Font font) {
	UIDefaults defaults = UIManager.getDefaults();
	Sets.newHashSet(
		"List.font",
		"TableHeader.font",
		"Panel.font",
		"TextArea.font",
		"ToggleButton.font",
		"ComboBox.font",
		"ScrollPane.font",
		"Spinner.font",
		"Slider.font",
		"EditorPane.font",
		"OptionPane.font",
		"ToolBar.font",
		"Tree.font",
		"TitledBorder.font",
		"Table.font",
		"Label.font",
		"TextField.font",
		"TextPane.font",
		"CheckBox.font",
		"ProgressBar.font",
		"FormattedTextField.font",
		"ColorChooser.font",
		"PasswordField.font",
		"Viewport.font",
		"TabbedPane.font",
		"RadioButton.font",
		"ToolTip.font",
		"Button.font"
	).forEach(key -> defaults.put(key, font));
}
 
Example 7
Source File: Bug6530694.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 8
Source File: Bug6530694.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 9
Source File: Bug6530694.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 10
Source File: Bug6530694.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 11
Source File: UIUtilities.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set up the user interface.
 */
public static void setupUI() {
    try {
        final String classname = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(classname);
    }
    catch (Exception e) { 
        e.printStackTrace();
    }

    final UIDefaults defaults = UIManager.getDefaults();

    defaults.put(
        "PopupMenu.border", 
        new BorderUIResource.EtchedBorderUIResource(
            EtchedBorder.RAISED, defaults.getColor("controlShadow"), 
            defaults.getColor("controlLtHighlight")
        )
    );

    final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black);
    final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control"));
    final BorderUIResource.CompoundBorderUIResource compBorder
        = new BorderUIResource.CompoundBorderUIResource(emptyborder, matteborder);
    final BorderUIResource.EmptyBorderUIResource emptyBorderUI
        = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0);
    defaults.put("SplitPane.border", emptyBorderUI);
    defaults.put("Table.scrollPaneBorder", emptyBorderUI);
    defaults.put("ComboBox.border", compBorder);
    defaults.put("TextField.border", compBorder);
    defaults.put("TextArea.border", compBorder);
    defaults.put("CheckBox.border", compBorder);
    defaults.put("ScrollPane.border", emptyBorderUI);

}
 
Example 12
Source File: Bug6530694.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 13
Source File: Bug6530694.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 14
Source File: FreeColLookAndFeel.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the default font in all UI elements.
 *
 * @param defaultFont A {@code Font} to use by default.
 */
public static void installFont(Font defaultFont) {
    UIDefaults u = UIManager.getDefaults();
    java.util.Enumeration<Object> keys = u.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (u.get(key) instanceof javax.swing.plaf.FontUIResource) {
            u.put(key, defaultFont);
        }
    }
}
 
Example 15
Source File: Bug6530694.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 16
Source File: Module.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void install() {
    // don't install directory chooser if standard chooser is desired
    if (isStandardChooserForced()) {
        return;
    }
    final UIDefaults uid = UIManager.getDefaults();
    originalImpl = (Class<?>) uid.getUIClass(KEY);
    Class<?> impl = DelegatingChooserUI.class;
    final String val = impl.getName();
    // don't install dirchooser if quickfilechooser is present
    if (!isQuickFileChooser(uid.get(KEY))) {
        uid.put(KEY, val);
        // To make it work in NetBeans too:
        uid.put(val, impl);
    }
    // #61147: prevent NB from switching to a different UI later (under GTK):
    uid.addPropertyChangeListener(pcl = new PropertyChangeListener() {
        public @Override void propertyChange(PropertyChangeEvent evt) {
            String name = evt.getPropertyName();
            Object className = uid.get(KEY);
            if ((name.equals(KEY) || name.equals("UIDefaults")) && !val.equals(className)
                    && !isQuickFileChooser(className)) {
                originalImpl = (Class<?>) uid.getUIClass(KEY);
                uid.put(KEY, val);
            }
        }
    });
}
 
Example 17
Source File: ColorEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Initialized fields used in Swing Palette. */
private static void initSwingConstants() {
    if (swingColorNames != null)
        return;

    UIDefaults def = UIManager.getDefaults ();
    Enumeration e = def.keys ();
    
    java.util.TreeSet<String> names = new java.util.TreeSet<String>();
    
    while (e.hasMoreElements ()) {
        Object k = e.nextElement ();
        if (! (k instanceof String))
            continue;
        Object v = def.get (k);
        if (! (v instanceof Color))
            continue;
        names.add((String)k);
    }
    
    swingColorNames = new String [names.size ()];
    names.toArray(swingColorNames);
    swingColors = new Color [swingColorNames.length];
    
    int i, k = swingColorNames.length;
    for (i = 0; i < k; i++)
        swingColors [i] = (Color) def.get (swingColorNames [i]);
        }
 
Example 18
Source File: Bug6530694.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 19
Source File: Bug6530694.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Bug6530694() {
    Locale.setDefault(Locale.GERMANY);
    UIDefaults defs = UIManager.getDefaults();
    defs.addResourceBundle("Bug6530694");
    String str = defs.getString("testkey");
    if (!"testvalue".equals(str)) {
        throw new RuntimeException("Could not load the resource for de_DE locale");
    }
}
 
Example 20
Source File: MainFrame.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
        Globals.setMainFrame(this);

        // better text visualization for disabled components
    	Options.setPopupDropShadowEnabled(true); // add drop shadow to popup menu
        UIDefaults uiDefaults = UIManager.getDefaults();
        uiDefaults.put("ComboBox.disabledForeground", Color.DARK_GRAY);
        uiDefaults.put("TextField.inactiveForeground", Color.DARK_GRAY);
        uiDefaults.put("TextArea.inactiveBackground", Color.WHITE);
        uiDefaults.put("FormattedTextField.inactiveForeground",Color.DARK_GRAY);
        uiDefaults.put("PasswordField.inactiveForeground",Color.DARK_GRAY);
        uiDefaults.put("CheckBox.disabledText", Color.DARK_GRAY);

        // internationalization
        UIManager.put("OptionPane.yesButtonText", I18NSupport.getString("optionpanel.yes"));
        UIManager.put("OptionPane.cancelButtonText", I18NSupport.getString("optionpanel.cancel"));
        UIManager.put("OptionPane.noButtonText", I18NSupport.getString("optionpanel.no"));
        UIManager.put("OptionPane.okButtonText", I18NSupport.getString("optionpanel.ok"));
        UIManager.put("OptionPane.messageDialogTitle", I18NSupport.getString("optionpanel.message"));
        UIManager.put("ColorChooser.okText", I18NSupport.getString("colorchooser.ok"));
        UIManager.put("ColorChooser.cancelText", I18NSupport.getString("colorchooser.cancel"));
        UIManager.put("ColorChooser.resetText", I18NSupport.getString("colorchooser.reset"));
        UIManager.put("FileChooser.saveInLabelText", I18NSupport.getString("FileChooser.saveInLabelText"));
        UIManager.put("FileChooser.fileNameLabelText", I18NSupport.getString("FileChooser.fileNameLabelText"));
        UIManager.put("FileChooser.folderNameLabelText", I18NSupport.getString("FileChooser.folderNameLabelText"));
        UIManager.put("FileChooser.filesOfTypeLabelText", I18NSupport.getString("FileChooser.filesOfTypeLabelText"));
        UIManager.put("FileChooser.saveButtonText", I18NSupport.getString("FileChooser.saveButtonText"));
        UIManager.put("FileChooser.cancelButtonText", I18NSupport.getString("FileChooser.cancelButtonText"));
        UIManager.put("FileChooser.saveButtonToolTipText", I18NSupport.getString("FileChooser.saveButtonToolTipText"));
        UIManager.put("FileChooser.cancelButtonToolTipText", I18NSupport.getString("FileChooser.cancelButtonToolTipText"));
        UIManager.put("FileChooser.upFolderToolTipText", I18NSupport.getString("FileChooser.upFolderToolTipText"));
        UIManager.put("FileChooser.homeFolderToolTipText", I18NSupport.getString("FileChooser.homeFolderToolTipText"));
        UIManager.put("FileChooser.newFolderToolTipText", I18NSupport.getString("FileChooser.newFolderToolTipText"));
        UIManager.put("FileChooser.listViewButtonToolTipText", I18NSupport.getString("FileChooser.listViewButtonToolTipText"));
        UIManager.put("FileChooser.detailsViewButtonToolTipText", I18NSupport.getString("FileChooser.detailsViewButtonToolTipText"));

        // docking
        UIManager.put(MyDoggyKeySpace.DRAG_ENABLED, false); 
        
        // inside connections dir are kept the queries/reports for every data source
        DefaultDataSourceManager.getInstance().load();
        File  connections = new File(FileReportPersistence.CONNECTIONS_DIR);
        if (!connections.exists()) {
            connections.mkdir();
        }
        // inside reports dir are kept the generated reports
        File reports = new File(ExportAction.REPORTS_DIR);
        if (!reports.exists()) {
            reports.mkdir();
        }

        // create workspace panel
        workspacePanel = new JXPanel(new CardLayout());
        
        // create query builder panel before menu(!!! for docking)
        qbPanel = new QueryBuilderPanel();
        qbPanel.initWorkspace();

        setLayout(new BorderLayout());
//        add(new MainToolBar(), BorderLayout.NORTH);
        setToolBar(new MainToolBar());

        statusBar = new JXStatusBar();
        //statusBar.add(new JXLabel(""), JXStatusBar.Constraint.ResizeBehavior.FILL);
        statusBar.add(new JXLabel(""), new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL, new Insets(0,5,2,2)));        
        statusBar.add(new MemoryStatus());
        statusBar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));                
        setStatusBar(statusBar);

        WorkspaceManager workspaceManager = WorkspaceManager.getInstance();
        workspacePanel.add((Component) workspaceManager.getQueryWorkspace().getToolWindowManager(), WorkspaceManager.QUERY_WORKSPACE);
        workspacePanel.add((Component) workspaceManager.getReportWorkspace().getToolWindowManager(), WorkspaceManager.REPORT_WORKSPACE);
        workspacePanel.add((Component) workspaceManager.getChartWorkspace().getToolWindowManager(), WorkspaceManager.CHART_WORKSPACE);
        add(workspacePanel, BorderLayout.CENTER);
        
        DataSource ds = DefaultDataSourceManager.getInstance().getConnectedDataSource();
        if (ds != null) {
            setStatusBarMessage("<html>" + I18NSupport.getString("datasource.active") + 
            		" <b>" + ds.getName() + "</b></html>");
        }

        setJMenuBar(new MainMenuBar());

        Globals.getMainMenuBar().actionUpdate(ds != null);
        Globals.getMainToolBar().actionUpdate(ds != null);
        
        String systemReport = Globals.getSystemReport();
        String systemChart = Globals.getSystemChart();
        String systemPath = Globals.getSystemPath();
        if (systemReport !=  null) {
        	openSystemReport(systemReport, systemPath);
        } else if (systemChart !=  null) {
        	openSystemChart(systemChart, systemPath);
        }
        
    }