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();
}
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);
}
}
});
}
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;
}
}
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");
}
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");
}
});
}
Aggregations