initialize
* method.
*/
private boolean inInitialize;
/**
* If true, PropertyChangeListeners have been installed for the
* Toolkit.
*/
private boolean pclInstalled;
/**
* StyleFactory needs to be created only the first time.
*/
private GTKStyleFactory styleFactory;
/**
* Cached theme name. Used by GTKGraphicsUtils
*/
private static String gtkThemeName = "Default";
static {
// Backup for specifying the version, this isn't currently documented.
// If you pass in anything but 2.2 you got the 2.0 colors/look.
String version = AccessController.doPrivileged(
new GetPropertyAction("swing.gtk.version"));
if (version != null) {
IS_22 = version.equals("2.2");
}
else {
IS_22 = true;
}
String language = Locale.getDefault().getLanguage();
boolean cjkLocale =
(Locale.CHINESE.getLanguage().equals(language) ||
Locale.JAPANESE.getLanguage().equals(language) ||
Locale.KOREAN.getLanguage().equals(language));
if (cjkLocale) {
boolean isSunDesktop = false;
switch (OSInfo.getOSType()) {
case SOLARIS:
isSunDesktop = true;
break;
case LINUX:
Boolean val = AccessController.doPrivileged(
new PrivilegedActionSynth | GTK * |
SynthConstants.PRESSED | ACTIVE * |
SynthConstants.SELECTED | SELECTED * |
SynthConstants.MOUSE_OVER | PRELIGHT * |
SynthConstants.DISABLED | INSENSITIVE * |
SynthConstants.ENABLED | NORMAL * |
SynthStyles
from the SynthStyleFactory
* when the ancestor of the Component changes.
*
* @return whether or not the UIs should update their
* SynthStyles
from the SynthStyleFactory
* when the ancestor changed.
*/
public boolean shouldUpdateStyleOnAncestorChanged() {
return true;
}
/**
* {@inheritDoc}
*/
public LayoutStyle getLayoutStyle() {
return GnomeLayoutStyle.INSTANCE;
}
/**
* Gnome layout style. From:
* http://developer.gnome.org/projects/gup/hig/2.0/design-window.html#window-layout-spacing
* You'll notice this doesn't do the radiobutton/checkbox border
* adjustments that windows/metal do. This is because gtk doesn't
* provide margins/insets for checkbox/radiobuttons.
*/
private static class GnomeLayoutStyle extends DefaultLayoutStyle {
private static GnomeLayoutStyle INSTANCE = new GnomeLayoutStyle();
@Override
public int getPreferredGap(JComponent component1,
JComponent component2, ComponentPlacement type, int position,
Container parent) {
// Checks args
super.getPreferredGap(component1, component2, type, position,
parent);
switch(type) {
case INDENT:
if (position == SwingConstants.EAST ||
position == SwingConstants.WEST) {
// Indent group members 12 pixels to denote hierarchy and
// association.
return 12;
}
// Fall through to related
// As a basic rule of thumb, leave space between user
// interface components in increments of 6 pixels, going up as
// the relationship between related elements becomes more
// distant. For example, between icon labels and associated
// graphics within an icon, 6 pixels are adequate. Between
// labels and associated components, leave 12 horizontal
// pixels. For vertical spacing between groups of components,
// 18 pixels is adequate.
//
// The first part of this is handled automatically by Icon (which
// won't give you 6 pixels).
case RELATED:
if (isLabelAndNonlabel(component1, component2, position)) {
return 12;
}
return 6;
case UNRELATED:
return 12;
}
return 0;
}
@Override
public int getContainerGap(JComponent component, int position,
Container parent) {
// Checks args
super.getContainerGap(component, position, parent);
// A general padding of 12 pixels is
// recommended between the contents of a dialog window and the
// window borders.
return 12;
}
}
}