本文整理汇总了Java中javax.swing.plaf.ColorUIResource类的典型用法代码示例。如果您正苦于以下问题:Java ColorUIResource类的具体用法?Java ColorUIResource怎么用?Java ColorUIResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColorUIResource类属于javax.swing.plaf包,在下文中一共展示了ColorUIResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustColor
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
/**
* Creates and returns a new color derived from the passed in color.
* The transformation is done in the HLS color space using the specified
* arguments to scale.
*
* @param color Color to alter
* @param hFactory Amount to scale the hue
* @param lFactor Amount to scale the lightness
* @param sFactory Amount to sacle saturation
* @return newly created color
*/
static Color adjustColor(Color color, float hFactor, float lFactor,
float sFactor) {
float h;
float l;
float s;
synchronized(HLS_COLOR_LOCK) {
float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS);
h = hls[0];
l = hls[1];
s = hls[2];
}
h = Math.min(360, hFactor * h);
l = Math.min(1, lFactor * l);
s = Math.min(1, sFactor * s);
return new ColorUIResource(hlsToRGB(h, l, s));
}
示例2: adjustColor
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
/**
* Creates and returns a new color derived from the passed in color.
* The transformation is done in the HLS color space using the specified
* arguments to scale.
*
* @param color Color to alter
* @param hFactor Amount to scale the hue
* @param lFactor Amount to scale the lightness
* @param sFactor Amount to sacle saturation
* @return newly created color
*/
static Color adjustColor(Color color, float hFactor, float lFactor,
float sFactor) {
float h;
float l;
float s;
synchronized(HLS_COLOR_LOCK) {
float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS);
h = hls[0];
l = hls[1];
s = hls[2];
}
h = Math.min(360, hFactor * h);
l = Math.min(1, lFactor * l);
s = Math.min(1, sFactor * s);
return new ColorUIResource(hlsToRGB(h, l, s));
}
示例3: testNames
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
void testNames() {
Color defaultColor = label.getBackground();
UIManager.put("\"BlueLabel\"[Enabled].background",
new ColorUIResource(Color.BLUE));
UIManager.put("\"RedLabel\"[Enabled].background",
new ColorUIResource(Color.RED));
nimbus.register(Region.LABEL, "\"BlueLabel\"");
nimbus.register(Region.LABEL, "\"RedLabel\"");
label.setName("BlueLabel");
check(Color.BLUE);
label.setName("RedLabel");
check(Color.RED);
// remove name, color goes back to default
label.setName(null);
check(defaultColor);
}
示例4: parseColor
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
/**
* parse a comma delimited list of 3 strings into a Color
*/
private ColorUIResource parseColor(String s) {
int red = 0;
int green = 0;
int blue = 0;
try {
StringTokenizer st = new StringTokenizer(s, ",");
red = Integer.parseInt(st.nextToken());
green = Integer.parseInt(st.nextToken());
blue = Integer.parseInt(st.nextToken());
} catch (Exception e) {
System.out.println(e);
System.out.println("Couldn't parse color :" + s);
}
return new ColorUIResource(red, green, blue);
}
示例5: main
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
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");
}
});
}
示例6: convert
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
/**
* Takes a UIManager color key and ensures that it is stored as a
* ColorUIResource, not a Color.
*/
private static void convert (String key) {
Color c = UIManager.getColor(key);
if (c != null && !(c instanceof ColorUIResource)) {
UIManager.put (key, new ColorUIResource(c));
}
}
示例7: updateVirtualItemForTheme
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
public static void updateVirtualItemForTheme(Colors currentTheme) {
if (currentTheme == null) {
selectedThumbBorder = BorderFactory.createLineBorder(new ColorUIResource(122, 170, 233), 2);
} else {
selectedThumbBorder = BorderFactory.createLineBorder(currentTheme.getFileChooserColors()[1], 2);
}
}
示例8: paintBorder
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y);
g.setColor(new ColorUIResource(90, 90, 90));
g.drawLine(0, 0, w - 1, 0);
g.drawLine(0, 0, 0, h - 1);
g.setColor(new ColorUIResource(255, 255, 255));
g.drawLine(w - 1, 1, w - 1, h - 1);
g.drawLine(1, h - 1, w - 1, h - 1);
g.translate(-x, -y);
}
示例9: paintBorder
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y);
g.setColor(new ColorUIResource(190, 190, 190));
g.drawLine(0, 0, w - 1, 0);
g.drawLine(0, 0, 0, h - 1);
g.setColor(new ColorUIResource(220, 220, 220));
g.drawLine(w - 1, 1, w - 1, h - 1);
g.drawLine(1, h - 1, w - 1, h - 1);
g.translate(-x, -y);
}
示例10: paintBorder
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
g.translate(x, y);
g.setColor(new ColorUIResource(220, 220, 220));
g.drawLine(0, 0, w, 0);
g.drawLine(0, h - 1, w, h - 1);
g.setColor(new ColorUIResource(200, 200, 200));
g.drawLine(0, 1, w, 1);
g.drawLine(0, h - 2, w, h - 2);
g.translate(-x, -y);
}
示例11: paintToImage
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
@Override
protected void paintToImage(Component c, Graphics g, int w, int h, Object[] args) {
g.setColor(new ColorUIResource(252, 252, 252));
g.fillRect(0, 0, w, 3);
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(new GradientPaint(0, 3, new ColorUIResource(252, 252, 252), 0, h - 3, new ColorUIResource(232, 232, 232)));
g2.fillRect(0, 3, w, h - 3);
}
示例12: configureUI
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
private static void configureUI() {
UIManager.put("ScrollBarUI", "com.transparentdiscord.UI.Custom.CustomScrollBarUI");
System.setProperty("awt.useSystemAAFontSettings", "on");
System.setProperty("swing.aatext", "true");
UIManager.put("ScrollBar.width", 4);
UIManager.put("ScrollBar.track", new ColorUIResource(new Color(0,0,0,0)));
UIManager.put("ScrollBar.thumb", new ColorUIResource(Color.decode("#99AAB5")));
UIManager.put("ScrollBar.thumbDarkShadow", new ColorUIResource(Color.decode("#99AAB5")));
UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(Color.decode("#99AAB5")));
UIManager.put("ScrollBar.thumbHighlight", new ColorUIResource(Color.decode("#99AAB5")));
}
示例13: addCustomEntriesToTable
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
public void addCustomEntriesToTable(UIDefaults table) {
super.addCustomEntriesToTable(table);
// table.put("Button.gradient", Arrays.asList(new Object[] {
// new Float(.3f), new Float(0f), new ColorUIResource(light_gray),// new
// // ColorUIResource(0xDDE8F3),
// new ColorUIResource(new Color(245,245,245)), getSecondary2() }));
// Color cccccc = new ColorUIResource(0xCCCCCC);
Color dadada = new ColorUIResource(0xDADADA);
// Color c8ddf2 = new ColorUIResource(0xC8DDF2);
List<Object> buttonGradient = Arrays.asList(new Object[] {
new Float(1f), new Float(0f), getWhite(), dadada,
new ColorUIResource(dadada) });
// Arrays.asList(new Object[] {
// new Float(.3f),
// new Float(0f),
// new ColorUIResource(new Color(230, 230, 230)),// new
// // ColorUIResource(0xDDE8F3),
// new ColorUIResource(new Color(235, 235, 235)),
// new ColorUIResource(new Color(180, 180, 180)) });
table.put("Button.gradient", buttonGradient);
table.put("ScrollBar.gradient", buttonGradient);
table.put("RadioButton.gradient", buttonGradient);
table.put("RadioButtonMenuItem.gradient", buttonGradient);
// table.put("ScrollBar.gradient", buttonGradient);
//
// table.put("Button.gradient", Arrays.asList(new Object[] {
// new Float(.3f), new Float(0f), new ColorUIResource(Color.black),//
// new
// // ColorUIResource(0xDDE8F3),
// getWhite(), getSecondary2() }));
// // System.out.println(table.get("Button.gradient"));
}
示例14: testInheritance
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
void testInheritance() {
Color defaultColor = label.getBackground();
// more specific setting is in global defaults
UIManager.put("Label[Enabled].background", new ColorUIResource(Color.RED));
// less specific one is in overrides
UIDefaults defs = new UIDefaults();
defs.put("Label.background", new ColorUIResource(Color.GREEN));
// global wins
label.putClientProperty("Nimbus.Overrides", defs);
check(Color.RED);
// now override wins
label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
check(Color.GREEN);
// global is back
label.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
check(Color.RED);
// back to default color
UIManager.put("Label[Enabled].background", null);
label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
label.putClientProperty("Nimbus.Overrides", null);
check(defaultColor);
}
示例15: getPrimary3
import javax.swing.plaf.ColorUIResource; //导入依赖的package包/类
@Override
protected ColorUIResource getPrimary3() {
return primary3;
}