Received: by 10.66.86.130 with SMTP id p2mr1615429paz.22.1354511532186; Sun, 02 Dec 2012 21:12:12 -0800 (PST) Received: by 10.50.213.33 with SMTP id np1mr1705448igc.3.1354511532133; Sun, 02 Dec 2012 21:12:12 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!kr7no15973634pbb.0!news-out.google.com!6ni24277pbd.1!nntp.google.com!kr7no15973632pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Sun, 2 Dec 2012 21:12:11 -0800 (PST) In-Reply-To: <511a3304-a598-413b-a630-b2e1454fd11c@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <511a3304-a598-413b-a630-b2e1454fd11c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <07cd0b03-3086-4ae5-8046-ee77d4900d37@googlegroups.com> Subject: Re: JFrame issues From: Lew Injection-Date: Mon, 03 Dec 2012 05:12:12 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:20055 K wrote: > Here is my script It's not a script. > does anyone know why this isn't working What is "working" for this program? What happens instead? Copy and paste your error messages so we don't have to tire out our crystal balls. You should place your program in a package, rather than the "default" (empty) package. > import javax.swing.JFrame; > import javax.swing.ImageIcon; > import javax.swing.JLabel; > import javax.swing.Continer; ^ You should get a compilation error on this import. > class Jframe { Get in the habit of declaring classes 'public', and not naming them so similarly to standard API types. > public static void main(String[] args) { > JFrame frame = new JFrame(); You failed to put the GUI work on the Event Dispatch Thread (EDT). > ImageIcon icon = new ImageIcon(puffin.jpg); ^ This line should raise a compilation error. > JLabel label = new JLable (icon); ^ This line should raise a compilation error. > Container contentPane = frame.getContentPane(); > contentPane.add(label); > frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > frame.pack(); > frame.setVisible(true); > } > } You are getting compilation errors that tell you exactly where you are being careless. Use 'invokeLater()' to do GUI things (like defining your frame and all that). Doing GUI off the EDT and doing non-GUI on the EDT are the twin sins of Swing. Repent your sins. -- Lew