The class JOptionPane (javax.swing) allows you to display a dialog box containing info. showmessagedialog(), showinputdialog()
|
|
|
- Ira Dean
- 10 years ago
- Views:
Transcription
1 // Fig. 2.8: Addition.java An addition program import javax.swing.joptionpane; public class Addition public static void main( String args[] ) String firstnumber, secondnumber; int number1, number2, sum; // read in first number from user as a string firstnumber = JOptionPane.showInputDialog( "Enter first integer" ); // read in second number from user as a string secondnumber = JOptionPane.showInputDialog( "Enter second integer" ); // convert numbers from type String to type int number1 = Integer.parseInt( firstnumber ); number2 = Integer.parseInt( secondnumber ); sum = number1 + number2; // display the results JOptionPane.showMessageDialog( null, "The sum is " + sum, "Results", JOptionPane.PLAIN_MESSAGE ); System.exit( 0 ); // terminate the program // Fig. 3.10: WelcomeLines.java Displaying text and lines import javax.swing.japplet; import java.awt.graphics; public class WelcomeLines extends JApplet public void paint( Graphics g ) g.drawline( 15, 10, 210, 10 ); g.drawline( 15, 30, 210, 30 ); g.drawstring( "Welcome to Java Programming!", 25, 25 ); The class JOptionPane (javax.swing) allows you to display a dialog box containing info. showmessagedialog(), showinputdialog() Graphics object: drawstring(), drawline(), drawoval(), drawrect()
2 / Fig. 3.12: AdditionApplet.java Adding two floating-point numbers import java.awt.graphics; import javax.swing.*; public class AdditionApplet extends JApplet double sum; public void init() String firstnumber, secondnumber; double number1, number2; // read in first number from user firstnumber = JOptionPane.showInputDialog( "Enter first floating-point value" ); // read in second number from user secondnumber = JOptionPane.showInputDialog( "Enter second floating-point value" ); // convert numbers from type String to type double number1 = Double.parseDouble( firstnumber ); number2 = Double.parseDouble( secondnumber ); sum = number1 + number2; public void paint( Graphics g ) // draw the results with g.drawstring g.drawrect( 15, 10, 270, 20 ); g.drawstring( "The sum is " + sum, 25, 25 );
3 // Fig. 5.6: Interest.java Calculating compound interest import java.text.decimalformat; import javax.swing.joptionpane; import javax.swing.jtextarea; public class Interest public static void main( String args[] ) double amount, principal = , rate =.05; DecimalFormat precisiontwo = new DecimalFormat( "0.00" ); JTextArea outputtextarea = new JTextArea( 11, 20 ); outputtextarea.append( "Year\tAmount on deposit\n" ); for ( int year = 1; year <= 10; year++ ) amount = principal * Math.pow( rate, year ); outputtextarea.append( year + "\t" + precisiontwo.format( amount ) + "\n" ); JOptionPane.showMessageDialog( null, outputtextarea, "Compound Interest", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); // terminate the application JTextArea (javax.swing) is a GUI component that is capable of displaying many lines of text. The arguments determine the number of rows and columns as well as the size on the screen. append(), settext() Fig. 5.6: An interesting feature of class JOptionPane is that the message it displays with showmessagedialog can be a String or a GUI component such as a JtextArea. JTextArea outtextarea = new JTA(11,20);... JOptionPane.showMessageDialog(null, outtextarea, CompoundInterest, JOptionPane.INFO_MSG);
4 // Fig. 5.7: SwitchTest.java Drawing shapes import java.awt.graphics; import javax.swing.*; public class SwitchTest extends JApplet int choice; public void init() String input; input = JOptionPane.showInputDialog( "Enter 1 to draw lines\n" + "Enter 2 to draw rectangles\n" + "Enter 3 to draw ovals\n" ); choice = Integer.parseInt( input ); public void paint( Graphics g ) for ( int i = 0; i < 10; i++ ) switch( choice ) case 1: g.drawline( 10, 10, 250, 10 + i * 10 ); break; case 2: g.drawrect( 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 ); break; case 3: g.drawoval( 10 + i * 10, 10 + i * 10, 50 + i * 10, 50 + i * 10 ); break; default: JOptionPane.showMessageDialog( null, "Invalid value entered" ); // end switch // end for // end paint() // end class SwitchTest
5 / Fig. 5.19: LogicalOperators.java Demonstrating the logical operators import javax.swing.*; public class LogicalOperators public static void main( String args[] ) JTextArea outputarea = new JTextArea( 17, 20 ); JScrollPane scroller = new JScrollPane( outputarea ); String output = ""; output += "Logical AND (&&)" + "\nfalse && false: " + ( false && false ) + "\nfalse && true: " + ( false && true ) + "\ntrue && false: " + ( true && false ) + "\ntrue && true: " + ( true && true ); output += "\n\nlogical OR ( )" + "\nfalse false: " + ( false false ) + "\nfalse true: " + ( false true ) + "\ntrue false: " + ( true false ) + "\ntrue true: " + ( true true ); output += "\n\nboolean logical AND (&)" + "\nfalse & false: " + ( false & false ) + "\nfalse & true: " + ( false & true ) + "\ntrue & false: " + ( true & false ) + "\ntrue & true: " + ( true & true ); output += "\n\nboolean logical inclusive OR ( )" + "\nfalse false: " + ( false false ) + "\nfalse true: " + ( false true ) + "\ntrue false: " + ( true false ) + "\ntrue true: " + ( true true ); output += "\n\nboolean logical exclusive OR (^)" + "\nfalse ^ false: " + ( false ^ false ) + "\nfalse ^ true: " + ( false ^ true ) + "\ntrue ^ false: " + ( true ^ false ) + "\ntrue ^ true: " + ( true ^ true ); output += "\n\nlogical NOT (!)" + "\n!false: " + (!false ) + "\n!true: " + (!true ); outputarea.settext( output ); JOptionPane.showMessageDialog( null, scroller, "Truth Tables", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); Fig 5-19: Class JScrollPane (javax.swing) provides a GUI component with scrolling functionality. It is initialized with the GUI component for which it will provide scrolling. JScrollPane scroller = new JSP( outputarea);
6 / Fig. 6.3: SquareInt.java A programmer-defined square method import java.awt.container; import javax.swing.*; public class SquareInt extends JApplet public void init() String output = ""; JTextArea outputarea = new JTextArea( 10, 20 ); // get the applet's GUI component display area Container c = getcontentpane(); // attach outputarea to Container c c.add( outputarea ); int result; for ( int x = 1; x <= 10; x++ ) result = square( x ); output += "The square of " + x + " is " + result + "\n"; outputarea.settext( output ); // square method definition public int square( int y ) return y * y; Fig 6.3: Displays a GUI component on an applet. The on-screen display area for a Japplet has a content pane to which the GUI components must be attached so they can be displayed at execution time. The content pane is an object of class Container (java.awt). Container c = getcontentpane(); c.add(outputarea); Method getcontentpane() returns a reference to the applet s content pane. The add() method places the JTextArea object on the applet so it can be displayed when executed.
7 Fig 6.9: Container and FlowLayout are imported from java.awt. The java.awt.event contains many data types that enable a program to process a user s interactions with a program (ActionListener, ActionEvent). JApplet, JLabel, JLextField and JButton are imported from javax.swing. A JLabel contains a string of chars to display on the screen. It normally indicates the purpose of another gui element on the screen. JTextFields are used to get a single line of info from the user at the keyboard or to display info on the screen. seteditable(): with argument false indicates that it is not editable (gray background). Method init() creates the gui components and attaches them to the user interface. c.setlayout (new FlowLayout() ); This method defines the layout manager for the applet s user interface. Layout managers are provided to arrange components on a Container for presentation purposes. They determine the position and size of every component attached. FlowLayout is the most basic manager. GUI components are placed from left to right in the order in which they are attached to the Container with the method add(). Each Container can have only one layout manager at a time. Separate Containers in the same program can have different managers. The interface ActionListener specifies that the class must define the method: public void actionperformed(actionevent e) This method is used to process a user s interaction with the JButton. When the user presses the button, this method will be called automatically in response to the user interaction (event). This process is called event handling. The handler is the actionperfomed() method. roll.addactionlistener( this ); The above method registers the applet (this) as the listener for events from the JButton roll. When a GUI event occurs in a program, Java creates an object containing info about the event that occurred and automatically calls an appropriate event handling method. Before any event can be processed, each GUI component must know which object in the program defines the event handling method that will be called when the event occurs.
8 To respond to an action event, we must define a class that implements ActionListener (that requires that the class also define method actionperformed() ) and we must register the event handler. actionperformed() receives one argument an ActionEvent which contains info about the action that has occurred.
9 // Fig. 6.9: Craps.java Craps import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Craps extends JApplet implements ActionListener final int WON = 0, LOST = 1, CONTINUE = 2; // const varis for status of game boolean firstroll = true; int sumofdice = 0; int mypoint = 0; int gamestatus = CONTINUE; // true if first roll // sum of the dice // point if no win/loss on first roll // game not over yet JLabel die1label, die2label, sumlabel, pointlabel; JTextField firstdie, seconddie, sum, point; JButton roll; public void init() Container c = getcontentpane(); c.setlayout( new FlowLayout() ); // setup graphical user interface components die1label = new JLabel( "Die 1" ); c.add( die1label ); firstdie = new JTextField( 10 ); firstdie.seteditable( false ); c.add( firstdie ); die2label = new JLabel( "Die 2" ); c.add( die2label ); seconddie = new JTextField( 10 ); seconddie.seteditable( false ); c.add( seconddie ); sumlabel = new JLabel( "Sum is" ); c.add( sumlabel ); sum = new JTextField( 10 ); sum.seteditable( false ); c.add( sum ); pointlabel = new JLabel( "Point is" ); c.add( pointlabel ); point = new JTextField( 10 ); point.seteditable( false ); c.add( point ); roll = new JButton( "Roll Dice" ); roll.addactionlistener( this ); c.add( roll ); public void actionperformed( ActionEvent e ) play(); // call method play when button is pressed
10 public void play() if ( firstroll ) sumofdice = rolldice(); // process one roll of the dice // first roll of the dice switch ( sumofdice ) case 7: case 11: // win on first roll gamestatus = WON; point.settext( "" ); // clear point text field break; case 2: case 3: case 12: // lose on first roll gamestatus = LOST; point.settext( "" ); // clear point text field break; default: // remember point gamestatus = CONTINUE; mypoint = sumofdice; point.settext( Integer.toString( mypoint ) ); firstroll = false; break; else sumofdice = rolldice(); if ( sumofdice == mypoint ) // win by making point gamestatus = WON; else if ( sumofdice == 7 ) // lose by rolling 7 gamestatus = LOST; if ( gamestatus == CONTINUE ) showstatus( "Roll again." ); else if ( gamestatus == WON ) showstatus( "Player wins. " + "Click Roll Dice to play again." ); else showstatus( "Player loses. " + "Click Roll Dice to play again." ); firstroll = true; public int rolldice() int die1, die2, worksum; die1 = 1 + ( int ) ( Math.random() * 6 ); die2 = 1 + ( int ) ( Math.random() * 6 ); worksum = die1 + die2; firstdie.settext( Integer.toString( die1 ) ); seconddie.settext( Integer.toString( die2 ) ); sum.settext( Integer.toString( worksum ) ); return worksum; // roll the dice
11 // Fig. 6.13: FibonacciTest.java Recursive fibonacci method public class FibonacciTest extends Japplet implements ActionListener JLabel numlabel, resultlabel; JTextField num, result; public void init() Container c = getcontentpane(); c.setlayout( new FlowLayout() ); numlabel = new JLabel( "Enter an integer and press Enter" ); c.add( numlabel ); num = new JTextField( 10 ); num.addactionlistener( this ); c.add( num ); resultlabel = new JLabel( "Fibonacci value is" ); c.add( resultlabel ); result = new JTextField( 15 ); result.seteditable( false ); c.add( result ); public void actionperformed( ActionEvent e ) long number, fibonaccivalue; number = Long.parseLong( num.gettext() ); showstatus( "Calculating..." ); fibonaccivalue = fibonacci( number ); showstatus( "Done." ); result.settext( Long.toString( fibonaccivalue ) ); public long fibonacci( long n ) if ( n == 0 n == 1 ) // base case return n; else return fibonacci( n - 1 ) + fibonacci( n - 2 ); // Recursive definition of method fibonacci Fig 6-13: In this example, the user presses the Enter key while typing in the JTextField num to generate the action event. Automatically, a message is sent to the applet indication that the user interacted with one of the program s GUI components.
12 The message e.getactioncommand(), when executed inside the handler, returns the string the user typed in the JTextField before pressing the Enter key.
13 // Fig. 8.5: TimeTest.java Demonstrating the Time3 class set and get methods import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.deitel.jhtp3.ch08.time3; public class TimeTest extends Japplet implements ActionListener private Time3 t; private JLabel hourlabel, minutelabel, secondlabel; private JTextField hourfield, minutefield, secondfield, display; private JButton tickbutton; public void init() t = new Time3(); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); hourlabel = new JLabel( "Set Hour" ); hourfield = new JTextField( 10 ); hourfield.addactionlistener( this ); c.add( hourlabel ); c.add( hourfield ); minutelabel = new JLabel( "Set minute" ); minutefield = new JTextField( 10 ); minutefield.addactionlistener( this ); c.add( minutelabel ); c.add( minutefield ); secondlabel = new JLabel( "Set Second" ); secondfield = new JTextField( 10 ); secondfield.addactionlistener( this ); c.add( secondlabel ); c.add( secondfield ); display = new JTextField( 30 ); display.seteditable( false ); c.add( display ); tickbutton = new JButton( "Add 1 to Second" ); tickbutton.addactionlistener( this ); c.add( tickbutton ); updatedisplay();
14 public void actionperformed( ActionEvent e ) if ( e.getsource() == tickbutton ) tick(); else if ( e.getsource() == hourfield ) t.sethour( Integer.parseInt( e.getactioncommand() ) ); hourfield.settext( "" ); else if ( e.getsource() == minutefield ) t.setminute( Integer.parseInt( e.getactioncommand() ) ); minutefield.settext( "" ); else if ( e.getsource() == secondfield ) t.setsecond( Integer.parseInt( e.getactioncommand() ) ); secondfield.settext( "" ); updatedisplay(); public void updatedisplay() display.settext( "Hour: " + t.gethour() + "; Minute: " + t.getminute() + "; Second: " + t.getsecond() ); showstatus( "Standard time is: " + t.tostring() + "; Universal time is: " + t.touniversalstring() ); public void tick() t.setsecond( ( t.getsecond() + 1 ) % 60 ); if ( t.getsecond() == 0 ) t.setminute( ( t.getminute() + 1 ) % 60 ); if ( t.getminute() == 0 ) t.sethour( ( t.gethour() + 1 ) % 24 ); Fig 8-5: Several GUI components that are being handled with the same method. The handler uses e.getsource() to determine which component generated the event. The ActionEvent parameter that is supplied to the handler contains a refernce to the source.
15 / Fig. 9.12: Time.java Time class definition import java.text.decimalformat; // used for number formatting public class Time extends Object private int hour; private int minute; private int second; public Time() settime( 0, 0, 0 ); public void settime( int h, int m, int s ) sethour( h ); setminute( m); setsecond( s ); public void sethour( int h ) hour = ( ( h >= 0 && h < 24 )? h : 0 ); public void setminute( int m ) minute = ( ( m >= 0 && m < 60 )? m : 0 ); public void setsecond( int s ) second = ( ( s >= 0 && s < 60 )? s : 0 ); public int gethour() return hour; public int getminute() return minute; public int getsecond() return second; public String tostring() DecimalFormat twodigits = new DecimalFormat( "00" ); return ( ( gethour() == 12 gethour() == 0 )? 12 : gethour() % 12 ) + ":" + twodigits.format( getminute() ) + ":" + twodigits.format( getsecond() ) + ( gethour() < 12? " AM" : " PM" ); // Fig. 9.12: TimeTestWindow.java Demonstrating the Time class set and get methods import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TimeTestWindow extends JFrame private Time t; private JLabel hourlabel, minutelabel, secondlabel; private JTextField hourfield, minutefield, secondfield, display; private JButton exitbutton;
16 public TimeTestWindow() super( "Inner Class Demonstration" ); t = new Time(); Container c = getcontentpane(); // create an instance of the inner class ActionEventHandler handler = new ActionEventHandler(); c.setlayout( new FlowLayout() ); hourlabel = new JLabel( "Set Hour" ); hourfield = new JTextField( 10 ); hourfield.addactionlistener( handler ); c.add( hourlabel ); c.add( hourfield ); minutelabel = new JLabel( "Set minute" ); minutefield = new JTextField( 10 ); minutefield.addactionlistener( handler ); c.add( minutelabel ); c.add( minutefield ); secondlabel = new JLabel( "Set Second" ); secondfield = new JTextField( 10 ); secondfield.addactionlistener( handler ); c.add( secondlabel ); c.add( secondfield ); display = new JTextField( 30 ); display.seteditable( false ); c.add( display ); exitbutton = new JButton( "Exit" ); exitbutton.addactionlistener( handler ); c.add( exitbutton ); public void displaytime() display.settext( "The time is: " + t ); public static void main( String args[] ) TimeTestWindow window = new TimeTestWindow(); window.setsize( 400, 140 ); window.show();
17 // INNER CLASS DEFINITION FOR EVENT HANDLING private class ActionEventHandler implements ActionListener public void actionperformed( ActionEvent e ) if ( e.getsource() == exitbutton ) System.exit( 0 ); else if ( e.getsource() == hourfield ) t.sethour( Integer.parseInt( e.getactioncommand() ) ); hourfield.settext( "" ); else if ( e.getsource() == minutefield ) t.setminute(integer.parseint( e.getactioncommand() ) ); minutefield.settext( "" ); else if ( e.getsource() == secondfield ) t.setsecond( Integer.parseInt( e.getactioncommand() ) ); secondfield.settext( "" ); // terminate the application displaytime(); Fig 9-12: TimeTestWindow extends JFrame (javax.swing) rather than JApplet. This class provides the basic attributes and behavior of a window a title bar and buttons to minimize, maximize and close the window. The init() method of the applet has been replaced by a constructor so that the GUI components are created as the application begins executing. super ( Inner Class Demonstration ) The above calls the superclass constructors with a string that will be displayed in the title bar. ActionEventHandler handler = new AEH() Defines one instance of an inner class and assigns it to handler. This reference is passed to each of the calls to addactionlistener() to register it as the event handler. Each call to this method (addal() ) requires an object of ActionListener to be passed as an argument. handler is an ActionListener since its class implements the interface: private class ActionEventHandler implements ActionListener The inner class is defined as private because its only used in this class definition. An inner class object has a special relationship with the outer class object creates it. The inner class object is allowed to access directly all the instance variables and methods of the outer class object.
18 // Fig. 9.13: TimeTestWindow.java Demonstrating the Time class set and get methods import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TimeTestWindow extends JFrame private Time t; private JLabel hourlabel, minutelabel, secondlabel; private JTextField hourfield, minutefield, secondfield, display; public TimeTestWindow() super( "Inner Class Demonstration" ); t = new Time(); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); hourlabel = new JLabel( "Set Hour" ); hourfield = new JTextField( 10 ); hourfield.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) t.sethour( Integer.parseInt( e.getactioncommand() ) ); hourfield.settext( "" ); displaytime(); ); c.add( hourlabel ); c.add( hourfield ); // anonymous inner class minutelabel = new JLabel( "Set minute" ); minutefield = new JTextField( 10 ); minutefield.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) t.setminute( Integer.parseInt( e.getactioncommand() ) ); minutefield.settext( "" ); displaytime(); ); // anonymous inner class
19 c.add( minutelabel ); c.add( minutefield ); secondlabel = new JLabel( "Set Second" ); secondfield = new JTextField( 10 ); secondfield.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) t.setsecond( Integer.parseInt( e.getactioncommand() ) ); secondfield.settext( "" ); displaytime(); ); c.add( secondlabel ); c.add( secondfield ); // anonymous inner class display = new JTextField( 30 ); display.seteditable( false ); c.add( display ); public void displaytime() display.settext( "The time is: " + t ); public static void main( String args[] ) TimeTestWindow window = new TimeTestWindow(); window.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); window.setsize( 400, 120 ); window.show();
20 Fig 9-13: Modifies the previous example to use an anonymous inner class. Since it has no name, one object of the anonymous class must be created at the point where the class is defined in the program. Each of the JTextFields that generate events have a similar anonymous inner class to handle events. hourfield.addactionlistener( new ActionListener() // a i c public void actionperformed(actionevent e) t.sethour( Integer.parseInt( e.getactioncommand() ) ); hourfield.settext( " " ); displaytime(); ); The argument to addactionlistener(), that must be an object that is an ActionListener, is an object of an anonymous class created by the line new ActionListener () (the parenthesis indicate a call to the default constructor of the aic). The body of the class (between ) defines one method to be called when the user presses Enter while typing in hourfield. Windows generate a variety of events. This example deals with the event generated when the user clicks the window s close box a window closing event. window.addwindowlistener( new WindowAdapter() public void windowclosing(windowevent e) System.exit( 0 ); ); The method addwindowlistener() registers the window event listener. The argument must be a reference to an object the is a WindowListener (java.awt.event). However, there are seven different methods that must be defined in every class that implements the interface, and we only need one for the window closing event.
21 For event handling interfaces with more than one method, Java provides a corresponding class (adapter class) that already implements all the methods in the interface for you. All you need to do is extend the adapter class and override the methods you require. The syntax WindowAdapter( ) begins the definition of an anonymous inner class that extends class WindowAdapter. This is similar to beginning a class definition with: public class MyHandler extends WindowAdapter Class WA implements the interface WListener, so every object of WA is a WL. Notes on Inner Classes 1. Compiling a class that contains inner classes results in a separate.class file for every class. Inner classes have the file name OuterClassName$InnerClassName.class Anonymous inner classes have the file name OuterClassName$#InnerClassName.class where # starts at 1 and is incremented for each AIC encountered during compilation. 2. Inner classes with class names can be defined public, private, package access, or protected and are subject to the same usage restrictions as other members of a class. 3. To access the outer class s this reference, use OuterClassName.this 4. The outer class is responsible for creating objs of its inner classes. To create an obj of another class s inner class, first create obj of the outer class and assign it to a refernce (lets call it ref). Then use a statement of the following form to create an inner class obj: OuterClassName.InnerClassName innerref = ref.new InnerClassName ( ) ; 5. An inner class can be declared static. These do not require an obj of its outer class to be defined. A static IC does not have access to the outer class s non-static members.
22 Swing Overview Swing components are written, manipulated and displayed completely in Java. The original components from the AWT are tied directly to the local s platform s graphical user interface capabilities. So a program executing on different platforms has a different appearance and sometimes even different user interactions. The Swing components allow the programmer to specify a different look and feel for each platform, or a uniform one across all, or even change the look and feel while running. Hierarchy: java.lang.object java.awt.component ava.awt.container javax.swing.jcomponent Swing components that subclass JComponent have the following features: 1. A pluggable look and feel that can be used to customize the l-a-f when the program executes on different platforms. 2. Shortcut keys (called mnemonics) for direct access to components through the keyboard. 3. Common event handling capabilities for cases where several components initiate the same actions in a program. 4. Brief descriptions of a component s purpose (called tool tips) that are displayed when the mouse cursor is positioned over the compt. 5. Support for assistive technologies. 6. Support for user interface localization. Fig 12-4: Example using labels with and without icons and different alignments. Many swing components can display images by specifying an Icon as an argument to their constructor or by using a method that is normally called seticon(). Icon bug = new ImageIcon( bug.gif ); label2 = new JLabel ( Text and icon, bug, SwingConstants.LEFT). The horizontal and vertical positiojns can be also be set: label3.sethorizontalposition(swingconstants.center)
23 // Fig. 12.4: LabelTest.java. Demonstrating the JLabel class. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LabelTest extends JFrame private JLabel label1, label2, label3; public LabelTest() super( "Testing JLabel" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); label1 = new JLabel( "Label with text" ); label1.settooltiptext( "This is label1" ); c.add( label1 ); // JLabel constructor with a string argument // JLabel constructor with string, Icon and alignment arguments Icon bug = new ImageIcon( "bug1.gif" ); label2 = new JLabel( "Label with text and icon", bug, SwingConstants.LEFT ); label2.settooltiptext( "This is label2" ); c.add( label2 ); label3 = new JLabel(); // JLabel constructor no arguments label3.settext( "Label with icon and text at bottom" ); label3.seticon( bug ); label3.sethorizontaltextposition( SwingConstants.CENTER ); label3.setverticaltextposition(swingconstants.bottom ); label3.settooltiptext( "This is label3" ); c.add( label3 ); setsize( 275, 170 ); show(); public static void main( String args[] ) LabelTest app = new LabelTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
24 // Fig. 12.7: TextFieldTest.java Demonstrating the JTextField class. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TextFieldTest extends JFrame private JTextField text1, text2, text3; private JPasswordField password; public TextFieldTest() super( "Testing JTextField and JPasswordField" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); text1 = new JTextField( 10 ); c.add( text1 ); text2 = new JTextField( "Enter text here" ); c.add( text2 ); // construct textfield with default sizing // construct textfield with default text text3 = new JTextField( "Uneditable text field", 20 ); // construct textfield with default text and 20 text3.seteditable( false ); // visible elements and no event handler c.add( text3 ); password = new JPasswordField( "Hidden text" ); c.add( password ); // construct textfield with default text TextFieldHandler handler = new TextFieldHandler(); text1.addactionlistener( handler ); text2.addactionlistener( handler ); text3.addactionlistener( handler ); password.addactionlistener( handler ); setsize( 325, 100 ); show(); public static void main( String args[] ) TextFieldTest app = new TextFieldTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); // inner class for event handling private class TextFieldHandler implements ActionListener public void actionperformed( ActionEvent e ) String s = ""; if ( e.getsource() == text1 ) s = "text1: " + e.getactioncommand(); else if ( e.getsource() == text2 ) s = "text2: " + e.getactioncommand(); else if ( e.getsource() == text3 ) s = "text3: " + e.getactioncommand(); else if ( e.getsource() == password ) JPasswordField pwd = (JPasswordField) e.getsource(); s = "password: " + new String( pwd.getpassword() ); JOptionPane.showMessageDialog( null, s );
25 Fig 12-7: When the user presses Enter in the active text field a message dialog box containing the text in the field is displayed. When an event occurs in the password field, the password is revealed. A JPasswordField shows that a char was typed as the user enters chars, but hides the characters. The inner class event handler determines the component using getsource(), and gets the text entered with getactioncommand(). For the password field it must first cast the component to be able to use the getpassword() method. JPasswordField = pwd (JPasswordField) e.getsource( ); Fig 12-10: The icon on the button changes as the mouse moves in and out of the button s area on the screen. A JButton can display Icons and can also have a rollover Icon one that is displayed when the mouse is positioned over the button. fancybutton.setrollovericon(bug2); Buttons generate ActionEvents that can be processed by any ActionListener object with the method actionperformed(). The inner class handler displays a message dialog box containing the label for the button that was pressed by the user. The ActionEvent method e.getactioncommand() returns the label. Fig 12-11: Changes the style of the text field by selecting check buttons. One JCheckButton applies a bold style and the other italic. When the user clicks a JCheckButton an ItemEvent is generated that can be handled by an ItemListener. The ItemListener obj must define the method itemstatechanged( ). This example uses an inner class as handler that determines the button checked with getsource() and the state of the button as follows: if ( e.getstatechange() == ItemEvent.SELECTED ) valbold = Font.BOLD; else valbold = Font.PLAIN; Fig 12-12: Uses JRadioButtons that permit only a single font style to be selected. The constructor of the radio button specifies the label and the initial state. radiogroup = new ButtonGroup(); The above object is the glue that binds the four radio buttons together to form a logical relationship that allows only one of the buttons to be selected at a time. Class RadioButtonHandler implements the ItemListener interface so it can handle events generated by the radio buttons.
26 // Fig : ButtonTest.java Creating JButtons. import java.awt.*; import java.awt.event.* import javax.swing.*; public class ButtonTest extends JFrame private JButton plainbutton, fancybutton; public ButtonTest() super( "Testing Buttons" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); plainbutton = new JButton( "Plain Button" ); c.add( plainbutton ); // create buttons Icon bug1 = new ImageIcon( "bug1.gif" ); Icon bug2 = new ImageIcon( "bug2.gif" ); fancybutton = new JButton( "Fancy Button", bug1 ); fancybutton.setrollovericon( bug2 ); c.add( fancybutton ); ButtonHandler handler = new ButtonHandler(); fancybutton.addactionlistener( handler ); plainbutton.addactionlistener( handler ); // create an instance of inner class ButtonHandler // to use for button event handling setsize( 275, 100 ); show(); public static void main( String args[] ) ButtonTest app = new ButtonTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); // inner class for button event handling private class ButtonHandler implements ActionListener public void actionperformed( ActionEvent e ) JOptionPane.showMessageDialog( null, "You pressed: " + e.getactioncommand() );
27 // Fig : CheckBoxTest.java Creating Checkbox buttons. public class CheckBoxTest extends JFrame private JTextField t; private JCheckBox bold, italic; public CheckBoxTest() super( "JCheckBox Test" ); Container c = getcontentpane(); c.setlayout(new FlowLayout()); t = new JTextField( "Watch the font style change", 20 ); t.setfont( new Font( "TimesRoman", Font.PLAIN, 14 ) ); c.add( t ); bold = new JCheckBox( "Bold" ); c.add( bold ); italic = new JCheckBox( "Italic" ); c.add( italic ); // create checkbox objects CheckBoxHandler handler = new CheckBoxHandler(); bold.additemlistener( handler ); italic.additemlistener( handler ); setsize( 275, 100 ); show(); public static void main( String args[] ) CheckBoxTest app = new CheckBoxTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); private class CheckBoxHandler implements ItemListener private int valbold = Font.PLAIN; private int valitalic = Font.PLAIN; public void itemstatechanged( ItemEvent e ) if ( e.getsource() == bold ) if ( e.getstatechange() == ItemEvent.SELECTED ) valbold = Font.BOLD; else valbold = Font.PLAIN; if ( e.getsource() == italic ) if ( e.getstatechange() == ItemEvent.SELECTED ) valitalic = Font.ITALIC; else valitalic = Font.PLAIN; t.setfont( new Font( "TimesRoman", valbold + valitalic, 14 ) ); t.repaint();
28 // Fig : RadioButtonTest.java Creating radio buttons using ButtonGroup and JRadioButton. public class RadioButtonTest extends JFrame private JTextField t; private Font plainfont, boldfont, italicfont, bolditalicfont; private JRadioButton plain, bold, italic, bolditalic; private ButtonGroup radiogroup; public RadioButtonTest() super( "RadioButton Test" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); t = new JTextField( "Watch the font style change", 25 ); c.add( t ); plain = new JRadioButton( "Plain", true ); c.add( plain ); // Create radio buttons bold = new JRadioButton( "Bold", false); c.add( bold ); italic = new JRadioButton( "Italic", false ); c.add( italic ); bolditalic = new JRadioButton( "Bold/Italic", false ); c.add( bolditalic ); RadioButtonHandler handler = new RadioButtonHandler(); // register events plain.additemlistener( handler ); bold.additemlistener( handler ); italic.additemlistener( handler ); bolditalic.additemlistener( handler ); radiogroup = new ButtonGroup(); // create logical relationship between JRadioButtons radiogroup.add( plain ); radiogroup.add( bold ); radiogroup.add( italic ); radiogroup.add( bolditalic ); plainfont = new Font( "TimesRoman", Font.PLAIN, 14 ); boldfont = new Font( "TimesRoman", Font.BOLD, 14 ); italicfont = new Font( "TimesRoman", Font.ITALIC, 14 ); bolditalicfont = new Font( "TimesRoman", Font.BOLD + Font.ITALIC, 14 ); t.setfont( plainfont ); setsize( 300, 100 ); show(); public static void main( String args[] ) RadioButtonTest app = new RadioButtonTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); private class RadioButtonHandler implements ItemListener public void itemstatechanged( ItemEvent e ) if ( e.getsource() == plain ) t.setfont( plainfont ); else if ( e.getsource() == bold ) t.setfont( boldfont ); else if ( e.getsource() == italic ) t.setfont( italicfont ); else if ( e.getsource() == bolditalic ) t.setfont( bolditalicfont ); t.repaint();
29 // Fig : ComboBoxTest.java Using a JComboBox to select an image to display. public class ComboBoxTest extends JFrame private JComboBox images; private JLabel label; private String names[] = "bug1.gif", "bug2.gif", "travelbug.gif", "buganim.gif" ; private Icon icons[] = new ImageIcon( names[ 0 ] ), new ImageIcon( names[ 1 ] ), new ImageIcon( names[ 2 ] ), new ImageIcon( names[ 3 ] ) ; public ComboBoxTest() super( "Testing JComboBox" ); Container c = getcontentpane(); c.setlayout( new FlowLayout() ); images = new JComboBox( names ); images.setmaximumrowcount( 3 ); images.additemlistener( new ItemListener() public void itemstatechanged( ItemEvent e ) label.seticon( icons[ images.getselectedindex() ] ); ); c.add( images ); label = new JLabel( icons[ 0 ] ); c.add( label ); setsize( 350, 100 ); show(); public static void main( String args[] ) ComboBoxTest app = new ComboBoxTest(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
30 Fig 12-13: Uses a JComboBox to provide a list of four image file names, that when selected its displayed as an Icon on a JLabel. images = new JComboBox (names); Creates a combo box obj using the string in array names as the elements in the list. A numeric index keeps track of the ordering of items. images.setmaximumrowcount(3); Sets the maximum number of elements that are displayed when the user clicks the combo box. If there are more items than the max, the combo box automatically provides a scrollbar. The handler obtains the index of the item selected with method getselectedindex(). Mouse Event Handling Mouse events are handled by the MouseListener and MouseMotionListener event-listener interfaces. Each mouse event handling methods takes a MouseEvent obj argument. Contains info about the event that occurred and the x and y coordinates of the location where it occurred. Fig 12-17: Each mouse event results in a string displayed in a JLabel at the bottom of the window. Uses the default layout manager, BorderLayout, that divides the content pane s area into five regions - north, south, east, west and center. GetContentPane( ).add( statusbar, BorderLayout.SOUTH ); Attaches the JLabel statusbar to the south region which extends across the entire bottom of the content pane. The application window is registered as the listener for its own mouse events. When the mouse enters or exits the application area the corresponding event handlers display a message in statusbar indicating the event. When any of the other five events occur, they display a message describing the event and the coordinates where the event occurred. With the getx() and gety() MouseEvent methods.
31 // Fig : MouseTracker.java Demonstrating mouse events. public class MouseTracker extends Jframe implements MouseListener, MouseMotionListener private JLabel statusbar; public MouseTracker() super( "Demonstrating Mouse Events" ); statusbar = new JLabel(); getcontentpane().add( statusbar, BorderLayout.SOUTH ); addmouselistener( this ); addmousemotionlistener( this ); // application listens to its own mouse events setsize( 275, 100 ); show(); public void mouseclicked( MouseEvent e ) statusbar.settext( "Clicked at [" + e.getx() + ", " + e.gety() + "]" ); public void mousepressed( MouseEvent e ) statusbar.settext( "Pressed at [" + e.getx() + ", " + e.gety() + "]" ); public void mousereleased( MouseEvent e ) statusbar.settext( "Released at [" + e.getx() + ", " + e.gety() + "]" ); public void mouseentered( MouseEvent e ) statusbar.settext( "Mouse in window" ); public void mouseexited( MouseEvent e ) statusbar.settext( "Mouse outside window" ); // MouseListener event handlers // MouseMotionListener event handlers public void mousedragged( MouseEvent e ) statusbar.settext( "Dragged at [" + e.getx() +, " + e.gety() + "]" ); public void mousemoved( MouseEvent e ) statusbar.settext( "Moved at [" + e.getx() + ", " + e.gety() + "]" ); public static void main( String args[] ) MouseTracker app = new MouseTracker(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
32 // Fig : Painter.java Using class MouseMotionAdapter. public class Painter extends JFrame private int xvalue = -10, yvalue = -10; public Painter() super( "A simple paint program" ); getcontentpane().add( new Label( "Drag the mouse to draw" ), BorderLayout.SOUTH ); addmousemotionlistener( new MouseMotionAdapter() public void mousedragged( MouseEvent e ) xvalue = e.getx(); yvalue = e.gety(); repaint(); ); setsize( 300, 150 ); show(); public void paint( Graphics g ) g.filloval( xvalue, yvalue, 4, 4 ); public static void main( String args[] ) Painter app = new Painter(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); Fig 12-19: Uses the mousedragged event handler to create a simple drawing program. The user can draw pictures with by dragging the mouse on the background of the window. Since method mousemoved is not used, the MouseMotionListener is defined as a subclass of MouseMotionAdapter and then we override mousedragged. The handler captures the x and y coordinates of the mouse-dragged event and stores them in instance variables xvalue and yvalue, then calls repaint() to initiate drawing of the next oval on the background.
33 As you drag the mouse all ovals remain on the window. This is due to a special feature of Swing GUI components called double buffering in which all drawing actually occurs in an image stored in memory, then the entire image is displayed on the window. This helps present smooth graphics display in a GUI. // Fig : MouseDetails.java Demonstrating mouse clicks and distinguishing between mouse buttons. public class MouseDetails extends JFrame private String s = ""; private int xpos, ypos; public MouseDetails() super( "Mouse clicks and buttons" ); addmouselistener( new MouseClickHandler() ); setsize( 350, 150 ); show(); public void paint( Graphics g ) g.drawstring( [" + xpos + ", " + ypos + "]", xpos, ypos ); public static void main( String args[] ) MouseDetails app = new MouseDetails(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); ); private class MouseClickHandler extends MouseAdapter public void mouseclicked( MouseEvent e ) xpos = e.getx(); ypos = e.gety(); String s = "Clicked " + e.getclickcount() + " time(s)"; if ( e.ismetadown() ) s += " with right mouse button"; else if ( e.isaltdown() ) s += " with center mouse button"; else s += " with left mouse button"; settitle( s ); repaint(); // Right mouse button // Middle mouse button // Left mouse button // set the title bar of the window
34 Keyboard Event Handling Key events are generated when keys are pressed and released. To implement the KeyListener interface a class must provide definitions for methods keypressed, keyreleased and keytyped. Each of these receive a KeyEvent as its argument. keypressed: called in response to pressing any key keytyped: called in response to pressing any key that is not an action key (arrow key, Home, End, Page Up, Page Down, function key, Num Lock, Print Screen, Scroll Lock, Caps Lock and Pause). keyreleased: called when the key is released after any keypressed or keytyped event. Fig 12-22: The constructor registers the application to handle its own key events with method addkeylistener( ). This method is defined in class Component, so every subclass can notify KeyListeners of key events for that Component. A JTextArea is added to display the output. It occupies the entire window. When a single Component is added to a BorderLayout, it occupies the entire Container by default. Methods keypressed and keyreleased use KeyEvent method getkeycode to get the virtual key code of the key that was pressed. The value returned is passed to KeyEvent method getkeytext which returns a string containing the name of the key that was pressed. Method keytyped uses KeyEvent method getkeychar to get the Unicode value of the character typed. All three handlers call method setlines2and3( ) passing it the event object. This method uses the KeyEvent method isactionkey to determine if the key was an action key. InputEvent mehtod getmodifiers is called to determine if any modifier keys (Shift, Alt and Ctrl) where pressed. The result is passed to KeyEvent method getkeymodifierstext, which produces a string containing the names of the pressed modifier keys.
35 // Fig : KeyDemo.java Demonstrating keystroke events. public class KeyDemo extends JFrame implements KeyListener private String line1 = "", line2 = ""; private String line3 = ""; private JTextArea textarea; public KeyDemo() super( "Demonstrating Keystroke Events" ); textarea = new JTextArea( 10, 15 ); textarea.settext( "Press any key on the keyboard..." ); textarea.setenabled( false ); addkeylistener( this ); // allow frame to process Key events getcontentpane().add( textarea ); setsize( 350, 100 ); show(); public void keypressed( KeyEvent e ) line1 = "Key pressed: " + e.getkeytext( e.getkeycode() ); setlines2and3( e ); public void keyreleased( KeyEvent e ) line1 = "Key released: " + e.getkeytext( e.getkeycode() ); setlines2and3( e ); public void keytyped( KeyEvent e ) line1 = "Key typed: " + e.getkeychar(); setlines2and3( e ); private void setlines2and3( KeyEvent e ) line2 = "This key is " + ( e.isactionkey()? "" : "not " ) + "an action key"; String temp = e.getkeymodifierstext( e.getmodifiers() ); line3 = "Modifier keys pressed: " + ( temp.equals( "" )? "none" : temp ); textarea.settext( line1 + "\n" + line2 + "\n" + line3 + "\n" ); public static void main( String args[] ) KeyDemo app = new KeyDemo(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
36 Layout Managers The layout managers provide basic layout capabilities that are easier to use than determining the exact position and size of every GUI component. FlowLayout: the most basic layout manager. Components are placed on a container from left to right in the order in which they are added. When the edge is reached, components aer continued on the next line. Allows components to be left-aligned, centered (default) and right-aligned. Fig 12-24: Creates three buttons and adds them to the application using a FlowLayout. The user can click the Left, Right or Center buttons to change the alignment. layout.layoutcontainer( c ); Uses the LayoutManager s interface method to specify that the content pane should be rearranged based on the adjusted layout. BorderLayout: Arranges components into five regions. Up to five components can be added directly - one for each region. If all five regions are occupied, the entire container s space is covered. If a region is not occupied (except center), the other regions expand to fill the remaining space. Fig 12-25: Places five buttons on a BorderLayout. When a button is clicked, it is hidden and the window is adjusted. layout = new BorderLayout(5, 5); The arguments specify the number of pixels between components. The horizontal gap and the vertical gap (default is 0). The handler uses setvisible to hide the button. The LayoutManager method layoutcontainer is used to recalculate the layout of the content pane.
37 // Fig : FlowLayoutDemo.java Demonstrating FlowLayout alignments. public class FlowLayoutDemo extends JFrame private JButton left, center, right; private Container c; private FlowLayout layout; public FlowLayoutDemo() super( "FlowLayout Demo" ); layout = new FlowLayout(); c = getcontentpane(); c.setlayout( layout ); left = new JButton( "Left" ); left.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) layout.setalignment( FlowLayout.LEFT ); layout.layoutcontainer( c ); ); c.add( left ); center = new JButton( "Center" ); center.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) layout.setalignment( FlowLayout.CENTER ); layout.layoutcontainer( c ); ); c.add( center ); // re-align attached components // re-align attached components right = new JButton( "Right" ); right.addactionlistener( new ActionListener() public void actionperformed( ActionEvent e ) layout.setalignment( FlowLayout.RIGHT ); layout.layoutcontainer( c ); ); c.add( right ); setsize( 300, 75 ); show(); / re-align attached components public static void main( String args[] ) FlowLayoutDemo app = new FlowLayoutDemo(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
38 // Fig : BorderLayoutDemo.java Demonstrating BorderLayout. public class BorderLayoutDemo extends Jframe implements ActionListener private JButton b[]; private String names[] = "Hide North", "Hide South", "Hide East", "Hide West", "Hide Center" ; private BorderLayout layout; public BorderLayoutDemo() super( "BorderLayout Demo" ); layout = new BorderLayout( 5, 5 ); Container c = getcontentpane(); c.setlayout( layout ); b = new JButton[ names.length ]; // instantiate button objects for ( int i = 0; i < names.length; i++ ) b[ i ] = new JButton( names[ i ] ); b[ i ].addactionlistener( this ); // order not important c.add( b[ 0 ], BorderLayout.NORTH ); c.add( b[ 1 ], BorderLayout.SOUTH ); c.add( b[ 2 ], BorderLayout.EAST ); c.add( b[ 3 ], BorderLayout.WEST ); c.add( b[ 4 ], BorderLayout.CENTER ); // North position // South position // East position // West position // Center position setsize( 300, 200 ); show(); public void actionperformed( ActionEvent e ) for ( int i = 0; i < b.length; i++ ) if ( e.getsource() == b[ i ] ) b[ i ].setvisible( false ); else b[ i ].setvisible( true ); // re-layout the content pane layout.layoutcontainer( getcontentpane() ); public static void main( String args[] ) BorderLayoutDemo app = new BorderLayoutDemo(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
39 GridLayout: divides the container into a grid so that components can be placed in rows and columns. Every component has the same width and height. They are added starting at the top left cell of the grid and proceeding left to right. Fig 12-26: Adds six button to a GridLayout. Defines two GridLayout objects which are switched when a button is pressed. grid1 = new GridLayout(2, 3, 5, 5); grid2 = new GridLayout(3, 2); The object grid1 is a layout with 2 rows, 3 columns and 5 pixels at the gaps. Object grid2 specifies 3 rows, 2 columns and no gap space. Every call to actionperformed toggles the layout between grid2 and grid1. The method validate() illustrates another way to re-layout a container for which the layout has changed. It re-computes the container s layout based on the current layout manager and the current set of displayed components. Panels: Complex GUIs require that each component be placed in an exact location. They often consist of multiple panels with each panel s components arranged in a specific layout. A JPanel is a subclass of JComponent that inherits from class Container. Thus, JPanels may have components, including other panels, added to them. Fig 12-27: A JPanel is created with a GridLayout. Five buttons are added to the panel which is then added to the south region of a BorderLayout. buttonpanel.setlayout(new GridLayout(1, buttons.lenght) ); c.add( buttonpanel, BorderLayout.SOUTH); The buttons are added directly to the JPanel - class JPanel does not have a content pane like an applet or a JFrame.
40 / Fig : GridLayoutDemo.java Demonstrating GridLayout. public class GridLayoutDemo extends Jframe implements ActionListener private JButton b[]; private String names[] = "one", "two", "three", "four", "five", "six" ; private boolean toggle = true; private Container c; private GridLayout grid1, grid2; public GridLayoutDemo() super( "GridLayout Demo" ); grid1 = new GridLayout( 2, 3, 5, 5 ); grid2 = new GridLayout( 3, 2 ); c = getcontentpane(); c.setlayout( grid1 ); b = new JButton[ names.length ]; // create and add buttons for (int i = 0; i < names.length; i++ ) b[ i ] = new JButton( names[ i ] ); b[ i ].addactionlistener( this ); c.add( b[ i ] ); setsize( 300, 150 ); show(); public void actionperformed( ActionEvent e ) if ( toggle ) c.setlayout( grid2 ); else c.setlayout( grid1 ); toggle =!toggle; c.validate(); public static void main( String args[] ) GridLayoutDemo app = new GridLayoutDemo(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
41 // Fig : PanelDemo.java Using a JPanel to help lay out components. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PanelDemo extends JFrame private JPanel buttonpanel; private JButton buttons[]; public PanelDemo() super( "Panel Demo" ); Container c = getcontentpane(); buttonpanel = new JPanel(); buttons = new JButton[ 5 ]; buttonpanel.setlayout( new GridLayout( 1, buttons.length ) ); for ( int i = 0; i < buttons.length; i++ ) buttons[ i ] = new JButton( "Button " + (i + 1) ); buttonpanel.add( buttons[ i ] ); c.add( buttonpanel, BorderLayout.SOUTH ); setsize( 425, 150 ); show(); public static void main( String args[] ) PanelDemo app = new PanelDemo(); app.addwindowlistener( new WindowAdapter() public void windowclosing( WindowEvent e ) System.exit( 0 ); );
CS 335 Lecture 06 Java Programming GUI and Swing
CS 335 Lecture 06 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels
public class Craps extends JFrame implements ActionListener { final int WON = 0,LOST =1, CONTINUE = 2;
Lecture 15 The Game of "Craps" In the game of "craps" a player throws a pair of dice. If the sum on the faces of the pair of dice after the first toss is 7 or 11 the player wins; if the sum on the first
GUI Components: Part 2
GUI Components: Part 2 JComboBox and Using an Anonymous Inner Class for Event Handling A combo box (or drop-down list) enables the user to select one item from a list. Combo boxes are implemented with
Mouse Event Handling (cont.)
GUI Components: Part II Mouse Event Handling (cont.) Each mouse event-handling method receives a MouseEvent object that contains information about the mouse event that occurred, including the x- and y-coordinates
Introduction to Java Applets (Deitel chapter 3)
Introduction to Java Applets (Deitel chapter 3) 1 2 Plan Introduction Sample Applets from the Java 2 Software Development Kit Simple Java Applet: Drawing a String Drawing Strings and Lines Adding Floating-Point
Using A Frame for Output
Eventos Roteiro Frames Formatting Output Event Handling Entering Data Using Fields in a Frame Creating a Data Entry Field Using a Field Reading Data in an Event Handler Handling Multiple Button Events
5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung
AWT vs. Swing AWT (Abstract Window Toolkit; Package java.awt) Benutzt Steuerelemente des darunterliegenden Betriebssystems Native Code (direkt für die Maschine geschrieben, keine VM); schnell Aussehen
Swing. A Quick Tutorial on Programming Swing Applications
Swing A Quick Tutorial on Programming Swing Applications 1 MVC Model View Controller Swing is based on this design pattern It means separating the implementation of an application into layers or components:
Programming with Java GUI components
Programming with Java GUI components Java includes libraries to provide multi-platform support for Graphic User Interface objects. The multi-platform aspect of this is that you can write a program on a
Graphical User Interfaces
M14_REGE1813_02_SE_C14.qxd 2/10/10 3:43 PM Page 822 Chapter14 Graphical User Interfaces 14.1 GUI Basics Graphical Input and Output with Option Panes Working with Frames Buttons, Text Fields, and Labels
GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012
GUIs with Swing Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2012 Slides copyright 2012 by Jeffrey Eppinger, Jonathan Aldrich, William
GUI Event-Driven Programming
GUI Event-Driven Programming CSE 331 Software Design & Implementation Slides contain content by Hal Perkins and Michael Hotan 1 Outline User events and callbacks Event objects Event listeners Registering
How to Convert an Application into an Applet.
How to Convert an Application into an Applet. A java application contains a main method. An applet is a java program part of a web page and runs within a browser. I am going to show you three different
core 2 Handling Mouse and Keyboard Events
core Web programming Handling Mouse and Keyboard Events 1 2001-2003 Marty Hall, Larry Brown http:// Agenda General event-handling strategy Handling events with separate listeners Handling events by implementing
INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program
Java Mouse and Keyboard Methods
7 Java Mouse and Keyboard Methods 7.1 Introduction The previous chapters have discussed the Java programming language. This chapter investigates event-driven programs. Traditional methods of programming
The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).
The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,
http://netbeans.org/kb/docs/java/gui-functionality.html?print=yes
Page 1 of 6 Introduction to GUI Building Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer and Irina Filippova This beginner tutorial teaches you how to create a simple graphical user
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Skills and Topics for TeenCoder: Java Programming
Skills and Topics for TeenCoder: Java Programming Our Self-Study Approach Our courses are self-study and can be completed on the student's own computer, at their own pace. You can steer your student in
Assignment # 2: Design Patterns and GUIs
CSUS COLLEGE OF ENGINEERING AND COMPUTER SCIENCE Department of Computer Science CSc 133 Object-Oriented Computer Graphics Programming Spring 2014 John Clevenger Assignment # 2: Design Patterns and GUIs
Fondamenti di Java. Introduzione alla costruzione di GUI (graphic user interface)
Fondamenti di Java Introduzione alla costruzione di GUI (graphic user interface) component - container - layout Un Container contiene [0 o +] Components Il Layout specifica come i Components sono disposti
Homework/Program #5 Solutions
Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the
How To Write A Program For The Web In Java (Java)
21 Applets and Web Programming As noted in Chapter 2, although Java is a general purpose programming language that can be used to create almost any type of computer program, much of the excitement surrounding
How To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) (
Chapter 11. Graphical User Interfaces To this point in the text, our programs have interacted with their users to two ways: The programs in Chapters 1-5, implemented in Processing, displayed graphical
How Scala Improved Our Java
How Scala Improved Our Java Sam Reid PhET Interactive Simulations University of Colorado http://spot.colorado.edu/~reids/ PhET Interactive Simulations Provides free, open source educational science simulations
The Basic Java Applet and JApplet
I2PUJ4 - Chapter 6 - Applets, HTML, and GUI s The Basic Java Applet and JApplet Rob Dempster [email protected] School of Computer Science University of KwaZulu-Natal Pietermaritzburg Campus I2PUJ4 - Chapter
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking
JiST Graphical User Interface Event Viewer. Mark Fong [email protected]
JiST Graphical User Interface Event Viewer Mark Fong [email protected] Table of Contents JiST Graphical User Interface Event Viewer...1 Table of Contents...2 Introduction...3 What it does...3 Design...3
Advanced Network Programming Lab using Java. Angelos Stavrou
Advanced Network Programming Lab using Java Angelos Stavrou Table of Contents A simple Java Client...3 A simple Java Server...4 An advanced Java Client...5 An advanced Java Server...8 A Multi-threaded
Lecture VII JAVA SWING GUI TUTORIAL
2. First Step: JFrame Lecture VII Page 1 Lecture VII JAVA SWING GUI TUTORIAL These notes are based on the excellent book, Core Java, Vol 1 by Horstmann and Cornell, chapter 7, graphics programming. Introduction
Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.
Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6 Handout 3 Strings and String Class. Input/Output with JOptionPane. Strings In Java strings are represented with a class type String. Examples:
LAYOUT MANAGERS. Layout Managers Page 1. java.lang.object. java.awt.component. java.awt.container. java.awt.window. java.awt.panel
LAYOUT MANAGERS A layout manager controls how GUI components are organized within a GUI container. Each Swing container (e.g. JFrame, JDialog, JApplet and JPanel) is a subclass of java.awt.container and
Tutorial Reference Manual. Java WireFusion 4.1
Tutorial Reference Manual Java WireFusion 4.1 Contents INTRODUCTION...1 About this Manual...2 REQUIREMENTS...3 User Requirements...3 System Requirements...3 SHORTCUTS...4 DEVELOPMENT ENVIRONMENT...5 Menu
Essentials of the Java(TM) Programming Language, Part 1
Essentials of the Java(TM) Programming Language, Part 1 http://developer.java.sun.com/developer...ining/programming/basicjava1/index.html Training Index Essentials of the Java TM Programming Language:
Extending Desktop Applications to the Web
Extending Desktop Applications to the Web Arno Puder San Francisco State University Computer Science Department 1600 Holloway Avenue San Francisco, CA 94132 [email protected] Abstract. Web applications have
// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf;
// Correntista public class Correntista { String nome, sobrenome; int cpf; public Correntista(){ nome = "zé"; sobrenome = "Pereira"; cpf = 123456; public void setnome(string n){ nome = n; public void setsobrenome(string
Software Design: Figures
Software Design: Figures Today ColorPicker Layout Manager Observer Pattern Radio Buttons Prelimiary Discussion Exercise 5 ColorPicker They don't teach you the facts of death, Your mum and dad. They give
@ - Internal # - External @- Online TH PR OR TW TOTAL HOURS 04 --- 04 03 100 50# --- 25@ 175
COURSE NAME : COMPUTER ENGINEERING GROUP COURSE CODE SEMESTER SUBJECT TITLE : CO/CM/IF/CD : SIXTH : ADVANCED JAVA PROGRAMMING SUBJECT CODE : Teaching and Examination Scheme: @ - Internal # - External @-
Syllabus for CS 134 Java Programming
- Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.
core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt
core. 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Volume I - Fundamentals Seventh Edition CAY S. HORSTMANN GARY
Object Oriented Programming with Java. School of Computer Science University of KwaZulu-Natal
Object Oriented Programming with Java School of Computer Science University of KwaZulu-Natal January 30, 2006 2 Object Oriented Programming with Java Notes for the Computer Science Module Object Oriented
Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)
Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459) Class Time: 6:00 8:05 p.m. (T,Th) Venue: WSL 5 Web Site: www.pbvusd.net/mis260 Instructor Name: Terrell Tucker Office: BDC 127
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Event-Driven Programming
Event-Driven Programming Lecture 4 Jenny Walter Fall 2008 Simple Graphics Program import acm.graphics.*; import java.awt.*; import acm.program.*; public class Circle extends GraphicsProgram { public void
Java is commonly used for deploying applications across a network. Compiled Java code
Module 5 Introduction to Java/Swing Java is commonly used for deploying applications across a network. Compiled Java code may be distributed to different machine architectures, and a native-code interpreter
Basic Microsoft Excel 2007
Basic Microsoft Excel 2007 The biggest difference between Excel 2007 and its predecessors is the new layout. All of the old functions are still there (with some new additions), but they are now located
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
Tutorial: Time Of Day Part 2 GUI Design in NetBeans
Tutorial: Time Of Day Part 2 GUI Design in NetBeans October 7, 2010 Author Goals Kees Hemerik / Gerard Zwaan Getting acquainted with NetBeans GUI Builder Illustrate the separation between GUI and computation
Fachbereich Informatik und Elektrotechnik Java Swing. Advanced Java. Java Swing Programming. Programming in Java, Helmut Dispert
Java Swing Advanced Java Java Swing Programming Java Swing Design Goals The overall goal for the Swing project was: To build a set of extensible GUI components to enable developersto more rapidly develop
java.applet Reference
18 In this chapter: Introduction to the Reference Chapters Package diagrams java.applet Reference Introduction to the Reference Chapters The preceding seventeen chapters cover just about all there is to
Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, 2015. To gain experience with Strings. Objective
Lab 9 Handout 11 CSCI 134: Spring, 2015 Spam, Spam, Spam Objective To gain experience with Strings. Before the mid-90s, Spam was a canned meat product. These days, the term spam means just one thing unwanted
Automated Data Collection for Usability Evaluation in Early Stages of Application Development
Automated Data Collection for Usability Evaluation in Early Stages of Application Development YONGLEI TAO School of Computing and Information Systems Grand Valley State University Allendale, MI 49401 USA
Java Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
Fachbereich Informatik und Elektrotechnik Java Applets. Programming in Java. Java Applets. Programming in Java, Helmut Dispert
Java Applets Programming in Java Java Applets Java Applets applet= app = application snippet = Anwendungsschnipsel An applet is a small program that is intended not to be run on its own, but rather to
Triggers & Actions 10
Triggers & Actions 10 CHAPTER Introduction Triggers and actions are the building blocks that you can use to create interactivity and custom features. Once you understand how these building blocks work,
CaptainCasa. CaptainCasa Enterprise Client. CaptainCasa Enterprise Client. Feature Overview
Feature Overview Page 1 Technology Client Server Client-Server Communication Client Runtime Application Deployment Java Swing based (JRE 1.6), generic rich frontend client. HTML based thin frontend client
CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 29 / 2014 Instructor: Michael Eckmann Today s Topics Comments and/or Questions? import user input using JOptionPane user input using Scanner psuedocode import
Programação Orientada a Objetos. Programando Interfaces Gráficas Orientadas a Objeto Parte 2
Programação Orientada a Objetos Programando Interfaces Gráficas Orientadas a Objeto Parte 2 Paulo André Castro CES-22 IEC - ITA Sumário Programando Interfaces Gráficas Orientadas a Objeto - Parte 2 2.2.1
Dev Articles 05/25/07 11:07:33
Java Crawling the Web with Java Contributed by McGraw Hill/Osborne 2005 06 09 Access Your PC from Anywhere Download Your Free Trial Take your office with you, wherever you go with GoToMyPC. It s the remote
JIDE Action Framework Developer Guide
JIDE Action Framework Developer Guide Contents PURPOSE OF THIS DOCUMENT... 1 WHAT IS JIDE ACTION FRAMEWORK... 1 PACKAGES... 3 MIGRATING FROM EXISTING APPLICATIONS... 3 DOCKABLEBARMANAGER... 9 DOCKABLE
Principles of Software Construction: Objects, Design and Concurrency. GUIs with Swing. toad 15-214. Spring 2013
Principles of Software Construction: Objects, Design and Concurrency GUIs with Swing 15-214 toad Spring 2013 Christian Kästner Charlie Garrod School of Computer Science 2012-13 C Garrod, C Kästner, J Aldrich,
Interaction: Mouse and Keyboard DECO1012
Interaction: Mouse and Keyboard DECO1012 Interaction Design Interaction Design is the research and development of the ways that humans and computers interact. It includes the research and development of
MICROSOFT ACCESS STEP BY STEP GUIDE
IGCSE ICT SECTION 11 DATA MANIPULATION MICROSOFT ACCESS STEP BY STEP GUIDE Mark Nicholls ICT Lounge P a g e 1 Contents Task 35 details Page 3 Opening a new Database. Page 4 Importing.csv file into the
Designing and Implementing Forms 34
C H A P T E R 34 Designing and Implementing Forms 34 You can add forms to your site to collect information from site visitors; for example, to survey potential customers, conduct credit-card transactions,
Microsoft Access 2010 handout
Microsoft Access 2010 handout Access 2010 is a relational database program you can use to create and manage large quantities of data. You can use Access to manage anything from a home inventory to a giant
Introduction to MS WINDOWS XP
Introduction to MS WINDOWS XP Mouse Desktop Windows Applications File handling Introduction to MS Windows XP 2 Table of Contents What is Windows XP?... 3 Windows within Windows... 3 The Desktop... 3 The
Artificial Intelligence. Class: 3 rd
Artificial Intelligence Class: 3 rd Teaching scheme: 4 hours lecture credits: Course description: This subject covers the fundamentals of Artificial Intelligence including programming in logic, knowledge
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
Event processing in Java: what happens when you click?
Event processing in Java: what happens when you click? Alan Dix In the HCI book chapter 8 (fig 8.5, p. 298), notification-based user interface programming is described. Java uses this paradigm and you
NDA-30141 ISSUE 1 STOCK # 200893. CallCenterWorX-Enterprise IMX MAT Quick Reference Guide MAY, 2000. NEC America, Inc.
NDA-30141 ISSUE 1 STOCK # 200893 CallCenterWorX-Enterprise IMX MAT Quick Reference Guide MAY, 2000 NEC America, Inc. LIABILITY DISCLAIMER NEC America, Inc. reserves the right to change the specifications,
Getting Started with Excel 2008. Table of Contents
Table of Contents Elements of An Excel Document... 2 Resizing and Hiding Columns and Rows... 3 Using Panes to Create Spreadsheet Headers... 3 Using the AutoFill Command... 4 Using AutoFill for Sequences...
Example 1: Creating Jframe. Example 2: CenterFrame. Jaeki Song, Ph.D. Box 42101 Lubbock, TX, 79409-2101 PH: 806 784 0435 [email protected].
Example 1: Creating Jframe import javax.swing.*; public class MyFrame public static void main(string[] args) JFrame frame = new JFrame("Test Frame"); frame.setsize(400, 300); frame.setvisible(true); frame.setdefaultcloseoperation(
Solutions from SAP. SAP Business One 2005 SP01. User Interface. Standards and Guidelines. January 2006
Solutions from SAP SAP Business One 2005 SP01 User Interface Standards and Guidelines January 2006 Table of Contents Icons... 5 Typographic Conventions... 5 1. Overview... 6 2. General Issues... 6 2.1
PA Payroll Exercise for Intermediate Excel
PA Payroll Exercise for Intermediate Excel Follow the directions below to create a payroll exercise. Read through each individual direction before performing it, like you are following recipe instructions.
Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide
Open Crystal Reports From the Windows Start menu choose Programs and then Crystal Reports. Creating a Blank Report Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick
Basic Excel Handbook
2 5 2 7 1 1 0 4 3 9 8 1 Basic Excel Handbook Version 3.6 May 6, 2008 Contents Contents... 1 Part I: Background Information...3 About This Handbook... 4 Excel Terminology... 5 Excel Terminology (cont.)...
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
Essentials of the Java Programming Language
Essentials of the Java Programming Language A Hands-On Guide by Monica Pawlan 350 East Plumeria Drive San Jose, CA 95134 USA May 2013 Part Number TBD v1.0 Sun Microsystems. Inc. All rights reserved If
www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk
CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling
Adobe Dreamweaver CC 14 Tutorial
Adobe Dreamweaver CC 14 Tutorial GETTING STARTED This tutorial focuses on the basic steps involved in creating an attractive, functional website. In using this tutorial you will learn to design a site
Module One: Getting Started... 6. Opening Outlook... 6. Setting Up Outlook for the First Time... 7. Understanding the Interface...
2 CONTENTS Module One: Getting Started... 6 Opening Outlook... 6 Setting Up Outlook for the First Time... 7 Understanding the Interface...12 Using Backstage View...14 Viewing Your Inbox...15 Closing Outlook...17
Here's the code for our first Applet which will display 'I love Java' as a message in a Web page
Create a Java Applet Those of you who purchased my latest book, Learn to Program with Java, know that in the book, we create a Java program designed to calculate grades for the English, Math and Science
Java (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: ADVANCE JAVA PROGRAMMING (COURSE CODE: 3360701)
GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM COURSE TITLE: ADVANCE JAVA PROGRAMMING (COURSE CODE: 3360701) Diploma Programme in which this course is offered Computer Engineering/
Advanced Presentation Features and Animation
There are three features that you should remember as you work within PowerPoint 2007: the Microsoft Office Button, the Quick Access Toolbar, and the Ribbon. The function of these features will be more
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.
Working with Tables in Microsoft Word The purpose of this document is to lead you through the steps of creating, editing and deleting tables and parts of tables. This document follows a tutorial format
method is never called because it is automatically called by the window manager. An example of overriding the paint() method in an Applet follows:
Applets - Java Programming for the Web An applet is a Java program designed to run in a Java-enabled browser or an applet viewer. In a browser, an applet is called into execution when the APPLET HTML tag
Creating tables of contents and figures in Word 2013
Creating tables of contents and figures in Word 2013 Information Services Creating tables of contents and figures in Word 2013 This note shows you how to create a table of contents or a table of figures
Fundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
Microsoft Excel 2010 Part 3: Advanced Excel
CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES Microsoft Excel 2010 Part 3: Advanced Excel Winter 2015, Version 1.0 Table of Contents Introduction...2 Sorting Data...2 Sorting
Excel 2007 Basic knowledge
Ribbon menu The Ribbon menu system with tabs for various Excel commands. This Ribbon system replaces the traditional menus used with Excel 2003. Above the Ribbon in the upper-left corner is the Microsoft
Simple Line Drawing. Description of the Simple Line Drawing program
Simple Line Drawing Description of the Simple Line Drawing program JPT Techniques Creating and using the ColorView Creating and using the TextAreaView Creating and using the BufferedPanel with graphics
Creating Interactive PDF Forms
Creating Interactive PDF Forms Using Adobe Acrobat X Pro Information Technology Services Outreach and Distance Learning Technologies Copyright 2012 KSU Department of Information Technology Services This
INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB
INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB GINI COURTER, TRIAD CONSULTING Like most people, you probably fill out business forms on a regular basis, including expense reports, time cards, surveys,
