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 3 of 3

Thread: perameterizing a combobox in eclipse makes gui builder give error

  1. #1
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default perameterizing a combobox in eclipse makes gui builder give error

    I use jdk 1.7 and jre7

    I'm using eclipse and im trying out the gui builder and i like it better than netbeans but when i make a combobox i get the warning to parameterize it so i do and then i look at the design window and it gives this error

    new JComboBox<String>(targetElement) is not valid source for component creation, it references not existing constructor.

    when i dont parameterize it its fine is there any way to fix this? this is the code for the combobox without the parameter

    String[] targetElement = {"Choose", "None", "Earth", "Wind", "Water", "Fire"};
    		JComboBox comboBox_3 = new JComboBox(targetElement);
    		comboBox_3.setFont(new Font("Tahoma", Font.BOLD, 11));
    		panel.add(comboBox_3);

    i guess its fine without but just curious on if this will cause problems if i dont parameterize or if i can just leave it without and be fine?


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: perameterizing a combobox in eclipse makes gui builder give error

    If you are going to declare a type parameter in the constructor, you also have to do it in the variable declaration. For example:

    ArrayList<Object> list = new ArrayList<>();
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    83
    My Mood
    Cynical
    Thanks
    3
    Thanked 9 Times in 9 Posts

    Default Re: perameterizing a combobox in eclipse makes gui builder give error

    Your problem is that your Eclipse Java compliance level is set to 1.6 or lower, and you've got to set your it to Java 1.7. You can do this for all of Eclipse by clicking on the Window menu, or on a project by project basis by right clicking on the project. Go into the set up menu, and into Java then Compiler and there set the compliance level.

Similar Threads

  1. Help needed to figure out why I keep getting error messages in Eclipse
    By RookieCodeWriter in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 18th, 2012, 11:31 AM
  2. Error in Eclipse, Norm redirected me here.
    By SilentNite17 in forum Java IDEs
    Replies: 3
    Last Post: February 14th, 2012, 09:48 PM
  3. [SOLVED] Populating second combobox from a combobox help!
    By ComputerSaysNo in forum AWT / Java Swing
    Replies: 7
    Last Post: October 18th, 2011, 09:01 AM
  4. Error Running Java in Eclipse
    By steadyonabix in forum Java IDEs
    Replies: 1
    Last Post: September 3rd, 2011, 10:28 PM
  5. Error when opening eclipse
    By BlackJavaCoder in forum Java IDEs
    Replies: 4
    Last Post: September 3rd, 2011, 07:57 AM