Make a JButton look like it is pressed

I am setting up a JButton so that it operates like normal when you left click but if you right click it should act like it is being pressed until the next time you right click it.
My problem is that when it is right click activated I want it to paint as if it were armed. When I setArmed and setPressed to true, it will look good so long as the mouse is over the button but not when the mouse leaves the area of the button.
I've made a little hack that changes the background color to the color that is used when armed and it looks OK, but the border isn't drawn right. I am looking for a way to make the button look exactly like it does when held normally. Thanks in advance.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PolledButton extends JButton implements MouseListener
   protected boolean state;
   protected boolean rightClicked;
   protected Color enabledColor = new Color(153, 153, 153);
   public PolledButton()
      super();
      state = false;
      rightClicked = false;
      addMouseListener(this);
   public boolean getState()
      if(rightClicked) return true;
      boolean temp = state;
      state = false;
      return temp;
   public void mouseClicked(MouseEvent e)
      if(e.getButton() != MouseEvent.BUTTON3)
         System.out.println("Not a right click!");
         if(!rightClicked) state = true;
      else
         System.out.println("Right click!");
         if(rightClicked)
            System.out.println("Exiting hold");
            rightClicked = false;
            state = false;
            super.model.setArmed(false);
            super.model.setPressed(false);
            setBackground(Color.lightGray);
         else
            System.out.println("Entering hold");
            rightClicked = true;
            state = true;
            super.model.setArmed(true);
            super.model.setPressed(true);
            setBackground(enabledColor);
   public void mouseEntered(MouseEvent e)
   public void mouseExited(MouseEvent e)
   public void mousePressed(MouseEvent e)
   public void mouseReleased(MouseEvent e)
}

I believe using color is not the right approach
try this out
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PolledButton extends JButton implements MouseListener
protected boolean state;
protected boolean rightClicked;
public PolledButton()
     super();
     state = false;
     rightClicked = false;
     addMouseListener(this);
public boolean getState()
     if(rightClicked) return true;
     boolean temp = state;
     state = false;
     return temp;
public void mouseClicked(MouseEvent e)
     if(e.getButton() != MouseEvent.BUTTON3)
          System.out.println("Not a right click!");
          if(!rightClicked) state = true;
     else
          System.out.println("Right click!");
          if(rightClicked)
               System.out.println("Exiting hold");
               rightClicked = false;
               state = false;
               super.model.setArmed(false);
               super.model.setPressed(false);
          else
               System.out.println("Entering hold");
               rightClicked = true;
               state = true;
               super.model.setArmed(true);
               super.model.setPressed(true);
public void mouseEntered(MouseEvent e)
public void mouseExited(MouseEvent e)
     if(rightClicked)
          super.model.setArmed(true);
          super.model.setPressed(true);
public void mousePressed(MouseEvent e)
public void mouseReleased(MouseEvent e)

Similar Messages

  • How to make a crop looks like a camera zoom?

    If I crop a part of a video and want to make the crop looks like a camera zoom... is there a "zoom transition" to put before and after the crop part? Million thanks if someone can solve this technical question...

    Let's zoom in.
    Select the clip and move the playhead to where you want the zoom to start in the timeline.
    Activate the Crop function Shift-C and selec the middle crop function in the top left.
    Press the keyframe button.
    Move the playhead to where you want the zoom to end.
    Crop and reposition the selection as you like in the viewer.
    Click Done.

  • How do I make multiple movies look like one?

    I created a demo of 136 slides with mostly screencaps and one
    small flash animation. The final published flash file is
    approximately 30MB. When the demo is run on multiple computers, the
    CPU utilization rises up to almost 100%, this makes the demo run
    very slowly on most computers. I was advised to cut my captivate
    movie in half ( in slides)... however even then the CPU utilization
    is quite high. How can I break my demo into multiple linked movies
    (to bring down the file size) but still have it play smoothly
    without it stopping to load after each new movie? How do I make
    multiple movies look like one?
    Thank you.

    Would it work to make the navigation of the page go to the
    next movie?

  • How do I make 29.97fps look like film?

    Sorry for the novice questions, but all of my footage has been shot on a relatively inexpensive camcorder which records at 29.97fps. Is there any easy way to make it look like a 24fps film when I play it back on my NTSC television?
    I am relatively new to FCP but I have started learning compressor and I also heard about a program called 'Nattress?"
    Any help would be appreciated!!!
    -Brian

    There have been endless discussion and tutorials on how to make 29.97 look like film, so I would also check Google. One of the more commonly known plugins that will do this is called Magic Bullet. But be aware, there is only so much that can be done with DV footage shot on a relatively inexpensive camcorder (I'm assuming DV). Most "film effects" plugins will provide you with a nice number of presets that will soften your image, simulate pulldown, add grain, and do some heavy color correction. But they can't invent pixel data that isn't there to begin with.
    What really makes shooting on film so unique and eye catching is that if you can afford to work with it, chances are you can also afford high quality lenses and professional lighting. Things like motion blur, grain, lack of color sampling and a high dynamic range are what give film a unique look. Personally, I think getting a true "film look" for DV is a bit of an impossibility, but people have done some nice stuff with these plugins. Unfortunetly, until the really high end video formats make it into our Handycams, I think we're stuck with simulating the effects, rather than duplicating them.

  • How Would I Make A Photo Look Like A Detailed Painting?

    How would I use the "Oil Painting" feature to make a photo look like a detailed painting?

    Digital Painting Tutorials with Photoshop
    http://psd.tutsplus.com/category/tutorials/painting/
    Nancy O.

  • How to make new Firefox look like old Firefox?

    I was looking at the new version of Firefox and really don't like how it looks. If I update to it is there a way to make Firefox look like the old one? 3.6.24 is the version I'm using now, and I really like how it looks.

    To restore the old appearance right click the orange Firefox button to open the toolbar context menu or use (F10) View > Toolbars.
    * Click the Menu Bar entry and place a check-mark to make the Menu Bar visible all the time (Windows and Linux).
    * Click "Tabs on Top" to remove the check mark and place the Tab Bar at its original position just above the browser window.
    See also:
    * https://support.mozilla.com/kb/why-are-tabs-top
    *https://support.mozilla.com/kb/Menu+bar+is+missing
    *https://support.mozilla.com/kb/how-do-i-get-firefox-button
    * http://www.computertechtips.net/64/make-firefox-4-look-like-ff-3-6/

  • Possible to make a chart look like this?

    I'd like to make a chart look like
    this.
    Is this possible and if yes with which chart type and
    settings, or if no, could someone point me to
    some tutorial or guides how to draw custom shapes and line
    with flex?
    thanks,
    Mickey

    Hi Tony,
    Fisrt it's sure to use datetime, date and time range as a dimension for
    crosstab.
    The default type of ORDERDATE is Date, so you should define a computed
    column in dataset: expression is row["ORDERDATE"] type is Date Time or
    Time. Then using them in your cube.
    If you want display like:
    Jan 1, 00:00 to 11:59 x1
    Jan 1, 12:00 to 23:59 x2
    Jan 2, 00:00 to 11:59 x3
    you should make sure that the ORDERDATE dimension is a Regular group but
    not a Date group. Because the Date group can not set the static level. Do
    you know how to set the regular dimension? In cube builder, when you drag
    ORDERDATE column into Groups, there will be a selection dialog pops up,
    you just chose the regular group is ok. Then you can define your static
    levels to display x1, x2 and x3. There is another way but now we didn't
    open this feature now, the date level will suppport user to define its
    interval(range), but the display is only the number of hour but not 11:59.
    see bug
    #189340(https://bugs.eclipse.org/bugs/show_bug.cgi?id=189340)
    Second, chart can not using the cube's dimension as an axis, chart only
    can use the dataset as its data source, please see comments #3 in
    bug#192853.
    Regards!

  • How to make a shape look like paint?

    Hi,
    Hope you're doing well.
    As you'll see in the attached picture, I'm trying to make this bottle look like a bowling ball. I've drawn the two red stripes and think they work pretty well but still look very "photoshopped." Anyone have any suggestions as to how to make it look more realistic but still good looking?
    Thanks very much.

    Do you have any suggestions as to how I could create a nicer white background like they have in many stock photos. I've attached one that is like what I'd like to create.
    Thanks!

  • To make KDE apps look like KDE apps

    Hi everybody!
    I am very new to Arch so please don't be hard on me. :-)
    I have some problem with looks of apps. I use Gnome but I also have Xfce and KDE installed. My KDE apps look like this:
    As you can see - buttons of Gnome on KDE app. I want to make all apps look like the DE they belong. How do I do that?

    I think that that it would be very hard to use Oxygen effects outside KDE (not kwin: oxygen style has it's own effects).
    When you turn off those effects in KDE apps lok exactlly the same as on your image.
    With effects they look like this:
    Maybe someone has managed to „tweak" something.... hope so.
    Last edited by Xabre (2010-08-26 16:27:51)

  • What app do people use to make their pictures look like this

    what app do people use to make their pictures look like this?

    Apparently redchainsaw answered back saying that wasn't it. Though looking at the pictures I see nothing odd or special about them.
    With that said however, there are many image editors in the App store, and the Instagram App does have several filters you can apply to the photos.   So its very possible that is it.

  • How can I make a photo look like it's on a 3D Box Canvas?

    Hi,
    I have been scratching my head trying to figure out a way to make a photo look like it's wrapped around a wooden frame, like on a box canvas. I'm not concerned with the canvas texture, I just want to know how I can apply an effect or an action to a single image to give it depth. Any ideas?
    Ross

    the one i posted was a psd file using a smart object. Double click the smart object it then opens a new file, you add the photo you need, as you from the example that image is wide screen, my photo wasn't, so you use the 2nd file to make the photo fit how you want, then save and it then alters the original file, hence smart object. The background too was one, hence the perspective.
    The splicing etc is ok , as you say if you have an odd one to do.
    So essentially you make up the smart object once and then reuse. As you woudl need to make the canvas / canvas's into several templates for your liking, be it square / portrait / landscape or even spread over several canvases
    The example i showed here is an illusion, but a pretty good one, It NOT 3d. Its done with shadows, this is the smart object.
    as you see its just a perspective rectangle with the top and bottom left cropped off for the depth.
    these are the psd layers as you see there are only 5, its not an action, but googling i did see an action, i think it was $35. But as i said bear in mind the amount of possible boaard canvases you may want.
    2 of the other layers as you see are for the lighting and the top one is the 3d illusion effect, this particular one has the canvas effect too. I can't remember where i got this one from. I think graphic river do 3d canvas though, there will be others.
    Another thing to consider if using an action is if it can do multiple boards. like ...
    again just to show you before the illusion
    Pretty much example like the emboss effect you can use, all done with lighting and darkness.
    http://graphicriver.net/item/more-canvas-mockups/2581097?ref=riverpsd
    http://graphicriver.net/item/canvas-mockups/917210?ref=riverpsd
    there will be other avenues if you google

  • Why did Apple make iTunes 7 look like a Windows XP App.?

    Why did Apple make iTunes 7 look like a Windows XP App.? This version of iTunes doesn't even look like it belongs in OSX. It's ugly is about the only way I can put it. I can't figgure out why they removed the EQ icon and didn't even assign a key command for it. Now yoy have to go into the menu to select it. Also I have noticed that it sometimes downloads the wrong artwork for album covers. The old version of iTunes seemed much better and I have reverted back to it untill Apple fixes the problems with version 7 and makes it look like part of the OSX family of applications.

    Well I wouldn't say it was ugly but some changes do leave something to be desired.
    I certainly aggree about the equaliser button and the visualiser button has gone too but at least they assigned a key command for it. The scrollbars need more colour and I'd prefer the buttons at the bottom to stand out a bit more like the ones at the top.
    I see no reason to go back to iT6 though, especially as I would misss Cover Flow. You could have a long wait for a change of interface and in the meantime you miss out on the good parts of iT7. If your track information is correct and identical to that on the Store then it shouldn't get the wrong artwork. Luckily I already had most of my album covers in place from other sources such as Amazon and just used iTunes to get a few more. My only complaint about the Get Album Artwork feature is that it's getting it from the US store when I want it from the UK store.
    Anyway these forums are really here to enable users to help each other solve problems and not to discuss Apple's decisions. If there are things you want changing then do what I and others do and send constructive criticisms and requests via the link below, if you haven't already.
    http://www.apple.com/feedback/itunesapp.html

  • Make arch installation look like live media

    like bash completion, colorfull terminal, "boot splash screen" and all that stuff,
    how do i make my installation look like that?

    And for the shell, the installer is using zsh
    http://www.archlinux.org/news/install-m … available/
    https://wiki.archlinux.org/index.php/Zsh

  • How do i make my Video look like a dream.

    Hi, I was doing a cartoon video thing. And There should be this person Dreaming about stuff. Usually in Tv shows, Dreams are Black and While + a smooshy black frame thing. I know how to do the Ones where i make a frame that looks like a box. But it looks sorta ugly. Is there anyway I can make it look cloudy sorta thing? Thanks

    a little use of the *Soft Focus* filter goes a long way in a dream sequence
    or a bit of diffusion will do much the same thing ... layer a second copy of the "Dream" clip on the track above the first, then add some *Gaussian Blur* to that upper copy then adjust the clip's opacity, bringing it down to about 30%, finally right click that upper clip and change the Composite Mode to Screen ... play around with the blur amount, the opacity and the composite mode settings until you hit on a look you like

  • How do I make Flash not look like it's not responding?

    When I run a JSFL script that is pretty intensive and in depth, Flash opens up but doesn't draw itself, and lists "not responding" in the window title bar.
    My question is how can I make Flash look like it's alive (either have output show up in the output window, or have the stage update to the current frame that is navigated to from JSFL script, or put up some dialog box like the export movie progress bar)?  The script sometimes takes about 20-40 seconds to run and the user may think that it's actually crashed.
    I print out times of all my processes and functions, and eventually I get an output that seems reasonable. I thought printing output might help, but there doesn't seem to be a flush command for it that will force it to be written out.
    Thanks.

    You can't: the iCloud server won't allow it.

Maybe you are looking for