SlidePub
Home
Categories
Login
Register
Home
General
Java prog
Java prog
pdsalunkhe
16 views
5 slides
Jan 06, 2020
Slide
1
of 5
Previous
Next
1
2
3
4
5
About This Presentation
Key Event Mouse Event
Size:
64.97 KB
Language:
en
Added:
Jan 06, 2020
Slides:
5 pages
Slide Content
Slide 1
Key Event, Mouse Event Handling In Java Pratap College (Autonomous) Amalner Submitted By: P. M. Patil
Slide 2
// Write a Program to Demonstrate Mouse Event in Java import javax.swing .*; import java.awt.*; import java.awt.event .*; class mouseframe extends JFrame implements MouseListener { int x,y ; mouseframe () { setSize (400,400); setLocation (0,0); setTitle ("Mouse Event Demo"); addMouseListener (this); } public void mousePressed ( MouseEvent e) { x= e.getX (); y= e.getY (); repaint(); } public void mouseReleased ( MouseEvent e){} public void mouseEntered ( MouseEvent e){} public void mouseExited ( MouseEvent e){} public void mouseClicked ( MouseEvent e){} public void paint(Graphics g) { super.paint (g); g.setColor ( Color.blue ); g.fillRect (x,y,20,20); } public static void main(String [] a) { mouseframe f=new mouseframe (); f.show (); } }
Slide 3
// Write a Program to Demonstrate Key Event in Java // Write a Program to Demonstrate Key // Event in Java import javax.swing .*; import java.awt.*; import java.awt.event .*; class keyframe extends JFrame implements KeyListener { char ch ; keyframe () { setSize (400,400); setLocation (0,0); setTitle ("Key Event Demo"); addKeyListener (this); } public void keyPressed ( KeyEvent e) { ch = e.getKeyChar (); repaint(); } public void keyReleased ( KeyEvent e){} public void keyTyped ( KeyEvent e){} public void paint(Graphics g) { super.paint (g); g.setColor ( Color.blue ); if( ch =='r') g.fillRect (100,50,200,100); else if( ch =='c') g.fillOval (100,50,200,100); else if( ch =='l') g.drawLine (100,50,200,50); } public static void main(String [] a) { keyframe f=new keyframe (); f.show (); } }
Slide 4
Program in Java to Display String in Various Font import javax.swing .*; import java.awt.*; class myframe extends JFrame { myframe () { setSize (400,400 ); setLocation (0,0); drawshape p=new drawshape (); Container cp= getContentPane (); cp.add (p ); } } class drawshape extends JPanel { drawshape () { setBackground ( Color.red ); } public void paintComponent (Graphics g) { super.paintComponent (g); String f[]= GraphicsEnvironment . getLocalGraphicsEnvironment (). getAvailableFontFamilyNames (); for( int i =0; i <20;i++) { g.setFont (new Font (f[ i ],Font.ITALIC,20)); g.setColor (new Color( i *5,i*8,i*7)); g.drawString ("Pratap College",i+20,i*14); } } public static void main(String [] a) { myframe f=new myframe (); f.show (); } }
Slide 5
Program in Java using ComboBox and List Box import javax.swing .*; import java.awt.*; import java.awt.event .*; class comboframe extends JFrame implements ActionListener { int x=0,y; JComboBox c; JList l; String s,s1; comboframe () { setSize (400,400); setLocation (0,0); setTitle ("Radio Button Demo"); setLayout (new FlowLayout ()); c = new JComboBox (); c.addItem (" Shubhangi "); c.addItem (" Megha "); c.addItem (" Harshada "); c.addItem (" Khushboo "); c.addItem (" Sayli "); c.addActionListener (this); add(c); String a[]={"First Class","Second Class","Pass Class"}; l= new JList (a); add(l); } public void actionPerformed ( ActionEvent e) { Object o= c.getSelectedItem (); s = "" + o; o= l.getSelectedValue (); s=s+ " got "+o; repaint(); } public void paint(Graphics g) { super.paint (g); g.setColor ( Color.red ); g.setFont (new Font("verdana",Font.BOLD,15)); g.drawString (s,100,200); } public static void main(String []a) { comboframe f=new comboframe (); f.show (); } }
Tags
java key event
java mouse event
event hadling
Categories
General
Download
Download Slideshow
Get the original presentation file
Quick Actions
Embed
Share
Save
Print
Full
Report
Statistics
Views
16
Slides
5
Age
2157 days
Related Slideshows
22
Pray For The Peace Of Jerusalem and You Will Prosper
RodolfoMoralesMarcuc
32 views
26
Don_t_Waste_Your_Life_God.....powerpoint
chalobrido8
33 views
31
VILLASUR_FACTORS_TO_CONSIDER_IN_PLATING_SALAD_10-13.pdf
JaiJai148317
31 views
14
Fertility awareness methods for women in the society
Isaiah47
30 views
35
Chapter 5 Arithmetic Functions Computer Organisation and Architecture
RitikSharma297999
27 views
5
syakira bhasa inggris (1) (1).pptx.......
ourcommunity56
29 views
View More in This Category
Embed Slideshow
Dimensions
Width (px)
Height (px)
Start Page
Which slide to start from (1-5)
Options
Auto-play slides
Show controls
Embed Code
Copy Code
Share Slideshow
Share on Social Media
Share on Facebook
Share on Twitter
Share on LinkedIn
Share via Email
Or copy link
Copy
Report Content
Reason for reporting
*
Select a reason...
Inappropriate content
Copyright violation
Spam or misleading
Offensive or hateful
Privacy violation
Other
Slide number
Leave blank if it applies to the entire slideshow
Additional details
*
Help us understand the problem better