import javax.swing.*; - PowerPoint PPT Presentation

1 / 4
About This Presentation
Title:

import javax.swing.*;

Description:

repaint(); HTML HEAD TITLE Example use of an applet /TITLE /HEAD BODY ... { System.out.println( getText() ); setLocation( getX() 10, getY() ); repaint ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 5
Provided by: David58
Category:
Tags: import | javax | repaint | swing

less

Transcript and Presenter's Notes

Title: import javax.swing.*;


1
Application
import javax.swing. import java.awt.Color publi
c class ApplicationEG private
ExampleTextField field /postwin has
been instantiated and
win.getX() win.getY() 0
and win.getWidth()200 and win.getHeight()30
and field has been added to
win and field.getX()
field.getY() 10 and
field.getWidth()200 and field.getHeight()30
/ public ApplicationEG()
JFrame win new JFrame("Window")
win.setLayout(null)
win.setVisible(true)
win.setBounds(0, 0, 400, 300) field new
ExampleTextField(10, 10, 200, 30)
win.add(field, 0) win.setBackground(Color.b
lue) win.repaint()
public static void main(String args)
ApplicationEG something new
ApplicationEG()
2
Application
import java.awt.event. import
javax.swing.JTextField public class
ExampleTextField extends JTextField
implements ActionListener
/ post a new text field is instantiated
and getX()x and getY()y
and getWidth()w and getHeight()h
/ public ExampleTextField(int x, int y, int
w, int h) super()
setBounds(x, y, w, h)
addActionListener( this )
/ EVENT HANDLER - called in response to striking
return post the string content of
this text field is output and
getX() getX()_at_pre 10 / public void
actionPerformed( ActionEvent e )
System.out.println( getText() )
setLocation( getX()10, getY() )
repaint()
3
Applet
import javax.swing. import java.awt.Color publi
c class AppletEG extends JApplet private
ExampleTextField field /post field
has been added to this and
getX() getY() 0 and
getWidth()200 and getHeight()30
and field.getX() field.getY() 10
and field.getWidth()200 and
field.getHeight()30 / public AppletEG()
setLayout(null)
setVisible(true) setBounds(0, 0,
400, 300) field new ExampleTextField(10,
10, 200, 30) add(field, 0)setBackground(Co
lor.blue) repaint()
ltHTMLgt ltHEADgt ltTITLEgtExample use of an
appletlt/TITLEgt lt/HEADgt ltBODYgt ltAPPLET
CODE"AppletEG.class" WIDTH400
HEIGHT300 CODEBASE"." gt lt/APPLETgt
lt/BODYgt lt/HTMLgt
4
Applet
import java.awt.event. import
javax.swing.JTextField public class
ExampleTextField extends JTextField
implements ActionListener
/ post a new text field is instantiated
and getX()x and getY()y
and getWidth()w and getHeight()h
/ public ExampleTextField(int x, int y, int
w, int h) super()
setBounds(x, y, w, h)
addActionListener( this )
/ EVENT HANDLER - called in response to striking
return post the string content of
this text field is output and
getX() getX()_at_pre 10 / public void
actionPerformed( ActionEvent e )
System.out.println( getText() )
setLocation( getX()10, getY() )
repaint()
Write a Comment
User Comments (0)
About PowerShow.com