473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

hello need to touch up the mouth to get a sad face

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.applet.Applet;
  3. import java.awt.event.*;
  4.  
  5. public class Smiley extends Applet implements ActionListener
  6. {
  7. /**
  8. *
  9. */
  10. private static final long serialVersionUID = 1L;
  11. private boolean SMILE = true;
  12. private final Font f = new Font("Helvetica", Font.PLAIN, 9);
  13.  
  14. public void init() { // Define the GUI
  15.  
  16. // The applet has a "Smile" button
  17. final Button smileButton = new Button("Smile"); // create button
  18. add(smileButton); // add to applet's GUI
  19. smileButton.addActionListener(this); // register event listener
  20.  
  21. // The applet has a "Sad" button
  22. final Button sadButton = new Button("Sad");
  23. add(sadButton);
  24. sadButton.addActionListener(this);
  25.  
  26. // set initial background
  27. setBackground(Color.lightGray);
  28.  
  29. } // end of init
  30.  
  31. public void actionPerformed(final ActionEvent e) { // The event handler
  32.  
  33. // Get the command (which button was pressed?)
  34. final String cmd = e.getActionCommand();
  35.  
  36. if (cmd.equals("Smile")) { // "Smile" was pressed
  37. SMILE = true;
  38. setBackground(Color.lightGray);
  39. repaint();
  40. }
  41. else if (cmd.equals("Sad")) { // "Sad"
  42. SMILE = false;
  43. setBackground(Color.lightGray);
  44. repaint();
  45. }
  46.  
  47. } // end of actionPerformed
  48.  
  49.  
  50. public void paint( final Graphics g ) {
  51. // draw the face
  52.  
  53. g.setColor( Color.YELLOW );
  54. g.fillOval( 10, 10, 200, 200 );
  55.  
  56.  
  57.  
  58. // draw the eyes
  59.  
  60. g.setColor( Color.BLACK );
  61. g.fillOval( 55, 65, 30, 30 );
  62.  
  63. // draw the mouth
  64.  
  65. g.fillOval( 135, 65, 30, 30 );
  66. g.fillOval( 50, 110, 120, 60 );
  67.  
  68.  
  69.  
  70. // Draw smiley or sad
  71. if (SMILE) {
  72.  
  73. // "touch up" the mouth into a smile
  74. g.setColor( Color.YELLOW );
  75. g.fillRect( 50, 110, 120, 30 );
  76. g.fillOval( 50, 120, 120, 40 );
  77.  
  78. }
  79. else {
  80. // "touch up" the mouth into a smile to get sad face
  81. g.setColor( Color.YELLOW );
  82. g.fillRect( 50, 110, 120, 30 );
  83. g.fillOval( 50, 120, 120, 40 );
  84. }
  85.  
  86. // SIGNATURE: Write signature
  87. g.setFont(f);
  88. g.drawString("Applet by Deepak.", 1, 199);
  89. } // end of paint
  90. } // end of class Smiley
Oct 21 '13 #1
1 3084
part to be touch up to get the sad face


Expand|Select|Wrap|Line Numbers
  1. // "touch up" the mouth into a smile
  2. g.setColor( Color.YELLOW );
  3. g.fillRect( 50, 110, 120, 30 );// touch up here
  4. g.fillOval( 50, 120, 120, 40 ); // touch up here
Oct 21 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sean Kessinger | last post by:
Thanks, John. Here is the article: http://support.microsoft.com/default.aspx?scid=kb;;821546 I tried the suggestions from this article but still the same problem. No-touch deployment works on...
7
by: George Hester | last post by:
Best done using Microsoft Internet Explorer but I believe Netscape may do OK not sure. I have one itsy bitsy little problem here. The tabbing? No forget that I got a few gray hairs with that and...
3
by: Hamed | last post by:
Hello Is it possible to get a control (e.g. a checkbox) and make a Graphics object or a Bitmap object of current face of the control? I want to implement Sparse property for a ColumnStyle so I...
2
by: tatata9999 | last post by:
Currently my site is not using CSS. The thing I want to do with it is, I think, it needs a face lift, otherwise, it may look boring, target audience seems very much into visual stuff, flushy,...
2
by: eternity | last post by:
hello need to know hw oracle databese works. how it can be used.plse need help urgent to get started.
1
by: hani | last post by:
hi. i'm a newbie on c# and asp.net. sorry if this is a stupid questions. a. i put a treeview in my parent page. called 'TreeView1' b. i need to add a new tree node inside TreeView1 Is it...
1
by: Dansmith122 | last post by:
Hi I have been working on the java script for my website and I need help with the out put variables. I need to know how to add more variable for each row in my survey. I am very lost ...
2
by: Phillis2013 | last post by:
#include <stdlib.h> #include <stdio.h> #include <ctime> #include <string> #include <iostream> using namespace std; int main() { srand ( time(NULL) );
6
by: yanalvine | last post by:
import java.util.Scanner; // program uses class Scanner import java.awt.Color; import java.awt.Graphics; import javax.swing.JPanel; public class person { private String firstName;...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.