Search:

Type: Posts; User: javapenguin

Search: Search took 0.19 seconds.

  1. Re: Storing color names and their hexadecimals in hasmap

    The ActionListener. It will call the setText() method, as it appears you already did. It just wasn't doing it because the JLabel had been null.
  2. Re: Storing color names and their hexadecimals in hasmap

    This code below, a slight alteration of your code, worked for me.




    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import...
  3. Re: Storing color names and their hexadecimals in hasmap

    Try initializing the variable "display".

    Then add it to your GUI.

    Also, try setting p1 to be your content pane or something.




    import javax.swing.*;
  4. Re: Storing color names and their hexadecimals in hasmap

    I was able to make something similar work, though I had the HashMap be a class variable rather than a final variable like you had it.


    import java.util.HashMap;
    import...
  5. Re: Storing color names and their hexadecimals in hasmap

    To make FF0000 show, do something like this

    System.out.println(map.get("Red"));

    The get method returns the value, if there is one, associated with that key.
  6. Re: Storing color names and their hexadecimals in hasmap

    Because Strings have to be enclosed by literals. It's taking them as variables.

    Try this

    map.put("Red", "FF0000");
Results 1 to 6 of 6