Making a button do something

import java.awt.*;
import java.awt.event.*;
public final class ErrorMessage extends Dialog
private Button b1;
ErrorMessage(Frame frame, String s, String s1)
super(frame, s, true);
GridBagLayout gridbaglayout = new GridBagLayout();
setLayout(gridbaglayout);
GridBagConstraints gridbagconstraints = new GridBagConstraints();
Label label = new Label(s1);
gridbagconstraints.gridwidth = 0;
gridbagconstraints.gridheight = 1;
gridbagconstraints.fill = 1;
gridbagconstraints.weightx = 1.0D;
gridbagconstraints.weighty = 1.0D;
gridbaglayout.setConstraints(label, gridbagconstraints);
add(label);
Panel panel = new Panel();
gridbagconstraints.gridwidth = 1;
gridbagconstraints.gridheight = 1;
gridbagconstraints.fill = 1;
gridbagconstraints.weightx = 1.0D;
gridbagconstraints.weighty = 1.0D;
gridbaglayout.setConstraints(panel, gridbagconstraints);
add(panel);
Button b1 = new Button("OK");
gridbagconstraints.gridwidth = 1;
gridbagconstraints.gridheight = 1;
gridbagconstraints.fill = 1;
gridbagconstraints.weightx = 0.0D;
gridbagconstraints.weighty = 1.0D;
gridbaglayout.setConstraints(b1, gridbagconstraints);
add(b1);
b1.addActionListener(this);
panel = new Panel();
gridbagconstraints.gridwidth = 0;
gridbagconstraints.gridheight = 1;
gridbagconstraints.fill = 1;
gridbagconstraints.weightx = 1.0D;
gridbagconstraints.weighty = 1.0D;
gridbaglayout.setConstraints(panel, gridbagconstraints);
add(panel);
validate();
pack();
setResizable(false);
     public void actionPerformed(ActionEvent e)
     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
          setVisible(false);
     dispose();
System.exit(0);
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
every time i try to compile this code i get this error -
.\ErrorMessage.java:37: addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied to (ErrorMessage)
b1.addActionListener(this);
^
neone have ne idea how to solve this problem?

thats only for getting the window to close when you
press the x in the corner or using Alt+F4 isn't it -
i'm just trying to get the button to close itTrue. I didn't read your post properly.
My question now: Do you know what this line means?
b1.addActionListener(this);Anyway... the argument of that menthod has to be a subclass of ActionListener.. suggest you look at simple GUI tutorials available on this website on how to do it.

Similar Messages

  • [svn:osmf:] 14521: ChromeLibrary: moving live and recording buttons to the left hand side of the control bar , and making the button backdrops a little bigger.

    Revision: 14521
    Revision: 14521
    Author:   [email protected]
    Date:     2010-03-02 12:47:27 -0800 (Tue, 02 Mar 2010)
    Log Message:
    ChromeLibrary: moving live and recording buttons to the left hand side of the control bar, and making the button backdrops a little bigger.
    Modified Paths:
        osmf/trunk/libs/ChromeLibrary/assets/control bar.ai
        osmf/trunk/libs/ChromeLibrary/assets/images/eject_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/fullScreenEnter_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/fullScreenLeave_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/pause_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/play_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_up.png
        osmf/trunk/libs/ChromeLibrary/src/org/osmf/chrome/controlbar/ControlBar.as

    Revision: 14521
    Revision: 14521
    Author:   [email protected]
    Date:     2010-03-02 12:47:27 -0800 (Tue, 02 Mar 2010)
    Log Message:
    ChromeLibrary: moving live and recording buttons to the left hand side of the control bar, and making the button backdrops a little bigger.
    Modified Paths:
        osmf/trunk/libs/ChromeLibrary/assets/control bar.ai
        osmf/trunk/libs/ChromeLibrary/assets/images/eject_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/fullScreenEnter_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/fullScreenLeave_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/live_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/minus_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/pause_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/play_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/plus_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/record_up.png
        osmf/trunk/libs/ChromeLibrary/src/org/osmf/chrome/controlbar/ControlBar.as

  • Making a button rollover change a movie clip's frame

    Hi again everyone,
    I knew how to do this in AS2 but now I am having problems
    with making a button on the stage goto a frame in a movie clip on
    the stage.
    I've attached a sample of my code below, hopefully you'll see
    the error and be able to point it out to me?
    I have a movie clip on the stage that has different
    information in different frames. I want to make it so that when
    someone rolls over the button, the movie clip fades in and goes to
    the correct frame to display the information.
    With this setup the way it is below, I keep getting "Warning:
    3590: void used where a Boolean value was expected. The expression
    will be type coerced to Boolean.
    I know where the problem is happening, "function
    XXX(event:MouseEvent):void {navigateToURL(XXXweb)}"
    How can I write this differently and eliminate this problem?
    Thanks,
    Jeremiah

    I'll give that a shot, thanks!
    A follow up question to that one, is there a way to make it
    so that I can have one rolled over function applied to several
    buttons / frames in the movie clip? This movie clip has 50+ frames
    in it and if I could reduce my coding, it would make life a lot
    easier.
    Thanks,
    Jeremiah

  • TS2446 how can i get my security questions if my account is locked why cant you add a forgot security questions button or something to get the security questions back?

    how can i get my security questions if my account is locked why cant you add a forgot security questions button or something to get the security questions back?

    The Three Best Alternatives for Security Questions and Rescue Mail
         1.  Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
         2.  Call Apple Support in your country: Customer Service: Contact Apple support.
         3.  Rescue email address and how to reset Apple ID security questions.
    A substitute for using the security questions is to use 2-step verification:
    Two-step verification FAQ Get answers to frequently asked questions about two-step verification for Apple ID.

  • Making A Button to make something happen....?!

    Okay... Basically, what I'm trying to do is make it so that
    when the user clicks a little arrow, some more text is revealed....
    For example... the user might see..
    "Bid starts at 15:00 GMT >"
    Then the user can click the ">" and the following is
    shown..
    "Bid starts at 15:00 GMT (16:00 CET) <"
    As the moment I've got a white area that moves across to the
    right and uncovers the last bit of text - I'm pretty new to
    Flash... so any help is much appreciated!!
    Thanks!

    is your "white area" a movie clip?
    It's a button
    I would make it a Movie Clip, and on frame 1 put a stop();
    action, then on lets say frame 10, make it large as to reveal the
    text and put stop(); and showwwhiteleft._visible = true; , then on
    frame 20 make the white small again and add gotoAndStop(1);. Give
    it an instance name, lets say reveal_mc... have reveal_mc mask your
    text content.
    showwhiteright._visible = true;
    showwhiteright.onRelease = function(){
    reveal_mc.play();
    this._visible = false;
    then your other arrow to make it go away, name it
    showwhiteleft
    showwhiteleft.onRelease = function()
    this._visible = false;
    reveal_mc.play();
    This might seem confusing, so give me a minute, and I'll whip
    up an example FLA

  • Help making a "button" that appears mid-track

    So... I have a client who's making a French version of a program that has already been made once in English. The English version was not made by me so i'm starting from scratch with some brand new assets.
    The English version has a feature I've not seen before so I'm unsure how to recreate it exactly. Basically, the main program of the disc comes in 2 flavors. the first is just your basic video program with chapter markers for each segment and an end jump to the main menu. the second is whats puzzling me. the program itself is the same video however at certain points during the program a "button" pops up which allows for a jump to another menu. i say "button" in quotes because i'm not sure its the right word.
    what happens is a translucent gray box pops up in the lower left hand corner of the screen that has some text in it with instructions to press the enter button on your remote if you'd like to see a related video. when one presses enter on the remote the DVD then jumps to a sub menu which corresponds to the appropriate supplemental program. the button comes up during the end of one chapter and visually is gone within a few second but the functionality of that button is still available for the first 20 or so seconds of the following chapter and then is disabled until the next instance.
    my question is: what is that gray box button thing? is it scripting or something? i've never seen this before. any suggestions would be greatly appreciated.

    Stolen from DVD Studio Pro Tutorials

  • Making a button in a scrollbar

    Hello,
    First things first. I know my english is not the best but I will try to explain my problem as clearly as I can.
    I have a problem with my Indesign document I am using indesign5.5.
    I am making an ipad version of a newspaper. And I made a scroll section for the menu. So if you wanna see the news you can scroll through the subjects. But if you see a subject you want to read. you have to click on the picture of te articale you want to see.  I can make buttons and I can make a scroll section but I can't make a button in the scroll section. I've tried a lot of ways but it just won't work or it won't scroll with the pictures. I hope you guys can help me to find a solution.
    thank you

    Your English is fine, but you’re in the wrong forum. Please visit the Digital Publishing Suite forum.
    Before posting however please have a look at the FAQs.
    Adding interactivity to scrolling content is a newly added feature that requires the use of the Pan and Zoom overlay instead of scrollable content layers.
    Bob

  • Making custom buttons dissappear when not selected

    I am trying to get around the limitiation of not being able to add audio to a layered menu item.
    Correct me if I am wrong but I think if I create my own buttons (that would reflect the same look as the active layers of the Photoshop file) then I could have audio in the Menu with the same look using the buttons I create.
    Here is my question ... Is it possible to have a button dissappear when its not in the "activated" or "selected" state? I figure that I can create the button to look like the same active state and have the normal state revealed in the background graphic when the button is deselected. I just don't know how to make the button invisible or transparent when its not "selected" or "activated"
    Thanks in advance
    Lou ..

    Yes use overlays for the buttons and do not highlight them in normal state (though you may consider having something showing for normal state so people know it is there as oppossed to totally not visibale)
    Some examples and techniques showing mapping and then some others with video backgrounds also
    http://dvdstepbystep.com/newmap.php
    http://dvdstepbystep.com/rollover.php
    http://dvdstepbystep.com/useelements.php
    http://dvdstepbystep.com/buttons07.php
    http://dvdstepbystep.com/motion.php

  • Making a button transparent

    I'm designing a Japplet with JButton but i dont know how to make my buttons background transparent
    i read the color class tutorial but i actualy didnt understand it
    it gives lots of values like fload arrays or something
    can somebody tell me how can i make my buttons background transparent?
    Thanks

    It's always good to send an example as you finally did.
    That helps to find a solution:
    package applet;
    import javax.swing.*;
    import java.awt.*;
    public class backgammon extends JApplet{
        public Icon pulicon,bgIcon;
        private Image pul_s,background;
        public JButton b1;
        public void init(){
            //set layout:
            getContentPane().setLayout(null);
            this.setSize(744, 536);
            //set button:
            pul_s = getImage(getCodeBase(),"images/pul_sari.gif");
            pulicon = new ImageIcon(pul_s);
            b1 = new JButton(pulicon);
            b1.setBounds(50,50,42,42);
            b1.setContentAreaFilled(false);
            b1.setBorderPainted(false);
            getContentPane().add(b1);
            //set background:
            background = getImage(getCodeBase(),"images/background.jpg");
            bgIcon = new ImageIcon(background);
            JLabel bg = new JLabel(bgIcon);
            bg.setBounds(0,0,getWidth(),getHeight());
            getContentPane().add(bg);
    }

  • Making a button appear on a track

    I've searched here and in the manual but I'm not sure I'm searching for the right thing. How can I make a button appear within a stream so the user can link back to a menu?
    puzzled.....
    Thanks

    It's done in DVDSP by using 'buttons over video'. Basically, you use the subtitle stream to add the text that you want for the button (or graphic, if you import one as a subtitle).
    Once you have set the markers for the start and end point of where the button will appear, click in between them in a spare subtitle stream, type the word you want and then click on the editor window to see it appear. From here on in you can use the window as you would when making buttons on a menu - drag out a button rectangle, set the target and so on.
    Make sure that you force the sub to view...
    On playback, the button will appear as a part of the subtitle. You need only press the 'enter' key on your remote control to activate it, unless you have created more than one button... in which case you need to use the arrow keys to get to where you want to be before you activate the button.

  • Making a button open a scene when clicked

    Im guessing this is linked to actionscript,
    Ive made 2 buttons, One named Home, And another Exit,
    When home is clicked i want it to open a certain scene in this case called S Home,
    And when exit is clicked i want it to open the scene S Exit,
    How to do this?
    I will explain my problem more if needed,
    You could maybe call this linking a button,
    Only it opens a new scene rather than .html or an website

    I figured it out. I read something about a "stop();" at the start of the second scene. What I figured out is that you have to add "stop();" to the start of any scene. (Excluding Movies I think.) So, to make a completely new scene with 1 button, and 2 scenes, do this: (Follow above topics as well.)
    Scene 1:
    stop();
    myButton.addEventListener(MouseEvent.CLICK.doClickButton);
    function doClickButton(e:MouseEvent):void {
         trace:("clicked");gotoAndPlay(1,"YourSecondSceneName");
    Scene 2:
    stop();
    Thats it!
    Thanks.

  • 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

  • Cap 5: Making menu buttons active / inactive until content is completed

    Hello Captivate experts!
    I've run into a snag I know you smart people will be able to help me with.:)
    I have created a menu system, linking several large pieces together. Each menu button opens the linked project.
    Here's my problem....I need to make the Security Policy Final Checkpoint module unavailable until users have taken all of the content. (something added to the scope of the project AFTER I created this...dang it) Any suggestions would be GREATLY appreciated!
    Here is an image of my rough draft menu and button properties:

    Hi Lilybiri,
    Yes, all of the modules are seperate .cptx files that are "linked" via the buttons on the menu. The menu is also a seperate file.:)
    All of these modules have an "avatar" voice narrating the entire piece, so having one giant file with over 120+ slides was not working well, so broke them up into seperate modules and built a menu file to navigate between the modules.
    Completion of the linked module IS all they have to do. Returning to the menu is considered completing that module, yes.:)
    Thanks for your anticipated help, MUCH appreciated!
    -cgoebelx

  • Applescript. Making dependant buttons in dialog windows

    Hello, I am learning on making dialogs with Adobe InDesign CS3.
    Is it possible to "grey out" some parts of the dialog window, depending on a certain selection of a radio button? I mean: I have a radio button group and depending on which radio button is selected, I want to grey out some other options in the very same dialog window that are not relevant anymore (for example some check boxes).
    And if possible can anyone provide me with an example code?
    And if impossible can it probably be done with Applescript Studio? I don't know.
    Kind regards,
    Bertus Bolknak

    Hi Bertus,
    In JavaScript – in ScriptUI, not in InDesign’s dialogs – you can set enable property of control objects to false.
    As to Applescript Studio, I think, It’s possible too, but I’m not sure – attributes pane in the Info window has ‘Enabled’ checkbox. I did an interface with radio buttons group (BTW in Applescript Studio it’s called matrix) long ago, but it was quite a hassle. I was doing it by trial-and-error method as couldn’t find an intelligible reference. But the interface came out more attractive, and what was more important to me, Cyrillic characters were fully supported, as opposed to InDesign’s dialogs.
    Kasyan

  • Make a button do something Xcode/interface builder

    How can i make a button placed in interface builder do something

    Well, that isn't much better - I am going to guess that your application is for Mac OS X in Objective-C.  Since something like a button is pretty basic, you either need some help with Xcode, or a conversion from some other programming language you know, or both.
    There is a basic button tutorial here that uses the older Xcode (there shouldn't be much difference), although you should look at getting Xcode 4.2 (free from the AppStore), since that is what is current.
    I don't do much in Obj-C so I can't help with good books, but Apple has a few documents on its developer site that should get you started (although most of their documentation has moved on to Xcode 4.

Maybe you are looking for

  • There is an inconsistency between the authentication mode of target web application and the source web application after migrating to claims

    I've had my farm upgraded from SP2010 to SP2013 for over 6 months now and all is well, however, I was refreshing my staging environment from production and I noticed that one of the databases still shows these errors when I run test-spcontentdatabase

  • Setting minimum order level in BC?

    Is there an easy way to set a minimum total order level in BC and enforce it by not allowing Check Out at lower $ amounts?  I've tried setting all of my shipping options to a $150 minimum level and then setting the shipping validation in the buy butt

  • HELP! How to validate DATE?

    Hello... how to validate a DATE variable? I have used SimpleDateFormat (dd/MM/yyyy). For some input it worked fine, but for: 12/67/200394 (OK!) <- this is false, right? but not trapped! 1234546 (TRAPPED!) 12/324/1234 (OK!) <- this is false, right? bu

  • Changing value in SELECT-OPTIONS

    Hi All, I am writing a report in CRM and have a requirement of changing/modifying the value that has been entered in SELECT-OPTIONS. I tried many ways bit the changed value is not reflecting in the screen. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN.

  • How do I disable safesearch?

    When I am on one of my favorite adult sites, Yahoo safesearch pops in and will not let me view what I want. I love Firefox but I an going to have to stop using it. I have changed the safesearch preferences dozens of times. I have removed Yahoo as a s