JButton, once click, made me headache

i want to use event of JButton, but i don't want to use its listener because i want to be easier.
method action doesn't work anyway, java document suggests me use dispatchEvent() method. when i try dispatchEvent(), it is a final method (i want to laugh) !
who knows how to get event from JButton except listener?
thanks

Here is a very easy code using listeners.
This button prints "hello", every time it is clicked.
     JButton b = new JButton("HELLO");
     ActionListener listen = new ActionListener() {
     public void actionPerformed(ActionEvent e) {
          System.out.println("hello");
     b.addActionListener(listen);
I hope this helps,
Val.

Similar Messages

  • How to fire "table change" once click other regions outside the table erea?

    I have a JTable created with DefaultTableModel. Usually the edit behavior of table cell is like this:
    1) Select one cell, it is highlighted in blue.
    2) Double click the cell, it's made editable with white background.
    3) Two scenarios
    (a) Once finish edit, press "Enter", the cell background turns from white to blue. At the same time, the table change is "fired" .
    (b) Once finish edit, click another cell, the originall cell turns white, and the new-clicked cell is highlighted in blue. At the same time, the table change is "fired".
    4) While editing one cell, and click somewhere OUTSIDE the table area. In this case, the table change is NOT fired.
    [This cause a confusion, user sees the changed text in table cell, but actually it is not stored and will not be stored in the table.]
    So what I want to implement is: once click the region outside the table, the text in that editabe cell (where you are just editing) is stored and fired.
    Can you help me? Thanks in advance!

    sabre150 & other experts,
    [see background in my first message]
    User is still not completely satisfied with the current behavior, though "table changed" can be fired when clicking other controls(eg. buttons or checkboxes).
    If I click a panel region(instead of a particular control), the "table changed" can not be fired. However, it is expected.
    I guess the reason is:
    a panel doesn't has a focus. so when clicking panel, the focus is not "lost" to the table cell.
    Any hints?

  • Keep a button set to Hover once clicked

    Hi,
    I was wondering if there was a quick way to set a button to
    it's hover state once clicked?
    I know how to do this by having it be a movie clip and
    changing its time line position onRollOver. onRollOut and
    onRelease. I am just trying to do this quick using a button so
    didn't want to deal with all that. Thanks!

    it takes a bit of Actionscript - but yes, its possible. --and
    instead of using a button, use a movieClip - and assign the actions
    on the main timeline.
    I'll use _xscale in my example, but you can do the same
    thing, and just put your "rollOver effect" on frame 2, and use
    gotoAndStop();.
    mc.onRollOver = function() {
    mc._xscale = 110;
    mc._yscale = 110;
    mc.onRollOut = function() {
    if (testV == true) {
    mc._xscale = 100;
    mc._yscale = 100;
    mc.onRelease = function() {
    if (testV == false || testV == undefined) {
    testV = true;
    } else if (testV == true) {
    testV = false;
    }

  • Making a button dissapear once clicked.

    Hi,
    I've created a button which makes a div appear. But what I want to know is make the button either dissapear once clicked or change its function and name to make the div dissapear.
    Problem is I have already used the onClick function, here is the code
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.getElementById(id).style.display = visibility;
    </script>
    HTML:
    <p><a href="#" onclick="setVisibility('hidden', 'inline'); this.onclick=function() { return false; };";>See More</a></p>
          <div id="hidden"><time>12/10/2010</time>
          <br />
          <p>Production for No More's music video is under way amd will be with you soon. </p><time>12/10/2010</time>
          <br />
          <p>Production for No More's music video is under way amd will be with you soon. </p>
          </div>
    Any help would be appreciated.
    Tom

    Thats amazing as usual! Works perfectly.
    New problem: I've now added a "read less" button that then hides the 'hidden' div. It goes a little something like this:
         <p><a href="#" id="hoohaa" onclick="setVisibility('hidden', 'block');setVisibility('hoohaa', 'none');return false;">Read More</a> </p>
         <div id="hidden">
         <br />
         <p><a href="#" onclick="setVisibility('hidden', 'none');";>Read Less</a></p>
         <time>12/10/2010</time>
          <br />
          <p>Production for No More's music video is under way amd will be with you soon. </p>
          </div>
    Can I make it so when you click read less the 'read more' button reappears.
    Cheers
    Tom

  • Apple Menu Bar once clicked would also open other menu bars

    Hello! I would like to receive some advice about this particular problem. The Mac is 4 months old. Description of the problem: Once the Mac starts and I click the apple menu bar, the drop down menu would open and so are the other menu bars i.e. the file, edit, view, help etc. The menu bars will drop one after another non-stop. This problem also affects when opening files in Finder. The chosen file, once clicked will not open but it will revert back to the documents main folder. I hope you can help me with this. Thank you very much.

    Hi! Thanks a lot! I tried your suggestions but the problem persists. Further description: It happens only when the computer is set to automatic log-in mode. I observed that if I hit any keys from the keyboard just before doing anything else after start-up, the "problem" disappears.

  • How do I create buttons that once clicked and un clicked, alter an image? ...

    How do I create buttons that once clicked and un clicked, alter an image?
    So for example if I imported a psd file into Muse with 5 layers, could i create 5 buttons which, when clicked, each individually took off and added 1 layer?
    Basically this should make what i'm trying to say clear (when it's loaded click the arrow and you'll see): http://lust.nl/lustArchive/noordzee/noordzee.html
    Appreciate any help

    Hi Joe,
    Please use this option to hide the target on click - http://prntscr.com/3plqn0
    - Abhishek Maurya

  • Anyone know code to open browser when JButton is clicked...Urgent!!!!

    Hello there,
    Does anyone know how to open a browser (i.e., i want to run servlet program http://localhost:8080/register.html) when JButton is clicked.
    Any help will be appreciated..please
    Sangeetha.

    Hi
    on the onclick event of the JButton give this code
    if ur working on WIn NT
    try {
         Runtime r = Runtime.getRuntime();
         r.exec("cmd /c start iexplore");
         }catch
         (Exception e) {}
         

  • Anchors on index page in Muse 2014 freeze scrolling once clicked.

    Hi everyone,
    On my index page I have two anchor points with arrows that link to those anchors. Once clicked, they take me to the right spot (and smoothly), but once the page has scrolled to the anchor point, I am no longer able to scroll up or down. I do not encounter this problem on other pages of my site.
    My index page: http://www.mdusault.com/
    Try clicking on the red arrow. It takes you down nicely, but then doesn't allow you to scroll anymore.
    On another page (not index page): Fading Lives
    Click on "More Info", it takes you down and still allows you to scroll afterwards.
    Any help? Is there a way to fix this issue?
    Thanks for your help,
    M

    Replied here :
    Muse CC 2014 Slideshow Horizontal Scrolling Thumbnails (Possible?)

  • Two questions: First, the homepage button on my browswer has stopped working. Once clicked, nothing happens. Second, when I try to upload pics to blogger, it says "Server Error".

    The homepage button has stopped on both my desktop and netbook browser, as about about a week ago. Once clicked, nothing happens. Yet all other browser buttons are working fine. Second, when I try to upload pics to blogger, it says "Server Error".
    The server error message on blogger happened about the same time, and although there have been rare occasions where it worked, but mostly it doesn't. I've tried a couple of times every day, and it's only worked twice. But I am able to do it on other browsers, leading me to believe it's a firefox problem. (For the record, blogger seems to have recently updated their pic upload feature).

    This usually happens if Spotlight is disabled on a drive. When you tried MacPilot, did it have an option to disable Spotlight? I haven't used the app, so don't know whether that is the case or not, but if it did and you inadvertantly, or even deliberately, disabled Spotlight then the Finder won't display anything but the most basic information about a file--thus you won't see dimensions or Last Opened, just size and dates created and modified.
    Francine
    Francine
    Schwieder

  • How to disable button once click

    Hi,
      I have made a dialog program, in which, on the screen I have to push button, PB1 and PB2, my requirement is Once the user click on PB1 then that button I want to disable (inactive mode) or invisible till user click on PB2,  I have written the code as below but it is not working,
       module USER_COMMAND_0100 input.
        OK_CODE  = SY-UCOMM.
      CASE OK_CODE.
      WHEN 'PB2'.
        CLEAR : VBELN,WA_VBAP,IT_VBAP[],WA_VBAP_RFC,IT_VBAP_RFC,MESSAGE.
      WHEN 'PB1'.
       PERFORM GET_SO_LINE.
      ENDCASE.
    endmodule.                 " USER_COMMAND_0100  INPUT
    now when the OK_CODE is PB1  in that I have below code
       LOOP AT SCREEN.
        IF SCREEN-NAME       = 'PB1'.
           SCREEN-ACTIVE     = '0'.
           SCREEN-INVISIBLE  = '1'.
           MODIFY SCREEN.
        ENDIF.
         IF SCREEN-NAME       = 'VBELN'.
           SCREEN-ACTIVE     = '0'.
           SCREEN-INPUT      = '0'.
    *       SCREEN-INVISIBLE  = '1'.
           MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    but with this code it is not working.
    regards,
    zafar

    Hi,
    Declare a global variable that will serve as your flag.
    * data declaration..
    data: g_flag type c.
    * PAI
    module USER_COMMAND_0100 input.
        OK_CODE  = SY-UCOMM.
      CASE OK_CODE.
      WHEN 'PB1'.
              g_flag = 'X'. " set flag
      WHEN 'PB2'.
              g_flag = space. " reset flag
      ENDCASE.
    endmodule.
    * PBO
    LOOP AT SCREEN.
        IF SCREEN-NAME       = 'PB1'.
               If g_flag = 'X'. " PB1 was clicked
                 SCREEN-INPUT  = '0'
               else.
                 SCREEN-INPUT  = '1'
               endif..
           MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    -Jake

  • How do I stop a Movie Clip (Button) from working once clicked?

    Ok,
    I'm using a movie clip as a button to show content on a page, effectively its like a new page of the website. Problem is, with the script im using for it, once the content is show, the button is still active and if clicked again, will re-load the content. I want a way to effectively disable the button whist the content is shown.
    Thanks.
    this.services_inner.buttonMode = true;
    this.services_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_services);
    this.services_inner.addEventListener(MouseEvent.CLICK, onClick_services);
    function rollOver_services(evt:MouseEvent):void {
    this.services_inner.play();
    function onClick_services(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.colour.gotoAndPlay(2);

    Thanks, that does stop it, however, i now need it to work again if a different button is clicked... there are 4 buttons (movie clips) in total, so I assume I'd just need to add the event listener back again on click of the others?
    This is the "Services" Button, with the event listener removal.....
    this.services_inner.buttonMode = true;
    this.services_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_services);
    this.services_inner.addEventListener(MouseEvent.CLICK, onClick_services);
    function rollOver_services(evt:MouseEvent):void {
    this.services_inner.play();
    function onClick_services(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.colour.gotoAndPlay(2);
    this.services_inner.removeEventListener(MouseEvent.CLICK, onClick_services);
    This is the "Contact" Button, which when clicked would need to "re-activate" the Services button.
    this.contact_inner.buttonMode = true;
    this.contact_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_contact);
    this.contact_inner.addEventListener(MouseEvent.CLICK, onClick_contact);
    function rollOver_contact(evt:MouseEvent):void {
    this.contact_inner.play();
    function onClick_contact(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.art.gotoAndPlay(2);
    this.services_inner.removeEventListener(MouseEvent.CLICK, onClick_contact);

  • When a search term is entered, then followed up in a drop-down box, once clicked nothing happens. Please help me!

    For example, when I type an artist's name in the search bar, such as Drake, it'll say "2 Albums, 19 songs, Nothing Was The Same, Thank Me Later" etc. then once I click on any of them, it doesn't take me to that artist and just acts as if the search bar results are something that you can't click on.
    Will I need to re-install iTunes and will this remove any of my music / downloaded music?
    Thanks

    Reinstalling iTunes should not affect your library.
    Try clicking the small magnifying glass in the search box and unticking the option to Search entire library. this will restore the previous function of the search feature which may work better for you. You might also find the newer version works better if you enable it again.
    tt2

  • Slideshow w/ timer, navigation problem (once clicked timing off)

    I have a AS3 flash slide show that uses the timer method with a wait() function to change slides.  So the preloader is on frame one and the first slide is on frame two and the second slide is on frame three and so on.  At each slide frame there is a wait(7) statement so that the swf moves ahead to the next frame every seven sec. When I create a nav element that uses the gotoAndPlay function to target each frame, everytime the nav is clicked and goes to the corresponding slide the timing of the slides is all messed up. 
    Can anyone help me by suggesting a solution to this?  I may be nieve but it seems that once the button in the nav is clicked the timer keeps going on the slide the user was on when the nav was clicked.  How can I clear the wait() timer on click?  When I just add a remove.EventListener to the button the function in the frame is not available to the button though they are both in the same frame.
    Below is the wait() I am using in the root stage timeline:
    function wait(duration:Number) {
        stop();
        var timer:Timer=new Timer(duration*1000,1);
        timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerComplete);
        timer.start();
    function onWaitTimerComplete(e:TimerEvent):void {
        e.target.removeEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerComplete);
        stage.removeEventListener(Event.RESIZE, onStageResize);
        play();
    Below is the code for the click inside the movieClip button:
    b1.addEventListener (MouseEvent.CLICK, onClick);
    function onClick( event:MouseEvent):void
    MovieClip(root).gotoAndPlay(2);
    THIS PROJECT IS LOCAL SO NO LINK AVAILABLE

    Look further int the Timerclass to see what other methods you can make use of.  It has a reset() and a stop() method that could get you what you want.  One thing you will probably need to do though is to decalre the Timer outside of the function so that it has scope outside of the function so thaat you can have other functions' code control it.

  • ONCE i made a photo project how do I access the original photos?

    once we make a photo project  how do I access the original photos?

    Do you mean to upload or use in another app or some such?
    There are many, many ways to access your files in iPhoto:   You can use any Open / Attach / Browse dialogue. On the left there's a Media heading, your pics can be accessed there. Command-Click for selecting multiple pics.
    (Note the above illustration is not a Finder Window. It's the dialogue you get when you go File -> Open)
    You can access the Library from the New Message Window in Mail:
    There's a similar option in Outlook and many, many other apps.  If you use Apple's Mail, Entourage, AOL or Eudora you can email from within iPhoto.
    If you use a Cocoa-based Browser such as Safari, you can drag the pics from the iPhoto Window to the Attach window in the browser.
    If you want to access the files with iPhoto not running:
    For users of 10.6 and later:  You can download a free Services component from MacOSXAutomation  which will give you access to the iPhoto Library from your Services Menu.
    Using the Services Preference Pane you can even create a keyboard shortcut for it.
    For Users of 10.4 and 10.5 Create a Media Browser using Automator (takes about 10 seconds) or use this free utility Karelia iMedia Browser
    Other options include:
    Drag and Drop: Drag a photo from the iPhoto Window to the desktop, there iPhoto will make a full-sized copy of the pic.
    File -> Export: Select the files in the iPhoto Window and go File -> Export. The dialogue will give you various options, including altering the format, naming the files and changing the size. Again, producing a copy.
    Show File:  a. On iPhoto 09 and earlier:  Right- (or Control-) Click on a pic and in the resulting dialogue choose 'Show File'. A Finder window will pop open with the file already selected.    3.b.
    b: On iPhoto 11 and later: Select one of the affected photos in the iPhoto Window and go File -> Reveal in Finder -> Original. A Finder window will pop open with the file already selected.

  • Not Showing Depression When JButton is Clicked/Selected

    To all,
    I've searched through the forums and the web for a while now and have come up with surpisingly little material on this.
    I want to create a JButton that, when you click on it, registers a mouse event, etc. but does not look like it's being depressed (ie: the top and left row of single pixels do not change color and stay the color of the button background).
    I have read the thread at http://forum.java.sun.com/thread.jspa?forumID=57&threadID=140220 , but to no avail. I've tried changing the Button.select color through the UIManager (inserting the line of code given at that thread into my class before creating buttons). I've also tried creating subclasses of both BasicButtonUI and MetalButtonUI that do nothing when paintButtonPressed is called and automatically set the selectColor to the button background color (and setting the custom UI to the button).
    But none of these seem to work. I'm not quite that experieced of a programmer, and so I'm at a loss for what to try next. Any help and further explaination of the posts on the thread given above would be greatly appreciated.
    And if it matters, I'm running 1.4.2 on a XP Pro machine.
    Thanks in advance!
    ~ Anthop

    I've also tried creating subclasses of both BasicButtonUI and MetalButtonUI Well, if you using the Metal LAF, then you can do the following:
    JButton button = new JButton("Test Button");
    button.setContentAreaFilled(false);
    This almost gives you the look you want, except that the Border changes slightly when the button is pressed. To fix this you can replace the default border with your own custom border:
    Border lowered = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    button.setBorder( new CompoundBorder(lowered, new EmptyBorder(3, 15, 3, 15) ) );

Maybe you are looking for

  • Apple ID / Family Sharing for Kids: Change Requests

    My 12 year old has been given an iPhone and I wanted to include him into our Family Sharing. I stumbled over a number of Problems that are a bit disappointing for an Apple user: 1. Asfar as I understand: As he reaches 13, the restriction that the par

  • Can I move MPEG movie from Mac to my iPad?

    Can I move a protected MPEG movie from Mac to my iPad?

  • How can i tell if something was shared using airdrop

    I found a picture on my camera roll that I do not remember taking.  Is there a way to tell if this was shared with someone using AirDrop on my iPhone 5s?  Someone else had access to my phone and I want to see if it was shared with anyone.

  • [SOLVED]Wireless connection becomes deactivated 3 seconds

    Good day, I am new to Arch. I installed Arch successfully and have everything working except the wifi. My WLAN device is Broadcom's BCM4312 and I have installed b43 driver from AUR.  Wired eth0 connection works fine but when I connect using wireless,

  • Caremefile is causing problems.

    Over the last two days I have had my Safari browser frozen by a website called Caremefile, (www.caremefile.info), while "Googeling" some web search, which invites you to download something. The first time it said my Media Player was out of date and a