Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Something I've never seen from the compiler is what I'm trying clear up

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    62
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default Something I've never seen from the compiler is what I'm trying clear up

    I'm getting this message from my compiler...

     

    Note: ShadeDesigner.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.




    ...and it seems to go away when I take away this statement with the comment...

     

    private void makeStylePanel()
    {
    stylePanel = new JPanel();

    styleBox = new JComboBox(styles); // This one right here.

    styleBox.setEditable(false);

    styleBox.addActionListener(new styleBoxListener());

    stylePanel.add(styleBox);
    }




    or write it like this.

     


    styleBox = new JComboBox();





    So, what exactly do these notes mean, and how do I clear them up?


  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: Something I've never seen from the compiler is what I'm trying clear up

    Hello.
    Usually these warnings appears with Java Collections sometimes.
    And they are always ignored as per my experience.

    Syed.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Something I've never seen from the compiler is what I'm trying clear up

    That error appears because you didn't specify a generic parameter for the JComboBox.

    It's not strictly required (Java will default to Object which allows all objects, done for historical reasons), but it's usually a good idea to specify it.

    styleBox = new JComboBox<Object>(styles); // You probably should pick a more specific generic type than Object

    java - What causes javac to issue the "uses unchecked or unsafe operations" warning - Stack Overflow

  4. The Following User Says Thank You to helloworld922 For This Useful Post:

    SOG (August 14th, 2013)

  5. #4
    Member
    Join Date
    Jul 2011
    Posts
    62
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default Re: Something I've never seen from the compiler is what I'm trying clear up

    Thanks helloworld922. I got rid of the warning.

Similar Threads

  1. How to clear the textArea?
    By dynamix24 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 25th, 2013, 08:46 AM
  2. Applet clear
    By chonch in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 24th, 2011, 12:40 PM
  3. getting errors needed to be clear
    By erinbasim in forum Enterprise JavaBeans
    Replies: 1
    Last Post: February 4th, 2010, 03:24 AM
  4. clear screen.
    By chronoz13 in forum Java Theory & Questions
    Replies: 10
    Last Post: December 5th, 2009, 07:27 AM
  5. Replies: 3
    Last Post: November 15th, 2008, 07:17 AM