Results 1 to 2 of 2

Thread: Regarding for JComboBox in Java

  1. #1

    Default Regarding for JComboBox in Java

    Hello Everyone, I am facing an error while working on a java project. I got the next simple program in Java, I got it online because I'm trying to learn Java programming but don't know how to fix it:

    Qt Code:
    1. import javax.swing.*;
    2. import java.awt.*;
    3. import java.awt.event.*;
    4.  
    5. public class java2 extends JPanel {
    6.  
    7. public java2 () {
    8. setLayout(new Gridlayout(2,1));
    9. JList lista = new JList(java2.ids);
    10. add(new JScrollpane(lista));
    11. JComboBox combo=new JComboBox();
    12. for (int i=0;i<100 ;i++ ) {
    13. combo.addItem(Integer.toString(i));
    14. add(combo);
    15. }
    16. }
    17. public static void main(String args[]) {
    18. java1 lista=new Java1();
    19. JFrame ventana=new JFrame();
    20. ventana.getContentPane().add(lista,BorderLayout.CENTER);
    21. ventana.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent evt){System.exit(0);}});
    22. ventana.setSize(200,200);
    23. ventana.setVisible(true);
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    I'm getting the next problems every time I compile this program on Interviewbit, Can anyone suggest me? How to fix this?

    Qt Code:
    1. java2.java:8: error: cannot find symbol
    2. setLayout(new Gridlayout(2,1));
    3. ^
    4. symbol: class Gridlayout
    5. location: class java2
    6. java2.java:9: error: cannot find symbol
    7. JList lista = new JList(java2.ids);
    8. ^
    9. symbol: variable ids
    10. location: class java2
    11. java2.java:10: error: cannot find symbol
    12. add(new JScrollpane(lista));
    13. ^
    14. symbol: class JScrollpane
    15. location: class java2
    16. java2.java:18: error: cannot find symbol
    17. java1 lista=new Java1();
    18. ^
    19. symbol: class java1
    20. location: class java2
    21. java2.java:18: error: cannot find symbol
    22. java1 lista=new Java1();
    23. ^
    24. symbol: class Java1
    25. location: class java2
    26. Note: java2.java uses unchecked or unsafe operations.
    27. Note: Recompile with -Xlint:unchecked for details.
    28. 5 errors
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,249
    Thanks
    304
    Thanked 868 Times in 855 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Regarding for JComboBox in Java

    Why are you posting a question about java, swing, and awt on a Qt forum? You should find a forum that is more relevant. "General Programming" does not mean any programming question. It still must be relevant to Qt.

    Your errors indicate you have not imported the files that contain the classes that the errors point to. It is also possible that your java installation does not contain the components you need and should be updated. Probably if you Google for the name of one of these classes, you will find out which imports are needed.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Why Qt When java is there?
    By Noks in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 13:23
  2. Qt and Java
    By gmseed in forum General Discussion
    Replies: 1
    Last Post: 21st November 2009, 12:55
  3. [java] Sax
    By mickey in forum General Discussion
    Replies: 0
    Last Post: 29th September 2009, 10:42
  4. Which way I take C++ or Java ?
    By sby in forum Newbie
    Replies: 1
    Last Post: 27th January 2009, 09:29
  5. [java] map
    By mickey in forum General Programming
    Replies: 1
    Last Post: 16th November 2008, 13:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.