Search in sources :

Example 1 with UIDefaults

use of javax.swing.UIDefaults in project AozoraEpub3 by hmdev.

the class AozoraEpub3Applet method main.

////////////////////////////////////////////////////////////////
// JFrame
////////////////////////////////////////////////////////////////
/** Jar実行用 */
public static void main(String[] args) {
    //LookAndFeel変更
    try {
        String lafName = UIManager.getSystemLookAndFeelClassName();
        //lafName = "";
        if (lafName.startsWith("com.sun.java.swing.plaf.windows.")) {
            UIManager.setLookAndFeel(lafName);
        } else {
            //Windows以外はMetalのままでFontはPLAIN
            UIDefaults defaultTable = UIManager.getLookAndFeelDefaults();
            for (Object o : defaultTable.keySet()) {
                if (o.toString().toLowerCase().endsWith("font")) {
                    FontUIResource font = (FontUIResource) UIManager.get(o);
                    font = new FontUIResource(font.getName(), Font.PLAIN, font.getSize());
                    UIManager.put(o, font);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    //フレーム初期化
    final JFrame jFrame = new JFrame("AozoraEpub3");
    //アップレット生成と初期化
    final AozoraEpub3Applet applet = new AozoraEpub3Applet(jFrame);
    applet.iconImage = java.awt.Toolkit.getDefaultToolkit().createImage(AozoraEpub3Applet.class.getResource("images/icon.png"));
    applet.init();
    //アイコン設定
    jFrame.setIconImage(applet.iconImage);
    //最小サイズ
    jFrame.setMinimumSize(new Dimension(520, 320));
    jFrame.setPreferredSize(new Dimension(520, 400));
    try {
        int x = (int) Float.parseFloat(applet.props.getProperty("PosX"));
        int y = (int) Float.parseFloat(applet.props.getProperty("PosY"));
        jFrame.setLocation(x, y);
    } catch (Exception e) {
    }
    jFrame.setSize(applet.getSize());
    try {
        int w = (int) Float.parseFloat(applet.props.getProperty("SizeW"));
        int h = (int) Float.parseFloat(applet.props.getProperty("SizeH"));
        jFrame.setSize(w, h);
    } catch (Exception e) {
    }
    jFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            try {
                //Window位置を割くに設定しておく
                Point location = jFrame.getLocation();
                Dimension size = jFrame.getSize();
                applet.props.setProperty("PosX", "" + location.getX());
                applet.props.setProperty("PosY", "" + location.getY());
                applet.props.setProperty("SizeW", "" + size.getWidth());
                applet.props.setProperty("SizeH", "" + size.getHeight());
                //props保存と終了処理
                applet.finalize();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            System.exit(0);
        }
    });
    jFrame.add(applet);
    jFrame.setVisible(true);
    //引数にファイルが指定されていたら変換実行
    for (String fileName : args) {
        File file = new File(fileName);
        Vector<File> vecFiles = new Vector<File>();
        if (file.exists())
            vecFiles.add(file);
        if (vecFiles.size() > 0) {
            File[] files = new File[vecFiles.size()];
            for (int i = 0; i < files.length; i++) files[i] = vecFiles.get(i);
            applet.startConvertWorker(vecFiles, null, null, null);
        }
    }
    //Focus
    applet.jTabbedPane.requestFocus();
}
Also used : UIDefaults(javax.swing.UIDefaults) FontUIResource(javax.swing.plaf.FontUIResource) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Point(java.awt.Point) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Point(java.awt.Point) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) File(java.io.File) Vector(java.util.Vector)

Example 2 with UIDefaults

use of javax.swing.UIDefaults in project gephi by gephi.

the class Module method install.

public static void install() {
    // don't install directory chooser if standard chooser is desired
    if (isStandardChooserForced()) {
        return;
    }
    final UIDefaults uid = UIManager.getDefaults();
    originalImpl = (Class<? extends FileChooserUI>) 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() {

        @Override
        public 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)) {
                uid.put(KEY, val);
            }
        }
    });
}
Also used : UIDefaults(javax.swing.UIDefaults) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 3 with UIDefaults

use of javax.swing.UIDefaults in project gephi by gephi.

the class Module method uninstall.

public static void uninstall() {
    if (isInstalled()) {
        assert pcl != null;
        UIDefaults uid = UIManager.getDefaults();
        uid.removePropertyChangeListener(pcl);
        pcl = null;
        String val = originalImpl.getName();
        uid.put(KEY, val);
        uid.put(val, originalImpl);
        originalImpl = null;
    }
}
Also used : UIDefaults(javax.swing.UIDefaults)

Example 4 with UIDefaults

use of javax.swing.UIDefaults in project jdk8u_jdk by JetBrains.

the class Test8039750 method main.

public static void main(String[] args) {
    UIDefaults table = new MetalLookAndFeel().getDefaults();
    test(table.get("ToolBar.rolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("ToolBar.nonrolloverBorder"), "javax.swing.plaf.metal.MetalBorders$ButtonBorder", "javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
    test(table.get("RootPane.frameBorder"), "javax.swing.plaf.metal.MetalBorders$FrameBorder");
    test(table.get("RootPane.plainDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.informationDialogBorder"), "javax.swing.plaf.metal.MetalBorders$DialogBorder");
    test(table.get("RootPane.errorDialogBorder"), "javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
    test(table.get("RootPane.colorChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.fileChooserDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.questionDialogBorder"), "javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
    test(table.get("RootPane.warningDialogBorder"), "javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
Also used : UIDefaults(javax.swing.UIDefaults) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 5 with UIDefaults

use of javax.swing.UIDefaults in project jdk8u_jdk by JetBrains.

the class WrongBackgroundColor method main.

public static void main(final String[] args) throws InvocationTargetException, InterruptedException {
    SwingUtilities.invokeAndWait(() -> {
        UIDefaults ui = UIManager.getDefaults();
        ui.put("control", new ColorUIResource(54, 54, 54));
        final JDialog dialog = new JDialog();
        final JFrame frame = new JFrame();
        frame.pack();
        dialog.pack();
        final Color dialogBackground = dialog.getBackground();
        final Color frameBackground = frame.getBackground();
        frame.dispose();
        dialog.dispose();
        if (!dialogBackground.equals(frameBackground)) {
            System.err.println("Expected:" + frameBackground);
            System.err.println("Actual:" + dialogBackground);
            throw new RuntimeException("Wrong background color");
        }
    });
}
Also used : UIDefaults(javax.swing.UIDefaults) JFrame(javax.swing.JFrame) Color(java.awt.Color) ColorUIResource(javax.swing.plaf.ColorUIResource) JDialog(javax.swing.JDialog)

Aggregations

UIDefaults (javax.swing.UIDefaults)20 FontUIResource (javax.swing.plaf.FontUIResource)5 Color (java.awt.Color)4 Font (java.awt.Font)3 ColorUIResource (javax.swing.plaf.ColorUIResource)3 Dimension (java.awt.Dimension)2 Insets (java.awt.Insets)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 JFrame (javax.swing.JFrame)2 Plastic3DLookAndFeel (com.jgoodies.looks.plastic.Plastic3DLookAndFeel)1 SkyBluer (com.jgoodies.looks.plastic.theme.SkyBluer)1 Image (java.awt.Image)1 Point (java.awt.Point)1 SystemColor (java.awt.SystemColor)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 File (java.io.File)1