Search in sources :

Example 1 with FontUIResource

use of javax.swing.plaf.FontUIResource 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 FontUIResource

use of javax.swing.plaf.FontUIResource in project Botnak by Gocnak.

the class HiFiDefaultTheme method setUpColor.

public void setUpColor() {
    super.setUpColor();
    // Defaults for HiFiLookAndFeel
    textShadow = true;
    foregroundColor = extraLightGray;
    disabledForegroundColor = gray;
    disabledBackgroundColor = new ColorUIResource(48, 48, 48);
    backgroundColor = new ColorUIResource(48, 48, 48);
    backgroundColorLight = new ColorUIResource(48, 48, 48);
    //was 16, 16, 16, they were the fugly black lines
    backgroundColorDark = new ColorUIResource(48, 48, 48);
    alterBackgroundColor = new ColorUIResource(64, 64, 64);
    selectionForegroundColor = white;
    selectionBackgroundColor = new ColorUIResource(40, 40, 40);
    frameColor = black;
    gridColor = black;
    focusCellColor = orange;
    inputBackgroundColor = new ColorUIResource(80, 80, 80);
    inputForegroundColor = foregroundColor;
    rolloverColor = new ColorUIResource(112, 112, 112);
    rolloverColorLight = new ColorUIResource(128, 128, 128);
    rolloverColorDark = new ColorUIResource(96, 96, 96);
    buttonForegroundColor = foregroundColor;
    buttonBackgroundColor = new ColorUIResource(96, 96, 96);
    buttonColorLight = new ColorUIResource(96, 96, 96);
    buttonColorDark = new ColorUIResource(32, 32, 32);
    controlForegroundColor = foregroundColor;
    // netbeans use this for selected tab in the toolbar
    controlBackgroundColor = new ColorUIResource(64, 64, 64);
    controlColorLight = new ColorUIResource(96, 96, 96);
    controlColorDark = new ColorUIResource(32, 32, 32);
    controlHighlightColor = new ColorUIResource(96, 96, 96);
    controlShadowColor = new ColorUIResource(32, 32, 32);
    controlDarkShadowColor = black;
    windowTitleForegroundColor = foregroundColor;
    windowTitleBackgroundColor = new ColorUIResource(96, 96, 96);
    windowTitleColorLight = new ColorUIResource(96, 96, 96);
    //new ColorUIResource(16, 16, 16);
    windowTitleColorDark = new ColorUIResource(32, 32, 32);
    windowBorderColor = black;
    windowIconColor = lightGray;
    windowIconShadowColor = black;
    windowIconRolloverColor = orange;
    windowInactiveTitleForegroundColor = new ColorUIResource(196, 196, 196);
    windowInactiveTitleBackgroundColor = new ColorUIResource(64, 64, 64);
    windowInactiveTitleColorLight = new ColorUIResource(64, 64, 64);
    windowInactiveTitleColorDark = new ColorUIResource(32, 32, 32);
    windowInactiveBorderColor = black;
    menuForegroundColor = foregroundColor;
    menuBackgroundColor = new ColorUIResource(32, 32, 32);
    menuSelectionForegroundColor = white;
    menuSelectionBackgroundColor = new ColorUIResource(96, 96, 96);
    menuColorLight = new ColorUIResource(96, 96, 96);
    menuColorDark = new ColorUIResource(32, 32, 32);
    toolbarBackgroundColor = new ColorUIResource(48, 48, 48);
    toolbarColorLight = new ColorUIResource(96, 96, 96);
    toolbarColorDark = new ColorUIResource(32, 32, 32);
    tabAreaBackgroundColor = backgroundColor;
    tabSelectionForegroundColor = selectionForegroundColor;
    desktopColor = new ColorUIResource(64, 64, 64);
    tooltipForegroundColor = white;
    tooltipBackgroundColor = new ColorUIResource(24, 24, 24);
    controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
    systemFont = new FontUIResource("Dialog", Font.BOLD, 12);
    userFont = new FontUIResource("Dialog", Font.BOLD, 12);
    menuFont = new FontUIResource("Dialog", Font.BOLD, 12);
    windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 12);
    smallFont = new FontUIResource("Dialog", Font.PLAIN, 10);
}
Also used : FontUIResource(javax.swing.plaf.FontUIResource) ColorUIResource(javax.swing.plaf.ColorUIResource)

Example 3 with FontUIResource

use of javax.swing.plaf.FontUIResource in project Botnak by Gocnak.

the class NoireDefaultTheme method setUpColor.

public void setUpColor() {
    super.setUpColor();
    // Defaults for NoireLookAndFeel
    textShadow = true;
    foregroundColor = white;
    disabledForegroundColor = gray;
    disabledBackgroundColor = new ColorUIResource(48, 48, 48);
    backgroundColor = new ColorUIResource(24, 26, 28);
    backgroundColorLight = new ColorUIResource(24, 26, 28);
    backgroundColorDark = new ColorUIResource(4, 5, 6);
    alterBackgroundColor = new ColorUIResource(78, 84, 90);
    selectionForegroundColor = new ColorUIResource(255, 220, 120);
    selectionBackgroundColor = black;
    frameColor = black;
    gridColor = black;
    focusCellColor = orange;
    inputBackgroundColor = new ColorUIResource(52, 55, 59);
    inputForegroundColor = foregroundColor;
    rolloverColor = new ColorUIResource(240, 168, 0);
    rolloverColorLight = new ColorUIResource(240, 168, 0);
    rolloverColorDark = new ColorUIResource(196, 137, 0);
    buttonForegroundColor = black;
    buttonBackgroundColor = new ColorUIResource(120, 129, 148);
    buttonColorLight = new ColorUIResource(232, 238, 244);
    buttonColorDark = new ColorUIResource(196, 200, 208);
    controlForegroundColor = foregroundColor;
    // netbeans use this for selected tab in the toolbar
    controlBackgroundColor = new ColorUIResource(52, 55, 59);
    controlColorLight = new ColorUIResource(44, 47, 50);
    controlColorDark = new ColorUIResource(16, 18, 20);
    controlHighlightColor = new ColorUIResource(96, 96, 96);
    controlShadowColor = new ColorUIResource(32, 32, 32);
    controlDarkShadowColor = black;
    windowTitleForegroundColor = foregroundColor;
    windowTitleBackgroundColor = new ColorUIResource(144, 148, 149);
    windowTitleColorLight = new ColorUIResource(64, 67, 60);
    windowTitleColorDark = black;
    windowBorderColor = black;
    windowIconColor = lightGray;
    windowIconShadowColor = black;
    windowIconRolloverColor = orange;
    windowInactiveTitleForegroundColor = new ColorUIResource(196, 196, 196);
    windowInactiveTitleBackgroundColor = new ColorUIResource(64, 64, 64);
    windowInactiveTitleColorLight = new ColorUIResource(64, 64, 64);
    windowInactiveTitleColorDark = new ColorUIResource(32, 32, 32);
    windowInactiveBorderColor = black;
    menuForegroundColor = white;
    menuBackgroundColor = new ColorUIResource(24, 26, 28);
    menuSelectionForegroundColor = black;
    menuSelectionBackgroundColor = new ColorUIResource(196, 137, 0);
    menuColorLight = new ColorUIResource(96, 96, 96);
    menuColorDark = new ColorUIResource(32, 32, 32);
    toolbarBackgroundColor = new ColorUIResource(24, 26, 28);
    toolbarColorLight = new ColorUIResource(96, 96, 96);
    toolbarColorDark = new ColorUIResource(32, 32, 32);
    tabAreaBackgroundColor = backgroundColor;
    desktopColor = new ColorUIResource(52, 55, 59);
    tooltipForegroundColor = white;
    //new ColorUIResource(16, 16, 16);
    tooltipBackgroundColor = black;
    controlFont = new FontUIResource("Dialog", Font.BOLD, 12);
    systemFont = new FontUIResource("Dialog", Font.BOLD, 12);
    userFont = new FontUIResource("Dialog", Font.BOLD, 12);
    menuFont = new FontUIResource("Dialog", Font.BOLD, 12);
    windowTitleFont = new FontUIResource("Dialog", Font.BOLD, 12);
    smallFont = new FontUIResource("Dialog", Font.PLAIN, 10);
}
Also used : FontUIResource(javax.swing.plaf.FontUIResource) ColorUIResource(javax.swing.plaf.ColorUIResource)

Example 4 with FontUIResource

use of javax.swing.plaf.FontUIResource in project jdk8u_jdk by JetBrains.

the class JLabel269 method main.

public static void main(String[] args) {
    String labelText = "<html><body><code>A</code></body></html>";
    verbose = Arrays.asList(args).contains("-verbose");
    JFrame mainFrame = new JFrame();
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
    JPanel p1 = new JPanel();
    JLabel l1 = new JLabelTest(labelText);
    l1.setFont(new FontUIResource("Tahoma", Font.PLAIN, 36));
    p1.add(l1);
    container.add(p1);
    JPanel p2 = new JPanel();
    JLabel l2 = new JLabelTest(labelText);
    l2.setFont(new FontUIResource("Tahoma", Font.PLAIN, 72));
    p2.add(l2);
    container.add(p2);
    mainFrame.add(container);
    mainFrame.pack();
    mainFrame.setVisible(true);
    BufferedImage bi = new BufferedImage(l1.getWidth(), l1.getHeight(), BufferedImage.TYPE_INT_ARGB);
    l1.paint(bi.getGraphics());
    int height1 = maxCharHeight(bi, l1.getWidth(), l1.getHeight());
    bi = new BufferedImage(l2.getWidth(), l2.getHeight(), BufferedImage.TYPE_INT_ARGB);
    l2.paint(bi.getGraphics());
    int height2 = maxCharHeight(bi, l2.getWidth(), l2.getHeight());
    mainFrame.dispose();
    if (Math.abs(height2 - 2 * height1) > 2) {
        throw new RuntimeException("Heights of \"<code>A</code>\" for 36pt and for 72pt " + "must differ by half (+/- 2pxs)");
    }
}
Also used : JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) FontUIResource(javax.swing.plaf.FontUIResource) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) BufferedImage(java.awt.image.BufferedImage)

Example 5 with FontUIResource

use of javax.swing.plaf.FontUIResource in project intellij-community by JetBrains.

the class IdeaLaf method initComponentDefaults.

public void initComponentDefaults(UIDefaults defaults) {
    super.initComponentDefaults(defaults);
    LafManagerImpl.initInputMapDefaults(defaults);
    initIdeaDefaults(defaults);
    Pair<String, Integer> systemFont = UIUtil.getSystemFontData();
    if (systemFont != null) {
        LafManagerImpl.initFontDefaults(defaults, systemFont.second, new FontUIResource(systemFont.first, Font.PLAIN, systemFont.second));
    } else {
        LafManagerImpl.initFontDefaults(defaults, 11, new FontUIResource("Tahoma", Font.PLAIN, 11));
    }
}
Also used : FontUIResource(javax.swing.plaf.FontUIResource)

Aggregations

FontUIResource (javax.swing.plaf.FontUIResource)26 Font (java.awt.Font)5 UIDefaults (javax.swing.UIDefaults)5 ColorUIResource (javax.swing.plaf.ColorUIResource)3 IOException (java.io.IOException)2 StringTokenizer (java.util.StringTokenizer)2 JFrame (javax.swing.JFrame)2 UISettings (com.intellij.ide.ui.UISettings)1 FontDescriptor (com.intellij.uiDesigner.lw.FontDescriptor)1 Plastic3DLookAndFeel (com.jgoodies.looks.plastic.Plastic3DLookAndFeel)1 SkyBluer (com.jgoodies.looks.plastic.theme.SkyBluer)1 Dimension (java.awt.Dimension)1 Image (java.awt.Image)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1