| | |
Swing Button question
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2006
Posts: 30
Reputation:
Solved Threads: 0
Hello,
I am very new to java so my question might seem stupid :p
anyway I am in a class where we are makeing a patron loading system for a library (every one else in the class is new to java also
) we have our basic form built and we have a submit button. what we want the button to do is once clicked it will display all the information entered and ask if the user would like to edit and continue, if they want to edit just take them back to the form so they can edit, if put send the information to a text file in comma seperated format.
right now I am having trouble getting the submit button to do anything. the code I am using right now is just a sample from a text book that once the submit button is clicked a pop up will open saying you have clicked the submit button, but I can't get it to work. Here is part of the code:
--------------------------------------------------------------------
it does not like this line:
any suggestion would be helpful, if the entire code would help I can paste that in also...but there is alot :p
Thanks
Stewie
I am very new to java so my question might seem stupid :p
anyway I am in a class where we are makeing a patron loading system for a library (every one else in the class is new to java also
) we have our basic form built and we have a submit button. what we want the button to do is once clicked it will display all the information entered and ask if the user would like to edit and continue, if they want to edit just take them back to the form so they can edit, if put send the information to a text file in comma seperated format.right now I am having trouble getting the submit button to do anything. the code I am using right now is just a sample from a text book that once the submit button is clicked a pop up will open saying you have clicked the submit button, but I can't get it to work. Here is part of the code:
Java Syntax (Toggle Plain Text)
JButton SubmitButton; pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); if (shouldFill) { //natural height, maximum width c.fill = GridBagConstraints.HORIZONTAL; } SubmitButton = new JButton("Submit"); if (shouldWeightX) { c.weightx = 0.5; } "omited code" ... ... ... SubmitButton = new JButton("Submit"); c.ipady = 0; //reset to default c.weighty = 1.0; //request any extra vertical space c.anchor = GridBagConstraints.PAGE_END; //bottom of space c.insets = new Insets(10,0,0,0); //top padding c.gridx = 7; //aligned with button 2 c.gridwidth = 2; //2 columns wide c.gridy = 13; //third row pane.add(SubmitButton, c); SubmitButton.addActionListener(new ButtonListener()); } private class ButtonListerner implements ActionListener { public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); if (actionCommand.equals("Submit")) { JOptionPane.showMessageDialog(null, "You clicked the first button."); } }
it does not like this line:
SubmitButton.addActionListener(new ButtonListener());any suggestion would be helpful, if the entire code would help I can paste that in also...but there is alot :p
Thanks

Stewie
Last edited by cscgal; Apr 26th, 2006 at 10:22 am.
Here's two links about file handling and making GUI's it's all you need.
Read them.
http://java.sun.com/docs/books/tutor.../io/index.html
http://java.sun.com/docs/books/tutor...tml#components
Read them.
http://java.sun.com/docs/books/tutor.../io/index.html
http://java.sun.com/docs/books/tutor...tml#components
![]() |
Similar Threads
- Win XP Won't Completely Shutdown (Windows tips 'n' tweaks)
- new to Swing, JTable questions (Java)
- My laptop sounds like a chipmunk (Windows NT / 2000 / XP)
- Running Tomcat on a webserver? (Java)
- Spelling Test using a button GUI environment..how do I create a brand new window? (Java)
- frequent degauss needed (Monitors, Displays and Video Cards)
Other Threads in the Java Forum
- Previous Thread: help please
- Next Thread: Java Encryption error
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui helpwithhomework html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls number oracle output print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows






