Home Answers Viewqa Applet button to accept user input

 
 


Thembekile
button to accept user input
1 Answer(s)      8 months ago
Posted in : Applet

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){ public string name,lastname,radiobutton,spinner;

name=JTextfield.getTextfield(); lastname=JTextfield.getTextfield(); show(new Studentinfoview(this)); connectDB(); } i cant figure how i am going to declare the radiobutton and spinner.The user input does not show on my Studentinfo.mdb database it just gives me an error.please help

View Answers

September 18, 2012 at 3:08 PM


Here is java swing example that accepts firstname, lastname and gender from user and insert to database.

import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SwingExample{
JTextField text;

public static void main(String[] args) throws Exception{
SwingExample sf=new SwingExample();
}

public SwingExample(){
JFrame f = new JFrame("Frame in Java Swing");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("First Name");
final JTextField jt1=new JTextField(15);
JLabel lbl2 = new JLabel("Last Name");
final JPasswordField jt2=new JPasswordField(15);
JLabel lbl3 = new JLabel("Gender");
final JRadioButton Male,Female;
ButtonGroup radioGroup=new ButtonGroup();
Male=new JRadioButton("Male");
radioGroup.add(Male);
Female=new JRadioButton("Female");
radioGroup.add(Female);
JButton button=new JButton("Submit");
text=new JTextField(15);
Male.addActionListener(al);
Female.addActionListener(al);
lbl1.setBounds(50,50,70,30);
lbl2.setBounds(50,90,70,30);
lbl3.setBounds(50,130,70,30);
button.setBounds(50,170,100,30);
jt1.setBounds(110,50,100,30);
jt2.setBounds(110,90,100,30);
Male.setBounds(110,130,100,30);
Female.setBounds(210,130,100,30);
text.setBounds(110,170,100,30);
text.setVisible(false);

button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String fname=jt1.getText();
String lname=jt2.getText();
String g=text.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("insert into data(firstname,lastname,gender) values(?,?,?)");
st.setString(1,fname);
st.setString(2,lname);
st.setString(3,g);
int i=st.executeUpdate();
JOptionPane.showMessageDialog(null,"Data is successfully inserted into database.");
}
catch(Exception ex){}
}
});
f.add(lbl1);
f.add(lbl2);
f.add(lbl3);
f.add(jt1);
f.add(jt2);
f.add(Male);
f.add(Female);
f.add(button);
f.add(text);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent e) {
text.setText(((JRadioButton) e.getSource()).getText());
}
};
}









Related Pages:
button to accept user input
button to accept user input  private void jButton1ActionPerformed... the radiobutton and spinner.The user input does not show on my Studentinfo.mdb... that accepts firstname, lastname and gender from user and insert to database
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
Accept command in Oracle
command in SQL Plus. The ACCEPT command in SQL Plus is used to take the input from... User input ACC[EPT] variable [NUM[BER]|CHAR|DATE] [FORMAT format] [DEFAULT... the Accept in SQLPlus. SQL> select * from user where username='&user_name
user input in java - Java Beginners
user input in java   i am trying to write a code to compute the average of 5 numbers but i dont know what to do for the program to accept user input  Hi import java.util.*; public class AverageExample { public
How to take input by user using jDialogue and use that input
How to take input by user using jDialogue and use that input  I am using NetBeans i have a 'Search by employee id' button . I want when user click this button a dialogue box appear which take employee_id as input from user
XP Bowling Game User input help
XP Bowling Game User input help  I was asked to do the XP Bowling Example as an assignment. I have the programme passing all tests, but now I need to make the code accept input from a user and display the scores/frames
input
input  a java program that will exchange the last names of two students that were input by a user
accept sentence from user and print all word starts with vowel and end with consonent
accept sentence from user and print all word starts with vowel and end with consonent  Write a program to accept a sentence. Print all the words that starts with vowel and end with a consonant. e.g. input by user "the purpose
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
input output
input to read the user input.. In this section, you will see how the standard I... Input And Output       Introduction The Java I/O means Java Input/Output and is a part
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
Java User Input
Java User Input  I am using Scanner class for user Input. Scanner s = new Scanner(System.in); String name = s.next(); but i am unable to store full name in name variable...how i can store full name plsss reply   use
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
user input to database
user input to database  /* * Studentinfo2App.java */ package studentinfo2; import java.sql.Connection; import java.sql.DriverManager; import... in my database user input from my applet does not show
calculation after if. user input
user input????   My apologies good evening peoples Once again I am...calculation after if. user input  System.out.print ("please select...[]args){ Scanner input=new Scanner(System.in); System.out.print
Accept Language and Accept Char set in Servlets
sends the user's language to the server using the Accept Language HTTP header... .style1 { font-weight: bold; } Accept Language and Accept Char set in Servlets   
JavaScript Array from Input
values in an array. The function insert ( )accept the value entered by the user... JavaScript Array from Input   ... you easy to understand an example of  Array from Input. The example create
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age
Simple input application in Echo3
an application which contains the window from where the user can  input a text and this value would be shown into the content pane when user will click... Simple input application in Echo3   
java user input - Java Beginners
java user input  how to input from keyboard? please give a example.  Hi Friend, There are lot of ways to input data from keyboard.You...:****** try{ System.out.print("Enter String:"); BufferedReader input = new
javascript focus input
the user and a submit button. This button calls the function setfocus() which checks whether user has entered some value to the input boxes one by one. If any one...;input type="button" id="name" onClick="setfocus()" value="Submit" />
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
Radio Button in HTML
Radio Button in HTML is a type of input form that allows a user to select one button from a group of button. When a user clicks on a radio button, it becomes checked, while all other button remains unchecked. <input type>
HTML5 input examples, Introduction and implementation of input tag.
HTML5 input examples, Introduction and implementation of input tag. Introduction:In this tutorial, you will see the use of input tag. The input tag is a input field in a form. In which user can insert data, and the type of data
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... that will communicate with the user at the command line and returns the user input. We have
Dialog Box Input Loop
When reading input in a loop user must have some way of indicating that the end... of the input is for the user to enter a special value to indicate... for empty string. Another common way for the user to indicate the end of the input
Input And Output
standard input to read the user input.. In this section, you will see how... Input And Output       Introduction The Java I/O means Java Input/Output and is a part of java.io
iPhone Input Field, iPhone Input Field Tutorial
iPhone Input Field Generally, input fields are used to take input from the users.  In iPhone application we can use Text Field to take the input. .... That keyboard can be customize according to our need i.e. if we wants the user
Create a input button inside js function
Create a input button inside js function  I call my js function from HTML code from another file. Now I would like to create a input button on page.... Now I would like to create a input button on page using createElement() in my
the App Store does not accept or distribute web apps
the App Store does not accept or distribute web apps  the App Store does not accept or distribute web apps We found the user interface of your app is not of sufficient quality to be appropriate for the App Store What could
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening the program. I am developing a college library management system, i would like
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey... record alphabetically (2) If user chooses choice1, the input data is stored in an ARRAY (or ARRAYLIST) until the user chooses to stop inputting data. Kindly
Show input dialog box
anything from user. Java Swing provides the facility to input any thing (whether.... The input dialog box contains two buttons, first is the "Ok" button..., this shows a button labeled by "Show Input Dialog Box" on the frame
keyboard input
keyboard input  how do I use JOptionPane to accept keyboard input? I know how to import but not specific command on input line   import javax.swing.*; class JOPtionPaneExample { public static void main(String
Array and input
[ ]={1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26}; i want to ask user to input one of the above numbers then i want to print the array without the number user input. how will i do tht
Keyboard Input
Java NotesKeyboard Input There are two approaches to getting keyboard input from the user. GUI (Graphical User Interface). Displaying a graphical text... of the old Teletype machine. Java was designed for graphical user interfaces (GUI
Submit comments in database when user clicks on submit button
Submit comments in database when user clicks on submit button... database when user clicks the submit button of the page. Create a database: First create a database named "usermaster" in MySql and table named "user
Java Graphical user interface
field, a text field to input the name and a â??Registerâ?? button. All of them...Java Graphical user interface  Hi, guys. I'm christina, need help with my home work Task 1: GUI Design and Implementation The user requirements
SQL IN Parameters
; A parameter is a placeholder that accept a user-defined value, whenever... an example, which create a procedure 'abc' and accept input parameter. The input parameter allows the invoker to pass the data into the procedure. 
JSP Back Button
;       Jsp Back Button enables the user back... and displayed in text area. The Back button takes the user back to the page they just came from. A Back button is created by INPUT type="button" value="
HTML5 input attribute, Define the type, alt and image  of input tag.
HTML5 input attribute, Define the type, alt and image  of input tag. Introduction:Here we will introduce you to about the type attribute of input tag. It is define the type of data. which can be insert by user. User can insert
Updating user profile
. When the user clicks the particular edit button, that data will get shown...(5)%></td> <td><input type="button" name="edit" value="Edit...Updating user profile  how should i provide user to update his
How to create file from input values in Jframe ?
How to create file from input values in Jframe ?  hi i m doing my project using java desktop application in netbeans.i designed a form to get the user's academic details and on clicking the submit button,it displays all
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below...; <input name="radiobutton" type="radio" value="radiobutton" /> </label></td> <td width="350"><input type
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below...; <input name="radiobutton" type="radio" value="radiobutton" /> </label></td> <td width="350"><input type
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below...; <input name="radiobutton" type="radio" value="radiobutton" /> </label></td> <td width="350"><input type
Input in Stateless Bean - EJB
Input in Stateless Bean  Hello, I am having problem in taking the input in stateless bean, when I am trying to get integer or double type input from the user in the client file, It shows me the error

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.