Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


James Bernard
GUI testing
3 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners


GUI testing in software testing


Advertisement
View Answers

April 4, 2008 at 5:41 PM


Hi

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;
do{
str_value = JOptionPane.showInputDialog(null, "Please input an integer value");
number = true;
try{
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;
}
}
while(!number);
}
}



April 5, 2008 at 6:10 AM


d


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){
numberTextField_KeyTyped(evt);
}
});
displayButton = new JButton("Enter");
pane.add(numberLabel);
pane.add(numberTextField);
pane.add(displayButton);
displayButton.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("GUI Example");
pack();
show();
}
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);
System.exit(0);
}
}

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

}
}
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

Thanks


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
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
Advertisements
Open Source Testing Tools in Java
Open Source Testing Tools in Java In this page we are discussing about the different Open Source Testing Tools available in Java. JUnit JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used
GJTester - Java Unit Testing Tool
GJTester - Java Unit Testing Tool       GJTester, a general Java testing tool, accomplishes the unit, regression and contract testing of your Java programs
GUI framework
GUI framework  what do u mean by GUI framework
junit testing - JUNIT
junit testing  How to perform a testing in JUnit?  Hi,Could you please explain me in detail "junit testing on stack". What is stack and how do you want to test?Please let's know, I will try to provide
GUI component
GUI component  How can a GUI component handle its own events
Advantages of Testing tools
Advantages of DbUnit       The reasons to use this testing tool can be summarized as follows : A framework which simplifies operations for each stage in the life
web services security testing by soapUI
web services security testing by soapUI  how to make security testing to online examination system by soapUI
Open Source Testing
. The Abbot framework is a Java library for GUI unit testing and functional testing...Open Source Testing Open Source Security Testing Methodology Manual The Open Source Security Testing Methodology Manual (OSSTMM) is a peer-reviewed
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
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
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 code  GUI code
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
Mobile Software Testing Services, Mobile Application Software Testing Service RoseIndia
; padding-bottom:9px; } Mobile Software Testing Services Now... a mobile software-testing firm to stress testing their mobile software. Roseindia... is offering a complete mobile testing solutions for all major brands of mobile. We
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
Convert the code to GUI
GUI Application example  GUI Application example
Convert the code to GUI
GUI Example  GUI Example code to learn
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
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: TESTING is not mapped [FROM TESTING]
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: TESTING is not mapped [FROM TESTING]  I am very new to Hibernate, just trying...; POJO class: package main; public class Testing { private int id
Convert the code to GUI
Java GUI Class Example  Java GUI Class Example
Convert the code to GUI
GUI Java JSP application  GUI Java JSP application
Convert the code to GUI
GUI Application Development   GUI Application Development
Convert the code to GUI
Java and GUI application Example  Java and GUI application Example
Convert the code to GUI
Write a GUI Application  best way to write a GUI based application
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
Continuous Testing
Continuous Testing       Continuous testing uses excess cycles on a developer's workstation... 3.1, download v 1.2.1, 2) Continuous Testing 2.0 for Eclipse 3.2 is on the way
Unit Testing with HTTPUnit
Unit Testing with HTTPUnit This tutorial shows you how to use HttpUnit..., Open Source Unit testing tool to test the web application. This tool is based on Unit which is also Java based free testing tool. HttpUnit emulates
Careers in Software Testing
Careers in Software Testing Searching loopholes could be paying job option... testing awaits your arrival. The whole exercise is to ensure the quality of product and find out the bugs if any. The range of software testing doesn’t ends
Deploying and testing Stateless Session Bean
Deploying and testing Stateless Session Bean       ... server directory and then install the application. Testing the application
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
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
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
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
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
Can we use Jmeter for testing a PHP website???
Can we use Jmeter for testing a PHP website???  Can we test a website in PHP using Apache jmeter? Actually, I want to perform load testing of my PHP website. So, whether it will be useful or should I go with any other? Plz
QA in software Testing - Servlet Interview Questions
of unit test case in Software Testing.   Hello,If you are planning to test your program then use the JUNIT. Junit is industry standard Unit testing tool... source Java framework that makes unit testing easier and more effective. JUnit
Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application
Database Testing with DbUnit
Database Testing with DbUnit      ... by Manuel Laflamme. This is a powerful tool for simplifying Unit Testing... these jar files are required to be added in the referenced library of your testing
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
GUI Tips
Java NotesGUI Tips [Beginning of list of GUI tips -- needs much more.... Events and communication After the GUI is constructed, the program stops execution... (eg, actionPerformed) may be mixed in with the GUI construction code
load testing for login using - Java Beginners
load testing for login using  Hi , I am new to Jmeter.How can i test Login funcionality when 10 different users logging with a gap of 10 sec each.Please tell me the process to do it.Thanx, Naryana
Software Testing Services, Application Testing Solutions, Testing Services from Rose India
Rose India Software Testing Services Software testing is any activity aimed... whether or not it meets the required results. Software testing is an art... in software testing is branched out from the complexity of software. Testing is more
Flex SDK GUI
Flex SDK GUI  Hi....... please give me ans of this question.. What classes do you typically extend in the Flex SDK for creating GUI controls and why? Thanks
GUI application program
GUI application program  Write a GUI application program that meets the following requirements: Create an array with 100 randomly chosen integers. Create a textfield to enter an array index and another textfield to display
GUI Alternatives
, it isn't difficult to build a Graphical User Interface (GUI) in Java, but it is hard... of GUI programming simply don't scale well. Separation of concerns BAD: Mix...: Separate GUI from logic. As programs grow larger, it's essential to separate
Advertisements
 

 

 

DMCA.com