File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
Null Pointer Exception in a GUI application
Haani Naz
Greenhorn
Joined: May 30, 2010
Posts: 23
posted
Aug 30, 2011 01:56:45
0
Hi Guys,
i would like to extend this question by asking something about my code.
i'm basically attempting to use extended
JFrame
(to understand how it differs) but i've run into a problem.
i decided to post the code so it makes more sense:
package org.javaguitutorial.gui; import javax.swing.*; import java.awt.*; public class FirstGUI extends JFrame { private JButton button1,button2,button3; private JPanel myPanel; public FirstGUI(){ button1 = new JButton("shock me"); button1 = new JButton("bliss"); button1 = new JButton("huh?"); myPanel = new JPanel(); //add buttons to panel myPanel.add(button1); myPanel.add(button2); myPanel.add(button3); add(myPanel); //add panel to frame
followed by:
package org.javaguitutorial.gui; import javax.swing.*; import java.awt.*; public class FirstGUI_driver { public static void main(String[] args) { FirstGUI gui = new FirstGUI(); gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //enable exit feature gui.setVisible(true); //make frame visible gui.setSize(275, 180); //set size of frame
This fails to work - i get run time errors. Can somebody please tell me why..? thanks.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
4
posted
Aug 30, 2011 09:16:48
0
Damn! I split the thread incorrectly. Please keep reading
here
.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Null Pointer Exception in a GUI application
Similar Threads
AWT-EventQueue-0" - need Help
Components Placement
how to center this button 1
JTabbedPane with Keyevents
JList selection to int not working
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter