Java tutorial
//package com.java2s; /* * Copyright (c) 2005-2016 Vincent Vandenschrick. All rights reserved. * * This file is part of the Jspresso framework. * * Jspresso is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Jspresso is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Jspresso. If not, see <http://www.gnu.org/licenses/>. */ import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class Main { private static final String FORMATTED_TEXTFIELD_FONT_KEY = "FormattedTextField.font"; private static final String FORMATTED_TEXTFIELD_INACTIVE_BACKGROUND_KEY = "FormattedTextField.inactiveBackground"; private static final String PASSWORDFIELD_FONT_KEY = "PasswordField.font"; private static final String TEXTFIELD_FONT_KEY = "TextField.font"; private static final String TEXTFIELD_INACTIVE_BACKGROUND_KEY = "TextField.inactiveBackground"; /** * Workaround for Bug#5063999. */ public static void installDefaults() { String defaultlaf = System.getProperty("swing.defaultlaf"); if (defaultlaf == null || defaultlaf.length() == 0) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException ex) { // NO-OP } } JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); UIManager.put(FORMATTED_TEXTFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY)); UIManager.put(FORMATTED_TEXTFIELD_INACTIVE_BACKGROUND_KEY, UIManager.get(TEXTFIELD_INACTIVE_BACKGROUND_KEY)); UIManager.put(PASSWORDFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY)); // try { // UIManager.put(LafWidget.TABBED_PANE_PREVIEW_PAINTER, // new DefaultTabPreviewPainter() { // // /** // * {@inheritDoc} // */ // @Override // public TabOverviewKind getOverviewKind(JTabbedPane tabPane) { // return TabOverviewKind.ROUND_CAROUSEL; // // return TabOverviewKind.MENU_CAROUSEL; // } // }); // UIManager.put(LafWidget.COMPONENT_PREVIEW_PAINTER, // new DefaultPreviewPainter()); // UIManager.put(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); // // UIManager.put(LafWidget.COMBO_BOX_NO_AUTOCOMPLETION, Boolean.TRUE); // } catch (Throwable ignored) { // // substance may not be available. // } } }