Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Null Pointer Exception in a GUI application
Haani Naz
Greenhorn
Posts: 23
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Marshal
Posts: 79151
377
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Damn! I split the
thread
incorrectly. Please keep reading
here
.
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Components Placement
how to center this button 1
JTabbedPane with Keyevents
AWT-EventQueue-0" - need Help
JList selection to int not working
More...