当前位置: 首页>>代码示例>>Java>>正文


Java Color.equals方法代码示例

本文整理汇总了Java中java.awt.Color.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Color.equals方法的具体用法?Java Color.equals怎么用?Java Color.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Color的用法示例。


在下文中一共展示了Color.equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.awt.Color; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    createUI();
    Robot robot = new Robot();
    robot.waitForIdle();
    Rectangle rect = window.getBounds();
    rect.x += rect.width - 10;
    rect.y += rect.height - 10;
    robot.delay(1000);
    Color c = robot.getPixelColor(rect.x, rect.y);
    try {
        if (!c.equals(Color.RED)) {
            throw new RuntimeException("Test Failed");
        }
    } finally {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                background.dispose();
                window.dispose();
            }
        });
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:SetShapeTest.java

示例2: main

import java.awt.Color; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    window.requestFocus();
    final ExtendedRobot robot = new ExtendedRobot();
    robot.setAutoDelay(200);
    robot.waitForIdle(1000);
    window.setBackground(Color.GREEN);
    robot.waitForIdle(1000);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:BackgroundIsNotUpdated.java

示例3: fixTextColor

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Fix foreground color if it is not readable on the background.
 */
private static Color fixTextColor(Color textColor, Color background) {
    if (background == null && textColor != null
            && textColor.equals(Color.WHITE)) {
        return Color.BLACK;
    } else if (textColor != null && background != null
            && colorDiff(textColor, background) < 10) {
        if (colorDiff(textColor, Color.WHITE)
                > colorDiff(textColor, Color.BLACK)) {
            return Color.WHITE;
        } else {
            return Color.BLACK;
        }
    } else {
        return textColor;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:OutWriter.java

示例4: checkPixel

import java.awt.Color; //导入方法依赖的package包/类
private synchronized boolean checkPixel(final Component c, final Color toMatch, final int x, final int y) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            final BufferedImage bi = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB);
            ((JComponent) c).paintAll(bi.getGraphics());
            int[] cArr = new int[3];
            bi.getData().getPixel(6, 200, cArr);
            checkColor = new Color(cArr[0], cArr[1], cArr[2]);
            //uncomment the code below for diagnosing painting problems
            /*
            JFrame jf = new JFrame() {
                public void paint (Graphics g) {
                    new ImageIcon (bi).paintIcon(this, g, 0, 0);
                    g.setColor (Color.RED);
                    g.drawLine(x, y, x, y);
                }
            };
            jf.setLocation (400,400);
            jf.setSize (500,500);
            jf.show();
             */
        }
    });
    boolean result = toMatch.equals(checkColor);
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SheetTableTest.java

示例5: setColor

import java.awt.Color; //导入方法依赖的package包/类
void setColor(Color color) {
    if (!color.equals(this.color)) {
        this.color = color;
        this.model.setColor(color.getRGB(), this.values);
        for (int i = 0; i < this.model.getCount(); i++) {
            this.spinners[i].setValue(this.values[i]);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:ColorPanel.java

示例6: getBackgroundA

import java.awt.Color; //导入方法依赖的package包/类
@Override
public Color getBackgroundA() {
    Color background = functions.get(0).getBackground();
    for (int i = 1; i < functions.size(); i++) {
        if (!background.equals(functions.get(i).getBackground()))
            return null;
    }
    return background;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:10,代码来源:MouseSelection.java

示例7: setColorSuccess

import java.awt.Color; //导入方法依赖的package包/类
public void setColorSuccess(Color colorSuccess) {
    Parameters.notNull("colorSuccess", colorSuccess);               //NOI18N
    if (!colorSuccess.equals(this.colorSuccess)) {
        Color oldColorSuccess = this.colorSuccess;
        this.colorSuccess = colorSuccess;
        pcs.firePropertyChange(PROP_COLOR_SUCCESS, oldColorSuccess,
                colorSuccess);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OutputOptions.java

示例8: setStrikeThroughColor

import java.awt.Color; //导入方法依赖的package包/类
public @Override void setStrikeThroughColor(Color strikeThroughColor) {
    if ((strikeThroughColor != this.strikeThroughColor)
        && (strikeThroughColor == null
            || !strikeThroughColor.equals(this.strikeThroughColor))
    ) {
        flush();
        this.strikeThroughColor = strikeThroughColor;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:DrawGraphics.java

示例9: createPlotBackgroundColorDialog

import java.awt.Color; //导入方法依赖的package包/类
private void createPlotBackgroundColorDialog() {
	Color oldColor = getPlotConfiguration().getPlotBackgroundColor();
	if (oldColor == null) {
		oldColor = Color.white;
	}
	Color newBackgroundColor = JColorChooser.showDialog(this,
			I18N.getGUILabel("plotter.configuration_dialog.global_config_panel.plot_background_color_title.label"),
			oldColor);
	if (newBackgroundColor != null && !newBackgroundColor.equals(oldColor)) {
		getPlotConfiguration().setPlotBackgroundColor(newBackgroundColor);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:GlobalConfigurationPanel.java

示例10: main

import java.awt.Color; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsDevice.WindowTranslucency mode = GraphicsDevice.WindowTranslucency.TRANSLUCENT;
        boolean translucencyCheck = gd.isWindowTranslucencySupported(mode);
        if(!translucencyCheck) {
            return;
    }

        Robot robot = new Robot();
        // create a GUI
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });
        robot.waitForIdle();
        Color opaque = robot.getPixelColor(dlgPos.x + 100, dlgPos.y + 100);

        // set Dialog Opacity
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                dialog.setOpacity(OPACITY);
            }
        });
        robot.waitForIdle();

        // iconify frame
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                frame.setExtendedState(JFrame.ICONIFIED);
            }
        });
        robot.waitForIdle();

        // deiconify frame
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                frame.setExtendedState(JFrame.NORMAL);
            }
        });
        robot.waitForIdle();

        Color transparent = robot.getPixelColor(dlgPos.x + 100, dlgPos.y + 100);
        if (transparent.equals(opaque)) {
            frame.dispose();
            throw new RuntimeException("JDialog transparency lost "
                    + "upon iconify/deiconify sequence");
        }
        frame.dispose();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:61,代码来源:TransparencyTest.java

示例11: checkTitleColor

import java.awt.Color; //导入方法依赖的package包/类
/**
  * Check behaviour of method TitledBorder.getTitleColor()
  */
private static void checkTitleColor() {
    TitledBorder titledBorder = new TitledBorder(new EmptyBorder(1, 1, 1, 1));
    Color defaultColor = UIManager.getLookAndFeelDefaults().getColor("TitledBorder.titleColor");
    Color titledBorderColor = titledBorder.getTitleColor();

    // check default configuration
    if (defaultColor == null) {
        if (titledBorderColor == null) {
            return;
        }
        else {
            throw new RuntimeException("TitledBorder default color should be null");
        }
    }
    if (!defaultColor.equals(titledBorderColor)) {
        throw new RuntimeException("L&F default color " + defaultColor.toString()
                                 + " differs from TitledBorder color " + titledBorderColor.toString());
    }

    // title color is explicitly specified
    Color color = Color.green;
    titledBorder.setTitleColor(color);
    if (!color.equals(titledBorder.getTitleColor())) {
        throw new RuntimeException("TitledBorder color should be " + color.toString());
    }

    // title color is unspecified
    titledBorder.setTitleColor(null);
    if (!defaultColor.equals(titledBorder.getTitleColor())) {
        throw new RuntimeException("L&F default color " + defaultColor.toString()
                                 + " differs from TitledBorder color " + titledBorderColor.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:Test7022041.java

示例12: createLegendFrameColorDialog

import java.awt.Color; //导入方法依赖的package包/类
private void createLegendFrameColorDialog() {
	Color oldColor = getPlotConfiguration().getLegendConfiguration().getLegendFrameColor();
	if (oldColor == null) {
		oldColor = LegendConfiguration.DEFAULT_LEGEND_FRAME_COLOR;
	}
	Color newBackgroundColor = JColorChooser.showDialog(this,
			I18N.getGUILabel("plotter.configuration_dialog.global_config_panel.legend_frame_color_title.label"),
			oldColor);
	if (newBackgroundColor != null && !(newBackgroundColor.equals(oldColor))) {
		getPlotConfiguration().getLegendConfiguration().setLegendFrameColor(newBackgroundColor);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:LegendConfigurationPanel.java

示例13: getShards

import java.awt.Color; //导入方法依赖的package包/类
/** Returns number of shards that we have. Works only if raid popup is open. Returns -1 in case it cannot read number of shards for some reason. */
private int getShards() {
	MarvinSegment seg;
	
	seg = detectCue(cues.get("RaidPopup"));
	
	if (seg == null) // this should probably not happen
		return -1;
	
	int left = seg.x2+1;
	int top = seg.y1+9;
	
	final Color full = new Color(199, 79, 175);
	
	int value = 0;

	// we measure it at 4 points:
	Color c1 = new Color(img.getRGB(left+10, top));
	Color c2 = new Color(img.getRGB(left+30, top));
	Color c3 = new Color(img.getRGB(left+50, top));
	Color c4 = new Color(img.getRGB(left+70, top));
	
	if (c1.equals(full)) value++;
	if (c2.equals(full)) value++;
	if (c3.equals(full)) value++;
	if (c4.equals(full)) value++;
	
	return value;
}
 
开发者ID:Betalord,项目名称:BHBot,代码行数:30,代码来源:MainThread.java

示例14: performTest

import java.awt.Color; //导入方法依赖的package包/类
@Override
protected boolean performTest() {
    int BORDER_SHIFT = frameBorderCounter();
    BORDER_SHIFT = Math.abs(BORDER_SHIFT) == 1 ? BORDER_SHIFT : (BORDER_SHIFT / 2);
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                lLoc = frame.getLocationOnScreen();
                size = frame.getSize();
                lLoc2 = frame.getContentPane().getLocationOnScreen();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException("Where is frame?");
    }
    Robot robot = Util.createRobot();
    robot.setAutoDelay(ROBOT_DELAY/2);

    // resize window
    robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
    Util.waitForIdle(robot);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 0; i < 10; i++) {
        robot.mouseMove(lLoc.x + size.width / 2 + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT + 20 * i);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT, lLoc.y + size.height + BORDER_SHIFT);
    Util.waitForIdle(robot);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 0; i < 10; i++) {
        robot.mouseMove(lLoc.x + size.width + BORDER_SHIFT + 20 * i, lLoc.y + size.height + BORDER_SHIFT);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    Util.waitForIdle(robot);
    // check if component is visible on the opened space
    try {
        Thread.sleep(300); //some more wait for Solaris (for some reason)
    }catch(Exception ex) {}
    lLoc2.translate(75, 75);
    Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);
    System.out.println("Actual: "+c+", expected: "+AWT_VERIFY_COLOR);

    if (!c.equals(AWT_VERIFY_COLOR)) {
        fail("HW component is not visible after resizing");
    }

    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:MixingFrameResizing.java

示例15: createLegendBackgroundColorDialog

import java.awt.Color; //导入方法依赖的package包/类
private void createLegendBackgroundColorDialog() {
	Color oldColor = getPlotConfiguration().getLegendConfiguration().getLegendBackgroundColor();
	if (oldColor == null) {
		oldColor = LegendConfiguration.DEFAULT_LEGEND_BACKGROUND_COLOR;
	}
	Color newBackgroundColor = JColorChooser.showDialog(this,
			I18N.getGUILabel("plotter.configuration_dialog.global_config_panel.legend_background_color_title.label"),
			oldColor);
	if (newBackgroundColor != null && !(newBackgroundColor.equals(oldColor))) {
		getPlotConfiguration().getLegendConfiguration().setLegendBackgroundColor(newBackgroundColor);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:13,代码来源:LegendConfigurationPanel.java


注:本文中的java.awt.Color.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。