📄 appearancepreferencespanel.java~
字号:
String[] userThemes = new String[0]; if (!path.isDirectory() && !path.mkdirs()) { com.valhalla.Logger .debug("Could not create user defined settings directories."); } else { userThemes = path.list(); for (int i = 0; i < userThemes.length; i++) { if (!current.equals(userThemes[i])) { box.addItem(userThemes[i]); } } } // default themes in the jar InputStream stream = getClass().getClassLoader().getResourceAsStream( "imagethemes/statusicons/index.dat"); if (stream == null) { com.valhalla.Logger.debug("Bad status theme file."); return box; } InputStreamReader in = new InputStreamReader(stream); BufferedReader reader = new BufferedReader(in); String line; try { while ((line = reader.readLine()) != null) { boolean userTheme = false; for (int i = 0; i < userThemes.length; i++) { if (line.equals(userThemes[i])) { userTheme = true; break; } } if (!userTheme && !line.equals(current)) { box.addItem(line); } } } catch (IOException e) { } return box; } /** * Gets a list of emoticon themes * * @return The emoticonThemes value */ private JComboBox getEmoticonThemes() { JComboBox box = new JComboBox(); String current = Settings.getInstance().getProperty("emoticonTheme"); if (current == null) { current = "default"; } box.addItem(current); // default themes in the jar InputStream stream = getClass().getClassLoader().getResourceAsStream( "imagethemes/emoticons/index.dat"); if (stream == null) { com.valhalla.Logger.debug("Bad emoticon theme file."); return box; } InputStreamReader in = new InputStreamReader(stream); BufferedReader reader = new BufferedReader(in); String line; try { while ((line = reader.readLine()) != null) { if (!line.equals(current)) { box.addItem(line); } } } catch (IOException e) { } return box; } /** * Gets the String representation of a font * * @param font * Description of the Parameter * @return the string representation of a font */ private String getEncodedFontName(Font font) { String fontString = font.getName() + "-"; if (font.isPlain()) { fontString += "PLAIN"; } if (font.isBold()) { fontString += "BOLD"; } if (font.isItalic()) { fontString += "ITALIC"; } fontString += "-" + font.getSize(); return fontString; } /** * Gets temporary settings * * @return temporary settings */ public TempSettings getSettings() { TempSettings tempSettings = new TempSettings(); if (lookAndFeel.getSelectedIndex() != current) { //Standard.noticeMessage( prefs, resources.getString( "themeLabel" // ), // resources.getString( "themeSettingsApplied" ) ); String laf = lfs[lookAndFeel.getSelectedIndex()].getClassName(); JBotherLoader.loadLAF(laf); tempSettings.setProperty("lookAndFeel", laf); current = lookAndFeel.getSelectedIndex(); } tempSettings.setProperty("messageWindowFont", getEncodedFontName(messageFontButton.getFont())); // update all open conversation areas Hashtable buddyStatuses = BuddyList.getInstance().getBuddyStatuses(); if (buddyStatuses != null) { Iterator i = buddyStatuses.keySet().iterator(); while (i.hasNext()) { BuddyStatus buddy = BuddyList.getInstance().getBuddyStatus( (String) i.next()); if (buddy.getConversation() != null) { buddy.getConversation().updateStyle( messageFontButton.getFont()); } } } if (BuddyList.getInstance().getTabFrame() != null) { BuddyList.getInstance().getTabFrame().updateStyles( messageFontButton.getFont()); } tempSettings.setProperty("applicationFont", getEncodedFontName(appFontButton.getFont())); updateApplicationFonts(appFontButton.getFont(), prefs); String selectedStatus = (String) statusTheme.getItemAt(statusTheme .getSelectedIndex()); tempSettings.setProperty("statusTheme", selectedStatus); tempSettings.setProperty("emoticonTheme", (String) emoticonTheme .getItemAt(emoticonTheme.getSelectedIndex())); BuddyList.getInstance().getBuddyListTree().repaint(); if (BuddyList.getInstance().getTabFrame() != null) { BuddyList.getInstance().getTabFrame().repaint(); } BuddyList.getInstance().updateButtons(); Emoticons.getInstance().switchTheme( tempSettings.getProperty("emoticonTheme")); return tempSettings; } /** * Updates all the fonts in the application * * @param font * the font to update to * @param prefs * Description of the Parameter */ public static void updateApplicationFonts(Font font, PreferencesDialog prefs) { com.valhalla.jbother.JBotherLoader.setupFont(font); updateAllUIs(); if (prefs != null) { updateComponentTreeUI0(prefs.getTree()); Iterator i = prefs.getPanels().keySet().iterator(); while (i.hasNext()) { updateComponentTreeUI0((Component) prefs.getPanels().get( i.next())); } i = PreferencesDialog.getPluginPanels().keySet().iterator(); while (i.hasNext()) { updateComponentTreeUI0((Component) prefs.getPanels().get( i.next())); } } } /** * Method to attempt a dynamic update for any GUI accessible by this JVM. It * will filter through all frames and sub-components of the frames. */ public static void updateAllUIs() { CopyPasteContextMenu.newInstance(); Frame frames[]; int i1; frames = Frame.getFrames(); i1 = 0; for (int i = 0; i < frames.length; i++) { updateWindowUI(frames[i]); } } /** * Method to attempt a dynamic update for all components of the given * <code>Window</code>. * * @param window * The <code>Window</code> for which the look and feel update * has to be performed against. */ public static void updateWindowUI(Window window) { try { updateComponentTreeUI(window); } catch (Exception exception) { } Window windows[] = window.getOwnedWindows(); for (int i = 0; i < windows.length; i++) { updateWindowUI(windows[i]); } } /** * A simple minded look and feel change: ask each node in the tree to * <code>updateUI()</code>-- that is, to initialize its UI property with * the current look and feel. Based on the Sun * SwingUtilities.updateComponentTreeUI, but ensures that the update happens * on the components of a JToolbar before the JToolbar itself. * * @param c * Description of the Parameter */ public static void updateComponentTreeUI(Component c) { updateComponentTreeUI0(c); c.invalidate(); c.validate(); c.repaint(); } /** * Description of the Method * * @param c * Description of the Parameter */ private static void updateComponentTreeUI0(Component c) { Component[] children = null; if (c instanceof JToolBar) { children = ((JToolBar) c).getComponents(); if (children != null) { for (int i = 0; i < children.length; i++) { updateComponentTreeUI0(children[i]); } } ((JComponent) c).updateUI(); } else { if (c instanceof JComponent) { ((JComponent) c).updateUI(); } if (c instanceof JMenu) { children = ((JMenu) c).getMenuComponents(); } else if (c instanceof Container) { children = ((Container) c).getComponents(); } if (children != null) { for (int i = 0; i < children.length; i++) { updateComponentTreeUI0(children[i]); } } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -