Change picture

how would i make this change picture button change the picture to the traffic light and have it behave the same as the smiley when the move picture button is clicked? also, how can i make this whole program swing instead of awt?
import java.math.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class Lab7 extends Applet implements ActionListener
   Picture myPicture1 = new Picture (Color.blue, Color.black, Color.red);
   Picture myPicture2 = new Picture (Color.red, Color.yellow, Color.green);
   Button moveButton = new Button ("Move Picture");
   Button sadButton = new Button ("Sadness");
   Button switchButton = new Button ("Switch Picture");
   int x = 50;
   boolean flag = true;
   public void init()
       setBackground(Color.black);
       moveButton.addActionListener(this);
       //switchButton.addActionListener(this);
       //sadButton.addActionListener(this);
       add(switchButton);
       add(moveButton);
       add(sadButton);
   public void paint(Graphics g)
   myPicture1.draw(g);
   myPicture1.setXY(300, 20);
   myPicture1.setXY(x, 20);
   myPicture1.draw(g);
   public void actionPerformed (ActionEvent ae)
       if (x > getSize().width - 175)
           /* 175 = diameter(150) + xOffset(10) + xIncrement(5)
        * + xOffsetToNotRunToEdge(10) n
        x = 0;
        else
        x += 5;
        repaint();
   class Picture {
       private Color faceColor;
       private Color eyeColor;
        private Color smileColor;
        private int x = 50;
        private int y = 30;
        public Picture (Color f, Color e, Color s)
            faceColor = f;
            eyeColor = e;
            smileColor = s;
        public void setXY(int newX, int newY)
            x = newX;  y = newY;
public void setColors(Color faceColor,
Color eyeColor, Color smileColor)
     this.faceColor = faceColor;
     this.eyeColor = eyeColor;
     this.smileColor = smileColor;
       public Color getFaceColor()
           return faceColor;
       public Color getEyeColor()
           return eyeColor;
           public Color getSmileColor()
               return smileColor;
           public void draw(Graphics g)
               g.setColor(faceColor);
               g.fillOval(x + 10, y + 40, 150, 150);
               g.setColor(eyeColor);
               g.fillOval(x + 60, y + 85, 10, 10);
               g.fillOval(x + 100, y + 85, 10, 10);
               g.setColor(smileColor);
               g.drawArc(x + 35, y + 75, 100, 100, 200, 140);
         class Picture2 {
         private Color topLight;
         private Color midLight;
         private Color lowLight;
         private int x = 50;
         private int y = 30;
         public Picture2 (Color f, Color e, Color s)
            topLight = f;
            midLight = e;
            lowLight = s;
        public void setXY(int newX, int newY)
            x = newX;  y = newY;
public void setColors(Color topLight,
Color midLight, Color lowLight)
     this.topLight = topLight;
     this.midLight = midLight;
     this.lowLight = lowLight;
       public Color gettopLight()
           return topLight;
       public Color getmidLight()
           return midLight;
           public Color getlowLight()
               return lowLight;
           public void draw(Graphics g)
               g.drawRect (100, 100, 50, 150);
               g.setColor(topLight);
               g.fillOval (100, 100, 50, 50);
               g.setColor(midLight);
               g.fillOval(100, 130, 50, 50);
               g.setColor(lowLight);
               g.fillOval(100, 160, 50, 50);
   }

Use Swing Components. =)

Similar Messages

  • Desktop "Change Picture" grayed out

    Before installing Tiger I was able to select "Change Picture" in System Preferences Desktop. Now that feature is grayed out, and a single picture is continuously display on the desktop. Any idea how to fix this?

    carpet1,
    You said:The file does contain an instruction in the default folder "Change..Never." When I tried to change this to 0 and save, finder could no longer find the file. I'm lost!I too am lost. My previous instructions did not specify any file alterations. I do not know, nor did I specify that you should make any changes to the com.apple.desktop.plist file. The fact that the file was altered without a plist editor probably disrupted normal behavior.
    If I open my com.apple.desktop.plist file with TextWrangler, I do see the following string...(YPlacementVChangeVRandomPlacementKeyTag_ChooseFolderPathCollectionStringZ ChangePathZChangeTime^ImageFileAlias]TimerPopUpTag]ImageFilePathZFillScreenUNev er), but I do not know how to change specific phrases in this plist to alter desktop behavior.
    Whenever a plist file is removed from preferences folder a new one will be regenerated to replace the old one after a log out/in or restart. That means you will have an old com.apple.desktop.plist file on your Desktop and a new com.apple.desktop.plist in your ~Library/Preferences Folder. You should be able to discard the old plist and allow the new one to resume normal default functions. Plist files should not normally be edited unless you know specifically with certainty what effect your changes will produce.
    Repeat the plist removal procedure if necessary, but do not make any changes to the replacement file. Permission repair may be considered without penalty.
    ;~)

  • Change picture frame on summary blog page

    I added a blog to my page. On the entries page I changed pictures and selected for these pictures no frame at the information selection. Now at the summary of the blog I can see these pictures, but only with a frame. How can I change this frame on the summary blog page?

    you need to know iweb widgets and some tricks to add picture frame in blog summary page:
    http://temp.cyclosaurus.com/revolving/Blog/Blog.html
    or give them feedback:
    http://www.apple.com/feedback/iweb.html

  • Changing picture at runtime using delphi

    Post Author: iman_400
    CA Forum: Other
    Please help me, is there anyway we can change picture at runtime using delphi 7.0 and CRXIR2?

    Hi, Lee;
    For the version of Crystal Reports that comes with .NET, you can use something like one of our samples shows:
    https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe
    Look for the sample, vbnet_win_DynamicImage.zip. It uses an ADO.NET dataset to change the image.
    For Crystal Reports XI R2 and Crystal Reports 2008, you can more directly change the image location using built in functionality.
    In the Designer, choose Insert > Picture. Choose a default image to show and save it. Right-click on it and select Format Graphic. Go to the Picture tab and click the formula button for Graphic location. Save the report.
    Then, at runtime you can populate the Formula with the new location for your image, either a URL or disk file location.
    See the following note for more information:
    [Image|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313338333333373334%7D.do]
    Best Regards,
    Jonathan

  • Change Picture In Offline Mode

    Hi All,
    I've found that in Word 2013 Change Picture insists on having Internet access. And it's a pain, there are many reasons why we do not want Word charging off to the Internet at the merest hint of a request.
    To test, try creating a document and populating it with a jpeg (or similar) from a local source.
    Use Change Picture and see the result. You have to dive down to the Work Offline to get a local image.
    Then try Unchecking the "Allow Office to connect to the Internet", under Options -> Trust Center -> Trust center Settings -> Privacy Options.
    Repeat, this time you get a pop up saying this feature needs the Internet.
    Now, MS and others may think that the Internet and Cloud is the be all and end all, but why forcing a feature such as Change Picture needs the Internet is beyond me.
    Has anyone found a way to make this behave a bit more rationally?

         Do you mean you get the following error in the screenshot?
    That's not the same as the error I get:
    Note: there is no "Work offline" option in Office 2013. Maybe there was once, but has been removed?
           I think the Change
    Picture button is used for online pictures, and it needs an internet connection.
    I think you're correct in that someone in Microsoft thinks this is the right way to go. I think that preventing the rest of us from working offline permanently is absolutely the wrong decision by Microsoft R&D. For someone writing and updating business
    specifications, updating and inserting screenshots from the web is almost never desirable.

  • I am trying to set my background setting to change when ever I log in, I clicked on both 'change picture' and 'random order' boxes as my settings, but when ever I log in it has the same background as before. Does any body know how to fix this?

    am trying to set my background setting to change when ever I log in, I clicked on both 'change picture' and 'random order' boxes as my settings, but when ever I log in it has the same background as before. Does any body know how to fix this?

    You have to enter the Apple ID and password. You are running into the Activation Lock
    iCloud: Find My iPhone Activation Lock in iOS 7
    Is there a way to find my Apple ID Name if I can't remember it?
    Yes. Visit My Apple ID and click Find your Apple ID. See Finding your Apple ID if you'd like more information.
    How do I change or recover a forgotten Apple ID Password?
    If you've forgotten your Apple ID Password or want to change it, go to My Apple ID and follow the instructions. SeeChanging your Apple ID password if you'd like more information.

  • Moving or changing pictures on a home page

    Hi
    I would like to set up changing pictures or video on the home page of my website.  The main aim is to have movement on the home page when people enter the site making it more attractive and appear as the latest news.  Does anyone know how I can achieve this in iweb?

    The first thing to do is to find out how to do it on a non-iWeb page. Similar to this :
    http://www.google.com/search?q=how+to+add+a+news+feed+to+my+website
    But to keep it simple : use a blog. Then the latest news is always at the top.
    The other simple way is to move the content down, and add new content at the top of the page.
    Or add a new page with the new content and make a reference to it on your home page.
    Do not expect too much from iWeb.

  • Why my iMac does not change picture when waking from sleep ?

    My iMac has Yosemite installed, I have tried to kill the system preferences in the library but it did not solve the problem.
    I restarted, PRAM, repaired system permissions, log on off, etc. and nothing, nada !
    It used to work without problems, changing the picture on my desktop every time the computer was waken up.
    What it could be wrong ?
    I have noticed that the CPU is now above 55% most of the time and iStat says that SGProtocol Service is constantly in 99%. I don´t have a clue what that means.
    Any help would be appreciated.
    Thanks in advance,
    Rod

    OK. I found the solution.
    The computer changes the picture after sleep is activated from the power button but no from a hot corner, like it used to do. Obviously is a bug.
    I ruled out the iStat, SG Protocol and high CPU, which are not related with the problem.
    It is not a big deal, now I set it to change the image every hour, and it works !
    Thanks anyway.

  • Change picture size when sending picture from I-phone 5 to HP Officejet Pro 8900

    I just installed my new HP Officejet Pro 8900.  So far every thing is working great except when I sent a picture from my I-phone 5, the picture printed the full size of the 8 1/2 x 11 page.  Not only do I NOT want a picture that big but I do not want to go thru that much ink.  How do I change the picture size to a 4 x 6 or 5 x 7? 
    Any assistance would be greatly appreciated as part of the reason I bought this printer was so I could e-print.  I take and print a lot of pics from my phone, I was hoping to avoid having to e-mail  pictures to computer in order to print.
    Thanks for your help.

    Hi BFPadmin,
    Welcome to the HP Support Forums.
    You didn't say whether you were sending the picture from your iPhone using Apple's AirPrint feature or using HP's ePrint app.   I have included a general document about printing from an Apple mobile device and it details the different ways to print to your HP printer.  I have also included the FAQ documents for the HP's ePrint app and HP's Printer Remote App.
    Printing from an Apple Mobile Device
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&docname=c02796271
    HP ePrint Mobile App FAQs
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&dlc=en&docname=c01923321
    HP All-in-One Printer Remote Mobile App FAQs
    https://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&docname=c03561640#N132
    Regards,
    Happytohelp01
    Please click on the Thumbs Up on the right to say “Thanks” for helping!
    Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
    I work on behalf of HP

  • JLabel click event to change picture

    Hi All,
    I am new to GUI programming and need some help.
    I am trying to get a picture of a match to change to a different picture of a match when i click on it.
    Below is how I'm currently trying to do it.
    import javax.swing.UIManager;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Application2 {
      boolean packFrame = false;
      //Construct the application
      public Application2() {
        Frame2 frame = new Frame2();
        //Validate frames that have preset sizes
        //Pack frames that have useful preferred size info, e.g. from their layout
        if (packFrame) {
          frame.pack();
        else {
          frame.validate();
        //Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width;
        frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
      //Main method
      public static void main(String[] args) {
        try {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        catch(Exception e) {
          e.printStackTrace();
        new Application2();
    public class Frame2 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      ImageIcon match = new ImageIcon("match.JPG");
      ImageIcon match2 = new ImageIcon("match2.JPG");
      JLabel jLabel1 = new JLabel(match);
      JLabel jLabel2 = new JLabel(match2);
      //Construct the frame
      public Frame2() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        jLabel1.addMouseListener(new Frame2_jLabel1_mouseAdapter(this));
        contentPane.add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(jLabel1, null);
       // jPanel1.add(jLabel2, null);
      //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
      void jLabel1_mouseClicked(MouseEvent e) {
        // DOESN'T seam to work
        jLabel1 = new JLabel(match2);
       // jPanel1.remove(jLabel1);
       // jPanel1.add(jLabel1);
        jPanel1.repaint();
        repaint();
    class Frame2_jLabel1_mouseAdapter extends java.awt.event.MouseAdapter {
      Frame2 adaptee;
      Frame2_jLabel1_mouseAdapter(Frame2 adaptee) {
        this.adaptee = adaptee;
      public void mouseClicked(MouseEvent e) {
        adaptee.jLabel1_mouseClicked(e);
    }

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame2Rx extends JFrame {
        JPanel contentPane;
        BorderLayout borderLayout1 = new BorderLayout();
        JPanel jPanel1 = new JPanel();
        ImageIcon match = new ImageIcon("images/bclynx.jpg");
        ImageIcon match2 = new ImageIcon("images/greathornedowl.jpg");
        ImageIcon[] icons;
        int iconCount;
        JLabel jLabel1 = new JLabel(match);
        JLabel jLabel2 = new JLabel(match2);
        //Construct the frame
        public Frame2Rx() {
            icons = new ImageIcon[] { match, match2 };
            iconCount = 0;
            enableEvents(AWTEvent.WINDOW_EVENT_MASK);
            try {
                jbInit();
            catch(Exception e) {
                e.printStackTrace();
        //Component initialization
        private void jbInit() throws Exception {
            contentPane = (JPanel) this.getContentPane();
            contentPane.setLayout(borderLayout1);
            this.setSize(new Dimension(400, 300));
            this.setTitle("Frame Title");
            jLabel1.addMouseListener(new Frame2_jLabel1_mouseAdapter(this));
            contentPane.add(jPanel1, BorderLayout.CENTER);
            jPanel1.add(jLabel1, null);
            // jPanel1.add(jLabel2, null);
        //Overridden so we can exit when window is closed
        protected void processWindowEvent(WindowEvent e) {
            super.processWindowEvent(e);
            if (e.getID() == WindowEvent.WINDOW_CLOSING) {
                System.exit(0);
        void jLabel1_mouseClicked(MouseEvent e) {
            jLabel1.setIcon(icons[++iconCount % icons.length]);
            jLabel1.revalidate();  // esp if image sizes not equal
            jLabel1.repaint();
        public static void main(String[] args)
            Frame2Rx f = new Frame2Rx();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
    class Frame2_jLabel1_mouseAdapter extends java.awt.event.MouseAdapter {
        Frame2Rx adaptee;
        Frame2_jLabel1_mouseAdapter(Frame2Rx adaptee) {
            this.adaptee = adaptee;
        public void mouseClicked(MouseEvent e) {
            adaptee.jLabel1_mouseClicked(e);
    }

  • Desktop Pictures: "Change Pictures" in System Prefs no longer works.

    I used to have my Desktop pictures change every five minutes using a special folder of photos. This function no longer works. The setting appears to be in effect according to the System Preferences Desktop Pictures Pane but the function appears to be broken in 10.4.5. I have trashed the Destop Pictures Preferences file in the Preferences Folder, but it still will not work.
    Can anyone using Tiger 10.4.5 get this to work?
    Griff

    OK, that was really dumb!
    The reason for the problem became abundantly clear when I quit Pathfinder. Suddenly the picture change became functional again.
    So, I guess Pathfinder will not follow the Finder when it comes to settings like this.
    Hey Cocoatech, how about getting this into your next release?
    Griff

  • Changing Picture at Runtime VS2005

    Hi
    I'm using VS2005 enterprise edition and the Crystal Reports that came with that package (the file versions say they are 10.2.3600).  All I want to do is insert an image at runtime, however this appears to be impossible judging by all the code I've looked through.  It seems that it was easy to do with version 9 and may be possible with version 11 but I can't find any code that works with the version that comes with VS2005.  Of course there's the standard method to insert an image and link it to a particular image in a folder, however this is fairly useless as when the program is deployed the user can choose which directory he installs to.  So what do I have to do to get this working.  Is it essential to upgrade?  If so what version do people recommend?  Once I have that version how do you change the image you want displayed in code (preferably VB.NET but I'm sure I can work out C#)?
    Thanks
    Lee Ottaway
    Fusion Software (UK) Ltd

    Hi, Lee;
    For the version of Crystal Reports that comes with .NET, you can use something like one of our samples shows:
    https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe
    Look for the sample, vbnet_win_DynamicImage.zip. It uses an ADO.NET dataset to change the image.
    For Crystal Reports XI R2 and Crystal Reports 2008, you can more directly change the image location using built in functionality.
    In the Designer, choose Insert > Picture. Choose a default image to show and save it. Right-click on it and select Format Graphic. Go to the Picture tab and click the formula button for Graphic location. Save the report.
    Then, at runtime you can populate the Formula with the new location for your image, either a URL or disk file location.
    See the following note for more information:
    [Image|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313338333333373334%7D.do]
    Best Regards,
    Jonathan

  • Background Change Picture Feature Not Working

    I have had my macbook pro for about 6 months now and my change background feature worked fine when I first got it. I could add folders of pictures and tell it change ever 5 seconds and it worked. Over time, I messed with my dock settings and background settings with other third party programs and stuff and decided I didn't like them so I would just go back to the features built into Leopard. I tried to do a random, change every 5 seconds background change folder deal the other day and it never would change. I tried doing it on the default folders like the apple images and the nature ones and stuff but it would never change. I can still add folders. I can click the option of random order and change every x times. When I close out my system preferences, it resets what I did. I go back to my background panel and they are unchecked. How can I fix this and is anyone else having this problem?

    delete the file com.apple.desktop.plist from homedirectory/Library/Preferences and log out/in. You background settings should be set to defaults and you should be able to change them as you like.

  • Change picture package default background color

    How do I change the background color for a picture package?  It keeps defaulting to white.  I need it to be black.
    Thanks,
    SP

    In Photoshop 11.0.1? Bridge 3.x? Or…?
    Try this older tech note:
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=323172

  • How to change picture box into sentence

    I need to make 3 picture boxes disappear when one of them is clicked and a sentence to appear in their place. For example if picture box 1 is clicked they all three disappear and the sentence "you have chosen picture box 1 appears"

    Put a label and three pictureboxes on your form from the Toolbox.
    The code below alters the label for the name of a picturebox clicked on and the picturebox's "disappear". Clicking on the label will make the label text return to "Waiting" and the picturebox's will "reappear". The label is
    centered in the form whenever its text is changed.
    Option Strict On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
    Label1.Text = "Waiting"
    Label1.Left = CInt((Me.ClientRectangle.Width / 2) - (Label1.Width / 2))
    End Sub
    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
    Label1.Text = "Waiting"
    Label1.Left = CInt((Me.ClientRectangle.Width / 2) - (Label1.Width / 2))
    PictureBox1.Visible = True
    PictureBox2.Visible = True
    PictureBox3.Visible = True
    End Sub
    Private Sub PictureBox_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click, PictureBox2.Click, PictureBox3.Click
    Label1.Text = DirectCast(sender, PictureBox).Name & " was selected."
    Label1.Left = CInt((Me.ClientRectangle.Width / 2) - (Label1.Width / 2))
    PictureBox1.Visible = False
    PictureBox2.Visible = False
    PictureBox3.Visible = False
    End Sub
    End Class
    La vida loca

Maybe you are looking for

  • Creation of PDF with different page sizes

    I am generating PDF using Acrobat Distiller from my application from the .ps file. From one machine, the PDF is generated with different page sizes.one page with 8.5*12.99 and other pages with 8.5*11 in the same PDF. However the PDF is created with c

  • How to remotely fix computer in Yosemite

    I am often called upon to fix my 83 year old father's iMac. I would love to be able to somehow remote into his computer and fix it that way vs having to drive all the way to his house. Is there a way of doing this? I don't quite understand the differ

  • Linux help please!

    OK, so.. on my iMac I am running OS X and Windows XP which was installed via boot camp. I decided I wanted to try Kubuntu out so I done the whole live cd deal and installed it. Well it got to 94% and had a "fatal error." Upon rebooting I noticed that

  • Resize still images in Photoshop?

    Hi there So I'm using jpegs (say 4000 x 4000 ish) in a DVC Pro HD sequenece.  Would you recommend re-sizing in Photoshop beforehand, or is it fine to let Final Cut do the resizing? Im using Final Cut 7. Appreciate any recommendations, Richard

  • I cannot open any new tabs in Firefox on my PC. I have Vista Home ppremium

    I cannot open any new tabs in Firefox on my PC. How can I correct this