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:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class java2 extends JPanel {
public java2 () {
setLayout(new Gridlayout(2,1));
JList lista = new JList(java2.ids);
add(new JScrollpane(lista));
JComboBox combo=new JComboBox();
for (int i=0;i<100 ;i++ ) {
combo.addItem(Integer.toString(i));
add(combo);
}
}
public static void main(String args[]) {
java1 lista=new Java1();
JFrame ventana=new JFrame();
ventana.getContentPane().add(lista,BorderLayout.CENTER);
ventana.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent evt){System.exit(0);}});
ventana.setSize(200,200);
ventana.setVisible(true);
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class java2 extends JPanel {
public java2 () {
setLayout(new Gridlayout(2,1));
JList lista = new JList(java2.ids);
add(new JScrollpane(lista));
JComboBox combo=new JComboBox();
for (int i=0;i<100 ;i++ ) {
combo.addItem(Integer.toString(i));
add(combo);
}
}
public static void main(String args[]) {
java1 lista=new Java1();
JFrame ventana=new JFrame();
ventana.getContentPane().add(lista,BorderLayout.CENTER);
ventana.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent evt){System.exit(0);}});
ventana.setSize(200,200);
ventana.setVisible(true);
}
}
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?
java2.java:8: error: cannot find symbol
setLayout(new Gridlayout(2,1));
^
symbol: class Gridlayout
location: class java2
java2.java:9: error: cannot find symbol
JList lista = new JList(java2.ids);
^
symbol: variable ids
location: class java2
java2.java:10: error: cannot find symbol
add(new JScrollpane(lista));
^
symbol: class JScrollpane
location: class java2
java2.java:18: error: cannot find symbol
java1 lista=new Java1();
^
symbol: class java1
location: class java2
java2.java:18: error: cannot find symbol
java1 lista=new Java1();
^
symbol: class Java1
location: class java2
Note: java2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
java2.java:8: error: cannot find symbol
setLayout(new Gridlayout(2,1));
^
symbol: class Gridlayout
location: class java2
java2.java:9: error: cannot find symbol
JList lista = new JList(java2.ids);
^
symbol: variable ids
location: class java2
java2.java:10: error: cannot find symbol
add(new JScrollpane(lista));
^
symbol: class JScrollpane
location: class java2
java2.java:18: error: cannot find symbol
java1 lista=new Java1();
^
symbol: class java1
location: class java2
java2.java:18: error: cannot find symbol
java1 lista=new Java1();
^
symbol: class Java1
location: class java2
Note: java2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
To copy to clipboard, switch view to plain text mode
Bookmarks