Comparing colors in java

import java.awt.*;
import java.awt.event.*;
import java.lang.Object;
import java.awt.Robot;
public class Robot04 {
public static void main(String[] args) throws AWTException{
Color UnkownColor = new Color(0, 102, 255);
Color greenn = new Color(0, 204, 51);
Color bluu = new Color(0, 102, 255);
If (UnkownColor = bluu) System.out.print(" the color is blue");
}This doesn't successfully compare the unknown and blue color and neither does ==, How do I compare them?

if(aColor.equals(otherColor)) { /* ... */ }http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html
= is the assignment operator;
== can be used to compare primitives;
.equals(...) is used to compare Objects for equality.

Similar Messages

  • How to get the silverish white color in Java

    Hi
    I want to know how to get the silver color in Java
    I am currently using
    R , G , B
    setBackground(new color(255,255,255));
    I am getting bright white color.
    How do I get the polished white(silverish white color) color.
    Thank You

    RGB Color Chart...
    http://www.htmlcenter.com/tutorials/tutorials.cfm/89/General/
    perhaps new Color(223,223,255) ???

  • How to remove and change the color of Java cup and border

    Hi to all,
    How to remove and change the color of Java cup and border.
    Thanks in advance
    khiz_eng

    This is just an Image. You would need to create your own image and call setIconImage(Image) on your JFrame.

  • b font color ='red' Java JDBC and Oracle DB URGENT HELP PLEASE /font /b

    Hello, I am a newbie. I'm very interested in Java in relation to JDBC, Oracle and SAP.I am trying to connect to an Oracle DB and I have problems to display the output on the consule in my application. What am I doing wrong here . Please help me. This is my code: Please Explain
    import java.sql.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    public class SqlConnection {
         public static void main(String[] args) {
              Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
              Connection con = DriverManager.getConnection
              ("jdbc:orcle:thin:@34.218.5.3:1521:ruka","data","data"); //making the connection.
              Statement stmt = con.createStatement ();// Sending a query to the database
              ResultSet rs = stmt.executeQuery("SELECT man,jean,test,kok FROM sa_kostl");
              while (rs.next()) {
                   String man = rs.getString("1");
                   String jean = rs.getString("2");
                   String test = rs.getString("3");
                   String kok = rs.getString("4");
                   System.out.println( man, jean, test,kok );//here where my the
                                                 //compiler gives me errors
              stmt.close();
              con.close();
    }

    <b><font color ='red'>Java JDBC and Oracle DB URGENT HELP PLEASE</font></b>Too bad your attempt at getting your subject to have greater attention failed :p

  • How to change InputField background color using Java Code

    Hi,
    In my application use will enter some set of Cost Centers in a table and submits request.
    In return i will get a list of invalid cost centers which i need to display in a table with input field
    In that table all cost centers will displayed, but invalid cost centers should be highlighted or background color should some other color. like red or yellow.
    Is it possible using java code to change a input field color.
    Please help me.
    Thanks

    Hi,
        declare a error message in message pool and declare a method say "checkCostCenters " and in this method, u can check whether it is a valid cost center .. if it is invalid cost center , then throw the erro message using the below code :
    wdComponentAPI.getMessageManager().reportContextAttributeMessage(
                        inputfieldattibutePointer, IMessageProgramPlanComp.ur error message,
                        new Object[] );
    for getting pointer and label use the below code:
    IWDAttributePointer inputfieldPointer = URNODEELEMENTElement
                        .getAttributePointer(URNODEELEMENT.ATTRIBUTENAME);
              String inputfieldLabel = wdContext.nodeURVALUENODE.getNodeInfo()
                        .getAttribute(URNODELEMENT.ATTRIBUTE).getSimpleType()
                        .getFieldLabel();
    hope it helps..
    Thanks and Regards

  • How to change object background color on  java run time

    Hi,
    I create object loading program. my problem is run time i change object background color using color picker. i select any one color of color picker than submit. The selecting color not assign object background.
    pls help me? How to run time change object background color?
    here follwing code
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.ParsingErrorException;
    import com.sun.j3d.loaders.IncorrectFormatException;
    import com.sun.j3d.loaders.Scene;
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.io.*;
    import com.sun.j3d.utils.behaviors.vp.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.awt.Graphics ;
    import javax.swing.*;
    public class ObjLoad1 extends Applet implements ActionListener
    private boolean spin = false;
    private boolean noTriangulate = false;
    private boolean noStripify = false;
    private double creaseAngle = 60.0;
    private URL filename = null;
    private SimpleUniverse u;
    private BoundingSphere bounds;
    private Panel cardPanel;
    private Button Tit,sub;
    private CardLayout ourLayout;
    private BorderLayout bl;
    Background bgNode;
    BranchGroup objRoot;
    List thelist;
    Label l1;
    public BranchGroup createSceneGraph()
    BranchGroup objRoot = new BranchGroup();
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.7);
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objScale.addChild(objTrans);
    int flags = ObjectFile.RESIZE;
    if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
    if (!noStripify) flags |= ObjectFile.STRIPIFY;
    ObjectFile f = new ObjectFile(flags,(float)(creaseAngle * Math.PI / 180.0));
    Scene s = null;
         try {
              s = f.load(filename);
         catch (FileNotFoundException e) {
         System.err.println(e);
         System.exit(1);
         catch (ParsingErrorException e) {
         System.err.println(e);
         System.exit(1);
         catch (IncorrectFormatException e) {
         System.err.println(e);
         System.exit(1);
         objTrans.addChild(s.getSceneGroup());
         bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
    if (spin) {
         Transform3D yAxis = new Transform3D();
         Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,0,0,4000,0,0,0,0,0);
         RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,objTrans,yAxis,0.0f,(float) Math.PI*2.0f);
         rotator.setSchedulingBounds(bounds);
         objTrans.addChild(rotator);
    //Background color setting
    Color3f bgColor = new Color3f(100,200,230);
    bgNode = new Background(bgColor);
    bgNode.setApplicationBounds(bounds);
    objRoot.addChild(bgNode);
    return objRoot;
    private void usage()
    System.out.println("Usage: java ObjLoad1 [-s] [-n] [-t] [-c degrees] <.obj file>");
    System.out.println("-s Spin (no user interaction)");
    System.out.println("-n No triangulation");
    System.out.println("-t No stripification");
    System.out.println("-c Set crease angle for normal generation (default is 60 without");
    System.out.println("smoothing group info, otherwise 180 within smoothing groups)");
    System.exit(0);
    } // End of usage
    public void init() {
    if (filename == null) {
    try {
    URL path = getCodeBase();
    filename = new URL(path.toString() + "./galleon.obj");
    catch (MalformedURLException e) {
         System.err.println(e);
         System.exit(1);
         //setLayout(new BorderLayout());
         //setLayout(new GridLayout(5,0));
         //setLayout(new CardLayout());
         //setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);
    add(c);
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);
    ViewingPlatform viewingPlatform = u.getViewingPlatform();
    PlatformGeometry pg = new PlatformGeometry();
    Color3f ambientColor = new Color3f(45,27,15);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    pg.addChild(ambientLightNode);
    Color3f light1Color = new Color3f(111,222,222);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    pg.addChild(light1);
    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(bounds);
    pg.addChild(light2);
    viewingPlatform.setPlatformGeometry(pg);
    viewingPlatform.setNominalViewingTransform();
    if (!spin) {
    OrbitBehavior orbit = new OrbitBehavior(c,OrbitBehavior.REVERSE_ALL);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    orbit.setSchedulingBounds(bounds);
    viewingPlatform.setViewPlatformBehavior(orbit);     
    u.addBranchGraph(scene);
         public ObjLoad1(String[] args) {
              if (args.length != 0) {
                   for (int i = 0 ; i < args.length ; i++) {
                        if (args.startsWith("-")) {
                             if (args[i].equals("-s")) {
                                  spin = true;
                             } else if (args[i].equals("-n")) {
                                  noTriangulate = true;
                             } else if (args[i].equals("-t")) {
                                  noStripify = true;
                             } else if (args[i].equals("-c")) {
                                  if (i < args.length - 1) {
                                       creaseAngle = (new Double(args[++i])).doubleValue();
                                  } else usage();
                             } else {
                                  usage();
                        } else {
                             try {
                                  if ((args[i].indexOf("file:") == 0) ||
                                            (args[i].indexOf("http") == 0)) {
                                       filename = new URL(args[i]);
                                  else if (args[i].charAt(0) != '/') {
                                       filename = new URL("file:./" + args[i]);
                                  else {
                                       filename = new URL("file:" + args[i]);
                             catch (MalformedURLException e) {
                                  System.err.println(e);
                                  System.exit(1);
    public void actionPerformed(ActionEvent e)
         if (e.getSource() == Tit)
    //Color Picker tool
              Color c1 = JColorChooser.showDialog(((Component)e.getSource()).getParent(),"Zaxis Color Picker", Color.blue);
              cardPanel.setBackground(c1);
              objRoot.removeChild(bgNode);
              int a = c1.getRed();
              int b = c1.getBlue();
              int c = c1.getBlue();
              System.out.println(a);
              System.out.println(b);
              System.out.println(c);
              Color3f ccc = new Color3f(a,b,c);
              bgNode.setApplicationBounds(bounds);
         objRoot.addChild(bgNode);
         else
              System.out.println("mathi");
    public ObjLoad1()
    Tit = new Button("BG Color");
    sub = new Button("Object Color");
    cardPanel = new Panel();
    cardPanel.add(Tit);
    cardPanel.add(sub);
    //cardPanel.add(l1);
    //cardPanel.add(thelist);
    sub.addActionListener(this);
    Tit.addActionListener(this);
    // thelist.addActionListener(this);
    //setLayout for applet to be BorderLayout
    this.setLayout(new BorderLayout());
    //button Panel goes South, card panels go Center
    this.add(cardPanel, BorderLayout.SOUTH);
    //this.add(cardPanel, BorderLayout.CENTER);     
    this.setVisible(true);
    public void destroy() {
    public static void main(String[] args) {
         new MainFrame(new ObjLoad1(args),400, 400);

    hi,
    i am using setColor(Color3f color) method
    like
    if (e.getSource() == Tit)
              Color c1 = JColorChooser.showDialog(((Component)e.getSource()).getParent(),"Zaxis Color Picker", Color.blue);
              bgColor = new Color3f(c1);
              System.out.println(bgColor.get());
         bgNode.setColor(bgColor);
         bgNode.setApplicationBounds(bounds);
         objRoot.addChild(bgNode);
    but error will be displayed
    like
    javax.media.j3d.CapabilityNotSetException: Background: no capability to set color
         at javax.media.j3d.Background.setColor(Background.java:307)
         at ObjLoad1.actionPerformed(ObjLoad1.java:230)
         at java.awt.Button.processActionEvent(Unknown Source)
         at java.awt.Button.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    pls help me

  • How can i change backgroud color in Java ME Platform SDK 3?

    Hello.
    Yesterday i had donwloaded Java ME Platform SDK 3.0. It is IDE based on NetBeans core, but i didn't find any facility to change default colors. (NetBeans have option to change color theme). I am don't like working when background color is white, i prefer black. So, how change a background color? Can anybody help me to figure this problem out?
    p.s. sorry for my bad english (

    Hello,
    Unfortunately it is not possible. We will think about it for next release. Java ME SDK is not supposed to offer full IDE functionality (e.g. changing editor colors), that's why some features are missing. For full IDE support use NetBeans IDE with Mobility support.

  • How to compare date in java

    Hi,
    i am devloping a form. in that form i have two text filed for entering dates which is From Date filed and To Date filed. I have to write a java script to check wether the From date is greater than To Date then prompt the user that the date is not correct. The formate of the date " mm-dd-yyy "
    i need help to compare these date
    Qaiser
    Email:[email protected]

    Hey, I do that same thing quite a bit. This is probably cheating and probably looks ugly to the pro's but it works for me.
    the textfields give a string that is in the format dd/MM/yyy, so convert that to a date object something like this
    String date1= text1.getText();
    String date2 = text2.getText();
    SimpleDateFormat sdf = new SimpleDateFormat(dd/MM/yyy);
    try{
    sdf.setLenient(true);
    Date d = sdf.parse(date1);
    }catch(ParseException p){"System.out.println("I take exception to that");
    then do the same for date2.
    then try
    if(date1.compareTo(date2) >0)
    {System.out.println("the first date is greater than the second date");}
    You can check out the java.util.Date api.
    JUst passing on the knowledge have passed to me! Cheers!! Oz.

  • Interpret ansi colors in java

    Hello there,
    I'm working on a client in java. The raw incoming text has all kinds of characters indicating the colors and other attributes of the text (ansi)
    like..
    [1;37m Yadda yadda [0m
    etc...
    Does anyone know if there's a pane or a class in java that interprets this and displays the text correctly in the right color?
    Thanks in advance,
    Dyte

    Hello there,
    I'm working on a client in java. The raw incoming text has all kinds of characters indicating the colors and other attributes of the text (ansi)
    like..
    [1;37m Yadda yadda [0m
    etc...
    Does anyone know if there's a pane or a class in java that interprets this and displays the text correctly in the right color?
    Thanks in advance,
    Dyte

  • System colors in Java

    I am working in a Java Swing Project. Here I have to set some System colors like Window Background, Button Face etc to the controls. I also need the way to set the color to be Transparent.
    Plz help me soon.
    Anila.

    Take a look at UIManager.
    You can write yourself a little loop to dump out all of the system defaults which are accessible via UIManager.get*() and adjustable via UIManager.put().
    If you want to adjust individual components then use their set() methods.

  • Comparable and comparator interface in java

    Hi All,
    How comparable and comparator interface works in java and when to use comparable and when to use comparator.please give me some example(code) as I am not able to understand the difference.
    Thanks
    Sumit
    Edited by: sumit7nov on May 17, 2009 4:45 AM

    Thanks,one more doubt.
    We have Collections.sort() method and we can sort any list by this method without implementing comparable or comparator interface.Then my question is when we need to implement comparable or comparator interface or when do we write our own compareTo() or compare() methods.
    Thanks
    Sumit

  • Color Webdynpro Java with OCA to Mobile 7.1

    HI
    I am developing an application with Webdynpro Java Mobile 7.1 with OCA.
    Does anyone know if you can give color to the elements (dropdown, inputField .....)?
    Best Regards.
    Maria Elena

    Hi:
    I put in the file configuration.properties :
    stylesheet.inputfiled.backgroundcolor = #FF0000  and this working properly
    but for the elements  
               stylesheet.dropdownbyindex.backgroundcolor=\#FF0000 NOT WORKING properly
    Is there a way to just change the color to a concrete and not all of that kind?
    Any idea???
    Best regards
    Maria Elena

  • Color coding java source

    Hi all
    Does anyone know how i can color code custom words in a java program when it is printd out. For example lets say i have a java source code and i wanna give attributs a color and constructers a different color and methods another color, but i wanna give it these colors when i print the java code. I am using an ANTLR parser to parse the code, i have a GUI which i made for it. But when i view the code in my GUI interface its black and white. So simply i just wanna give color to the source code.
    Thank You
    regards
    Rebaz

    I would post a request in these forums for everybody's opinion about IDEs, 123avaj.
    It is an important topic that is never discussed and I think many people might benefit (in more ways than one) from it.

  • Basic Colors in Java

    Hi.
    Hi. I have a method that generates random colors but now I need this method to generate basic colors, because with random colors again brings back too many colors. This is my method for random colors:
    Random randCol = new Random();
                          String cores = null;
                          for(int i = 0 ; i < faixas.split(",").length ; i++ ){
                              String html = String.format("#%06X", randCol.nextInt(0xFFFFFF+1));
                              if(cores == null)
                                  cores = html.replaceAll("#","") + ",";
                              else
                                  cores += html.replaceAll("#","") + ",";
                          } Is there any way to change this method so that it generates only basic colors?
    Thanks
    Marcos Santiago

    How about putting all 'basic' colors in an array. Then you generate a random number in the range of the array size and return the color stored in the array at the calculated index.
    Something like
        public Color randomColor()
            ArrayList<Color> colors = new ArrayList<Color>();
            colors.add(Color.yellow);
            colors.add(Color.white);
            colors.add(Color.red);
            colors.add(Color.pink);
            colors.add(Color.orange);
            colors.add(Color.magenta);
            // more to add...
            Date d = new Date();
            java.util.Random rnd = new java.util.Random(d.getTime());
            int lInt = rnd.nextInt(colors.size());
            return colors.get(lInt);
        }Timo

  • Adding Color to Java

    so i'm using the command document.write("The temperature is " + temp +" degress fahrenheit.");
    how do i get color inside to be used on just that sentence. do i need to add <p> </p> tags or what in order for it to work and be valid?

    I don't frakkin' believe this! That gap in the original post is where the OP included <p> </p> tags, and the forum software just passed them straight through. How many times do we have to fix this bug?
    Meanwhile, we still can't post code containing generic type parameters because the forum software keeps throwing in extra '>' characters. This is just embarassing.
    Oh, by the way, @OP, this is a Java forum, not a JavaScript forum. Do us all a favor and go away.

Maybe you are looking for

  • Black screen after clean Win 8.1 install

    I did a clean install from 10.9 Bootcamp utility and Win 8.1 Home full ISO. Installation is successful but after first reboot I got display drivers issue (black screen and system running on). I tried both ways and got the same issue: -     with Bootc

  • Loading content from multiple MiniDV tapes to one DVD

    I am being offered this "One Touch" feature on iDVD to copy my Camera footage to a DVD. I am wondering what the best process is to follow if I wanted to, say, merge :30 minutes of content from one MiniDV and :20 minutes of content from another. Shoul

  • I cant receive international messages on my e63

    please help me find out what could be the problem with my messaging.i cannot receive international messages on my e63 but i can send international messages. I can receive local and send local plus international but i cant receive international messag

  • IMac 2GHz PowerPC G5 and gen 7 ipod nano

    I have an iMac on 10.4.11 and have a gen 7 ipod requiring 10.6.8, my iMac is a 2GHz PowerPC G5, what can I do to make these compatible?

  • Contact sharing?

    I have set up family sharing me husband being 'in charge' and wife 'as member' Have put all current music and photos to wifes iPhone. Except how do i do the bit where i can add some of my contacts which are saved on my macbook and phone to my wifes,