GUI testing



Share on Google+Share on Google+

James Bernard
GUI testing
3 Answer(s)      9 years ago
Posted in : Java Beginners

GUI testing in software testing

View Answers

April 4, 2008 at 5:41 PM


Now, use the code and get the answer.

import javax.swing.*;

public class DemoTryCatchDialog{
public static void main(String args[]){
String str_value;
boolean number;
int num;
str_value = JOptionPane.showInputDialog(null, "Please input an integer value");
number = true;
num = Integer.parseInt(str_value);
JOptionPane.showMessageDialog(null, "You entered number is: " + num);
catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "You did not enter a valid number");
number = false;

April 5, 2008 at 6:10 AM


April 8, 2008 at 5:18 PM

This can be done using KeyEvent

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

class GUIExample1 extends JFrame implements ActionListener
JLabel numberLabel;
JTextField numberTextField;
JButton displayButton;
public GUIExample1()
Container pane = getContentPane();
pane.setLayout(new FlowLayout());
numberLabel = new JLabel("Enter a number:");
numberTextField = new JTextField(4);
//calling the KeyEvent method
numberTextField.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent evt){
displayButton = new JButton("Enter");
setTitle("GUI Example");
public void actionPerformed(ActionEvent event)
Object source = event.getSource();
if (source == displayButton)
double result = Integer.parseInt(numberTextField.getText());
JOptionPane.showMessageDialog(null, "you entered " + (int)(result), "Hello", JOptionPane.PLAIN_MESSAGE);

//added newly ----- KeyEvent
public void numberTextField_KeyTyped(KeyEvent evt)
char dotChar=evt.getKeyChar();
int dot=(int)dotChar;
char c = evt.getKeyChar(); //character object to hold the typed character
if (!(Character.isDigit(c)))
JOptionPane.showMessageDialog(this,"characters are not allowed");

catch(Exception e){
System.out.println("---error in validation---"+e);
}//end of the method

public static void main(String[] args)
new GUIExample1();

This will work fine.. Try it



Related Tutorials/Questions & Answers:
GUI testing/software testing - Java Beginners
GUI testing/software testing  how to create a GUI testing/software testing module in java
GUI  How to GUI in Net-beans ... ??   Please visit the following link:
GUI  Write a GUI application for the WebBuy Company that allows a user to compose the three parts of a complete email message: the ??To:??, ??Subject:?? and ??Message:?? text. The ??To:??, and ??Subject:?? Text areas
Testing  Spring mvc with jdbcTemplate.i want to write mock testing how do i write please give me one simple code example for me   any body is there   No, try
GUI framework
GUI framework  what do u mean by GUI framework
GUI component
GUI component  How can a GUI component handle its own events
Convert the code to GUI
GUI code  GUI code
gui question
gui question  design a gui application for me and write its code in which the user enters a no. in a textfield and onn clicking the button the sum of the digits of the no. should be displayed. hint: suppose the user enters 12
GUI problem
GUI problem  Create a class called CDProgram and write a GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows: Amount deposited: 80000.00 Years: 15 Interest Rate: 7.75 Hint
java gui
java gui   friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user entered value in first textfield(jtext1) and pressed the enter key . the cursor
Convert the code to GUI
GUI Application example  GUI Application example
Convert the code to GUI
GUI Example  GUI Example code to learn
Java GUI
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
Version of gj-gui>gj-gui dependency
List of Version of gj-gui>gj-gui dependency
gui question
gui question  design a gui application and write code to accept a string from the user in a textfeild and print using option pane whether it is a palindrome or not. hint: abba is a palindrome   import java.awt.*; import
GUI problem
GUI problem  How do I make a Jbutton which is shaped like a circle. This button needs to be clicked in order to change color.   import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class
Convert the code to GUI
GUI Java JSP application  GUI Java JSP application
Convert the code to GUI
Java and GUI application Example  Java and GUI application Example
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
Convert the code to GUI
Java GUI Class Example  Java GUI Class Example
Convert the code to GUI
GUI Application Development   GUI Application Development
Convert the code to GUI
Write a GUI Application  best way to write a GUI based application
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
Convert the code to GUI
How to create GUI application in Java   How to create GUI application in Java
Convert the code to GUI
Java Code to GUI   can any one convert My code to GUI code
GUI - Java Beginners
GUI testing  GUI testing in software testing  HiNow, use the code and get the answer.import javax.swing.*;public class DemoTryCatchDialog...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
Java GUI - Java Beginners
Convert the code to GUI
Convert the code   How to convert a code to GUI look alike
Convert the code to GUI
Is it possible to convert a code into GUI  Is it possible to convert a code into GUI
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application


Advertisement null