Example
#{example}"); ipb.editor_values.get('templates')['togglesource'] = new Template(""); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
Emoticons
"); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]3 Replies - 24 Views - Last Post: 50 minutes ago
#1
Reputation: 1
- Posts: 30
- Joined: 09-December 12
Posted Today, 01:00 PM
import javax.swing.*; import java.awt.event.*; import java.awt.*; public class CashierProgram { final int WIDTH = 430; final int HEIGHT = 310; JFrame frame = new JFrame(); public CashierProgram() { myComponents(); } private void myComponents() { JPanel jPanel1 = new JPanel(); JLabel jLabel1 = new JLabel(); JTextField jTextField1 = new JTextField(); JLabel jLabel2 = new JLabel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JPasswordField jPasswordField1 = new JPasswordField(); Container con = frame.getContentPane(); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setTitle("LOGIN"); frame.setResizable(false); frame.setSize(WIDTH,HEIGHT); jPanel1.setBorder(BorderFactory.createTitledBorder("")); jLabel1.setFont(new Font("Palatino Linotype", 1, 14)); jLabel1.setText("USERNAME:"); jLabel2.setFont(new Font("Palatino Linotype", 1, 14)); jLabel2.setText("PASSWORD:"); jButton1.setText("Login"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Exit"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 43, Short.MAX_VALUE) .addComponent(jButton1, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE) .addGap(40, 40, 40) .addComponent(jButton2, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jTextField1) .addComponent(jPasswordField1, GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(37, 37, 37) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPasswordField1, GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) .addGap(3, 3, 3))) .addGap(31, 31, 31) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap(50, Short.MAX_VALUE)) ); GroupLayout layout = new GroupLayout(con); con.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(13, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(55, Short.MAX_VALUE)) ); } private void jButton1ActionPerformed(ActionEvent evt) { String text = jTextField1.getText(); JOptionPane.showMessageDialog(null,text); } private void jButton2ActionPerformed(ActionEvent evt) { System.exit(0); } public static void main(String[] args) { CashierProgram cp = new CashierProgram(); } private JPanel jPanel1; private JLabel jLabel1; private JTextField jTextField1; private JLabel jLabel2; private JButton jButton1; private JButton jButton2; private JPasswordField jPasswordField1; }
Why is it that when I'm clicking the login button, it appears to have an error which is Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException and many more. Whenever I click that button, it appears. Please, help me. Thanks in advance.
Note: I made the layout of this program using NetBeans at the same time I'm using Dr. Java. I'm in a rush already and I'm not that familiar with the Layout Managers that's why I used NB. Btw, this program will prompt the user to input a username and password(which is fixed but it is not yet written in this post) then click the login button to proceed to another window. The other button serves for an exit button.
Is This A Good Question/Topic? 0
Replies To: Event Queue Error -- Null Pointer Exception
#2
Reputation: 0
- Posts: 16
- Joined: 18-January 13
Re: Event Queue Error -- Null Pointer Exception
Posted Today, 01:27 PM
Which button is the login button? Which Jbutton? Usually when there is a null pointer exception you declared a variable twice on accident.
#3
Reputation: 2113
- Posts: 8,802
- Joined: 20-September 08
Re: Event Queue Error -- Null Pointer Exception
Posted Today, 02:57 PM
Quote
JTextField jTextField1 = new JTextField();
Yes, you did declare it twice (and possibly others)
jTextField1 = new JTextField();
is what that should be
These could be of interest
http://technojeeves....with-cardlayout
http://technojeeves....tion-login-form
#4
Reputation: 8027
- Posts: 31,159
- Joined: 06-March 08
Re: Event Queue Error -- Null Pointer Exception
Posted 50 minutes ago
Your JButton are declared twice:- as instance variable
- as local variable in myComponents() method
and you will never learn Java using a GUI Builder. Write your own GUI and you won't have that stupid type of error
Page 1 of 1
Source: http://www.dreamincode.net/forums/topic/321619-event-queue-error-null-pointer-exception/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.