visual basic barcode program The actionPerformed( ) Method in Java

Generate PDF 417 in Java The actionPerformed( ) Method

The actionPerformed( ) Method
PDF417 Decoder In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
Encode PDF-417 2d Barcode In Java
Using Barcode drawer for Java Control to generate, create PDF 417 image in Java applications.
The actionPerformed( ) method handles the selection of the Close menu item from the File menu. It simply calls shutdown( ) to terminate the program.
Decoding PDF 417 In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
Make Bar Code In Java
Using Barcode printer for Java Control to generate, create bar code image in Java applications.
The shutdown( ) Method
Scan Bar Code In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Creating PDF-417 2d Barcode In Visual C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create PDF417 image in .NET framework applications.
When a StatsWin window is closed, the shutdown( ) method is called. It removes all open windows created by a StatsWin object, including the main window and any graph or data
PDF-417 2d Barcode Printer In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create PDF 417 image in ASP.NET applications.
PDF-417 2d Barcode Creator In Visual Studio .NET
Using Barcode encoder for .NET framework Control to generate, create PDF 417 image in Visual Studio .NET applications.
8: Statistics, Graphing, and Java
Painting PDF 417 In VB.NET
Using Barcode generation for VS .NET Control to generate, create PDF 417 image in VS .NET applications.
GS1 128 Maker In Java
Using Barcode drawer for Java Control to generate, create GS1-128 image in Java applications.
windows. Therefore, even though the graphs are displayed in top-level windows, they are removed when the main application is terminated.
GS1 - 13 Encoder In Java
Using Barcode printer for Java Control to generate, create EAN-13 image in Java applications.
Painting GS1 - 13 In Java
Using Barcode generator for Java Control to generate, create EAN13 image in Java applications.
The createMenu( ) Method
2/5 Standard Drawer In Java
Using Barcode creation for Java Control to generate, create 2 of 5 Standard image in Java applications.
Printing Code39 In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create Code-39 image in VS .NET applications.
The createMenu( ) method constructs the File menu. It begins by creating a MenuBar object called mbar. It then creates a Menu object called file to which a MenuItem object called close is added. Then, the file is added to mbar. Finally, the StatsWin object is added as an action listener for the menu. Thus, the action event generated when the user selects the Close menu item is handled by the actionPerformed( ) method described earlier.
Draw Barcode In Visual Studio .NET
Using Barcode maker for Reporting Service Control to generate, create bar code image in Reporting Service applications.
Paint Barcode In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create barcode image in ASP.NET applications.
The DataWin Class
Code 128 Code Set C Encoder In None
Using Barcode drawer for Software Control to generate, create Code 128C image in Software applications.
GTIN - 128 Generator In Visual Studio .NET
Using Barcode encoder for VS .NET Control to generate, create UCC - 12 image in .NET framework applications.
StatsWin uses an object of type DataWin to display the raw numeric data that is being analyzed. The DataWin class is shown here:
Reading EAN13 In Java
Using Barcode scanner for Java Control to read, scan read, scan image in Java applications.
Create Bar Code In None
Using Barcode creator for Software Control to generate, create barcode image in Software applications.
import java.awt.event.*; import java.awt.*; // Display an array of numeric data. class DataWin extends Frame { TextArea dataTA; DataWin(double[] data) { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setVisible(false); dispose(); } }); dataTA = new TextArea(10, 10); dataTA.setEditable(false); for(int i=0; i < data.length; i++) dataTA.append(data[i]+"\n"); setSize(new Dimension(100, 140)); setLocation(320, 100); setTitle("Data"); setResizable(false); add(dataTA);
The Art of Java
setVisible(true); } }
DataWin extends Frame and is also a top-level window. The DataWin constructor is passed a reference to the array of data to display. It then constructs a TextArea to display the data. The text area is set to read-only and is not resizable. However, it can be minimized.
Putting Together the Pieces
The following program demonstrates Stats and Graphs:
// Demonstrate the Stats and Graphs. import java.io.*; import java.awt.*; class DemoStat { public static void main(String args[]) throws IOException { double nums[] = { 10, 10, 11, 9, 8, 8, 9, 10, 10, 13, 11, 11, 11, 11, 12, 13, 14, 16, 17, 15, 15, 16, 14, 16 }; new StatsWin(nums); } }
To compile the program, use this command line:
javac DemoStat.java DataWin.java StatsWin.java Stats.java Graphs.java
To run the program, type
javaw DemoStat
Notice that javaw (rather than java) is used to run the application. javaw runs the application without requiring a console window. Using javaw ensures that the application will shut down correctly when the main window is closed. For Java 2, version 1.4 and later, you could also use java, but for earlier versions of Java, such as version 1.3, javaw is needed. Figures 8-2 through 8-4 show the statistic classes in action. One thing that makes this application interesting is the use of resizable, top-level windows to hold the graphs. This technique enables the graphs to be resized dynamically by the user, with the scale of the data automatically adjusted. Also, a graph window can be minimized. This allows it to be removed from the screen but not entirely removed from the system.
8: Statistics, Graphing, and Java
Figure 8-2
The main StatsWin window
Figure 8-3
The graph windows
The Art of Java
Figure 8-4
The effects of resizing a graph window
Creating a Simple Statistical Applet
Although the previous section created a stand-alone application using Stats and Graphs, these classes are not limited to this use. They can be easily used by both applets and servlets. To see how, consider the following simple applet. It uses Stats and Graphs to display statistical information about data that it is passed.
// A demonstration applet that uses Stats and Graphs. import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.*; /* <applet code="StatApplet" width=120 height=50> <param name=data value="1.2, 3.6, 5.7, 4.4, 7.1, 4.4, 6.89, 8.9, 10.3, 9.45"> </applet> */
8: Statistics, Graphing, and Java
public class StatApplet extends Applet implements ActionListener { StatsWin sw; Button show; ArrayList al = new ArrayList(); public void init() { StringTokenizer st = new StringTokenizer(getParameter("data"), ", \n\r"); String v; // Get the values from the HTML. while(st.hasMoreTokens()) { v = st.nextToken(); al.add(v); } show = new Button("Display Statistics"); add(show); show.addActionListener(this); } public void actionPerformed(ActionEvent ae) { if(sw == null) { double nums[] = new double[al.size()]; try { for(int i=0; i<al.size(); i++) nums[i] = Double.parseDouble((String)al.get(i)); } catch(NumberFormatException exc) { System.out.println("Error reading data."); return; } sw = new StatsWin(nums); show.setEnabled(false); sw.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { sw = null; show.setEnabled(true); } }); } } }
Copyright © OnBarcode.com . All rights reserved.