I extracted the following code from the tutorial:
import javax.swing.*; import java.util.Date; public class SwingGUI { public static void main( String[] args ) { JFrame f = new JFrame( "test" ); f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); f.setSize( 1500, 900 ); JLabel l = new JLabel( String.format( "%tT", new Date() ) ); f.add(l); f.setVisible( true ); } }
f.add(l); Two errors are highlighted and displayed:
Being relatively new to java, I don't quite understand what Eclipse is trying to tell me. What can I do to make it work?
edit: code works without line f.add(l); , so the problem is not that JFrame or JLabel was not found. After a short turn, I got rid of the first error, but the second still remains. The component cannot be resolved because it is indirectly referenced. What does it mean?
source share