How to make a button remain still while on top of a rotating image?

I've tried making an interactive menu that has a rotating image in the background and some buttons on top of that background. The background itself is in a JPanel and the button is added directly on that JPanel since the Panel occupies the entire frame. Now, the problem is that the button spins along with the rotated graphics X_X. So...any ideas?
Here's some of the code:
class EyE extends JPanel{
Image im;
public int angx=0;
MediaTracker tracker=new MediaTracker(this);
EyE(){
Toolkit ec=Toolkit.getDefaultToolkit();
im=ec.getImage("Graphics\\hcr1.png");
setPreferredSize(new Dimension (400,400));
setBackground(Color.BLACK);
JButton frog=new JButton("Jerry");
this.add(frog);
setOpaque(false);
setVisible(true);
public void paintComponent(Graphics ecr){
Graphics2D g2d=(Graphics2D)ecr;
tracker.addImage(im,1);
try{tracker.waitForID(1);}
catch(InterruptedException ie){}
//code for roatating image (really didn't want to use AffineTransform)
double cs=Math.cos(Math.toRadians(angx)),ss=Math.sin(Math.toRadians(angx));
g2d.rotate(Math.toRadians(angx));
double x2=(200*cs-200*ss),y2=(200*ss+200*cs);
double m,n,d,tetcs1,tetss1,tetcs2,tetss2,ang1,ang2;
d=(Math.sqrt(Math.pow((y2-200),2)+Math.pow((x2-200),2)));
tetcs1=d/(400*Math.sqrt(2));
tetss1=Math.sqrt(1-Math.pow(tetcs1,2));
tetcs2=(160000-Math.pow(d,2))/160000;
tetss2=Math.sqrt(1-Math.pow(tetcs2,2));
ang2=180-2*Math.toDegrees(Math.acos(tetcs1));
ang1=ang2+Math.toDegrees(Math.acos(tetcs1))-45;
n=d*(Math.sin(Math.toRadians(ang1)));
double g=Math.sin(Math.toRadians(ang1));
m=Math.sqrt(Math.pow(d,2)-Math.pow(n,2));
if(angx<=90)g2d.translate(m,-n);
else if(angx<=180)g2d.translate(-m,-n);
else if(angx<=270)g2d.translate(-n,-m);
else if(angx<=360)g2d.translate(-n,m);
//rotating code ends
g2d.drawImage(im, 0,0,400,400, this);
}

class EyE extends JPanel {
    Image im;
    public int angx=0;
    MediaTracker tracker=new MediaTracker(this);
    EyE(){
        Toolkit ec=Toolkit.getDefaultToolkit();
        im=ec.getImage("Graphics\\hcr1.png");
        setPreferredSize(new Dimension (400,400));
        setBackground(Color.BLACK);
        setOpaque(false);
        setVisible(true);
    public void paintComponent(Graphics ecr){
        Graphics2D g2d=(Graphics2D)ecr.create();
        tracker.addImage(im,1);
        try{tracker.waitForID(1);}
        catch(InterruptedException ie){}
//      code for roatating image (really didn't want to use AffineTransform)
        double cs=Math.cos(Math.toRadians(angx)),ss=Math.sin(Math.toRadians(angx));
        g2d.rotate(Math.toRadians(angx));
        double y2=(200*cs-200*ss),x2=(200*ss+200*cs);
        double m,n,d,tetcs1,tetss1,tetcs2,tetss2,ang1,ang2;
        d=(Math.sqrt(Math.pow((y2-200),2)+Math.pow((x2-200),2)));
        tetcs1=d/(400*Math.sqrt(2));
        tetss1=Math.sqrt(1-Math.pow(tetcs1,2));
        tetcs2=(160000-Math.pow(d,2))/160000;
        tetss2=Math.sqrt(1-Math.pow(tetcs2,2));
        ang2=180-2*Math.toDegrees(Math.acos(tetcs1));
        ang1=ang2+Math.toDegrees(Math.acos(tetcs1))-45;
        n=d*(Math.sin(Math.toRadians(ang1)));
        double g=Math.sin(Math.toRadians(ang1));
        m=Math.sqrt(Math.pow(d,2)-Math.pow(n,2));
        if(angx<=90)g2d.translate(m,-n);
        else if(angx<=180)g2d.translate(-m,-n);
        else if(angx<=270)g2d.translate(-n,-m);
        else if(angx<=360)g2d.translate(-n,m);
//      rotating code ends
        g2d.drawImage(im, 0,0,400,400, this);
        g2d.dispose();
        super.paintComponent(ecr);
}

Similar Messages

  • How to make a button to stop and run a for loop?

    How to make a button to stop and run a for loop?  and if it is stopped it shall start from where i t stopped.

    Your VI has some very fundamental flaws.
    The start/stop button is outside the FOR loop, thus it will NOT get read during execution of the FOR loop, but only before the FOR loop starts. Think dataflow!
    Thus the terminal of the start/stop button belongs inside the FOR loop.
    Your FOR loop iterates 20x, which probably takes about a nanosecond. You will NOT be fast enough to reliably press the start/stop button during a specific iteration of the FOR loop.
    Your code does not "stop and run" a FOR loop (sic). The loop always spins, but executes an empty case when "Stopped". I guess that's what you actually want?
    Once you solve (2), the x indicator will contain a random value whenever you "stop".
    As soon as the 20 iterations complete, the outer while loop spin an things start over, another nanosecond later.
    Place e.g. a 500ms wait inside the FOR loop to solve this.
    Don't place terminals of indicators on top of formula nodes.
    Your formula does not produce any output, so really has no purpose.
    Use a real "stop" button to terminate the while loop (mechanical action: latch when released). Right now you are using a plain switch, which does not reset to false before the next run. This means that you need to manually reset it before running the program again.
    It is oftern useful to operate the VI in execution highlighting mode. You will immediately see that your button does not get read during execution of the FOR loop. Try it!
    LabVIEW Champion . Do more with less code and in less time .

  • How to make the buttons INVISIBLE in the Application toolbar

    Hi All,
    I have a requirement to create a button in the Application toolbar of the Module Pool Screen. The field should be made Invisible by default. and it should be displayed based on one condition.
    Could you please let me know how to make that particular button INVISIBLE. I think we can make it invisible by using EXCLUDING statement. But, How to make the button VISIBLE again when the check is satisfied.
    I found from the portal that the FM 'VIEW_SET_PF_STATUS' can be used to make a button INVISIBLE. Could anyone help me out how to pass the parameters to this Function module?
    or is there any Function Module available to make the button VISIBLE and INVISIBLE? Please help me on this issues.
    Is there any possibility to make the button VISIBLE or INVISIBLE as we do for the screen fields using LOOP AT SCREEN..?
    Thank you in advance.
    Regards.
    Paddu.

    Hi,
    Try to use below in the PBO module status_0100 OUTPUT.
    DATA t_fcode TYPE TABLE OF sy-ucomm.
    refresh t_fcode[].
    APPEND 'Function code name of the button' TO t_fcode. 
    Check the condition here for which you want to make field visible.
        DELETE FCODE of the button from T_FCODE table
      ENDIF.
      SET PF-STATUS 'STATUS_0100' EXCLUDING t_fcode.

  • How to make a Button to work Actively even if there is a mandatory field..?

    Hi All..
    How to make a Button to work Actively even if there is a mandatory field to be fulfilled..???
    I am badly in need of this logic, as i have to incorporate in my code..
    Points will be rewarded without fail..

    Hi Pavan,
    I also faced the same requirement. U can do one thing like remove the obligatory keyword of that parameter/select-option. U can handle the same using the program in at selection-screen event. See this sample of code,
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_land1 for T005-LAND1 <b>[Needs to be mandatory]</b>                 no intervals no-extension.
    SELECT-OPTIONS:  s_panid FOR zoindex_val-zopanid.
    SELECT-OPTIONS:  s_effdat FOR zoexchrate-zedate.
    SELECTION-SCREEN END OF BLOCK b2.
    *-- AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
    *-- Obligatory Country Code
      IF s_land1[] IS INITIAL.
        MESSAGE e050 WITH text-050.
                     "Please select the Country Code
      ENDIF.
    So whenever u do F8/Enter other than that push button, it will prompt u to enter the country code first then only u can proceed.
    Hope this would help u in some way. Please do reward the helpful answers.

  • How to make "Utility" button in Printer Setup Utility available

    There, i add a printer in the Printer Setup Utility and select it. i want to open printer utility, but the "Utility"
    button in Printer Setup Utility is dimmed. In addition,
    "Printer\Configure printer" in the Printer Setup Utility menu is also dimmed.
    How to make "Utility" button in Printer Setup Utility available?
    Thanks in advance.

    Hi Jiong,
    That button is to acess the printer utility for that particular printer, not all printers come with a utility. If you have the disk that came with your printer, you can see if it has a Macintosh driver, if it does then it mimght have the utility with it. It's pretty hard to run the utility on its own, its burried somewhere in the system so that's why you have that menu item. You can alternatively go on the internet and download the latest driver, which might have a utility. All the utility will do will give you options to check nozzle patterns, alighnement, ink tank levels, and cleaning options - just mimnor maintenence junk, non-essentials, etc. I think Tiger just comes with a whole heap of generic drivers for different printer lines, can't say for sure.
    I wouldn't worry about it, especially if you have a relatively old printer.
    Hope that helps
    DKR

  • How to make a button load a sprite from library??

    PLEASE HELP!!
    Hey everyone.. iv been looking for help for a few weeks but cant seem to find the awnsers
    I am trying to create a newspaper that consists of four pages. Each   page i have created and are sitting in the library as sprites. Each page   has buttons that need linking so that when pressed it loads the next   page or page that i want. This is the part i am confused with =/ how do i   make the buttons on each page load the next page (sprite) from the   library??
    Basically i want to no how to make a button load a sprite from the library when clicked. Does anyone no the script for this?
    Thanks for any help

    A question arises as to whether or not you are posting in the right forum.  Sprites are AS3 objects.
    If you want to add movieclips to the stage from the library using AS2, then you need to assign them each an Identifier via right clicking them in the library and selecting the Linkage option... from there you slect the option to Export for Actionscript and then assign the Identifier.
    You then use the attachMovie() method to make use of that Identifier to dynamically load the library object.

  • HOW TO MAKE ROUND BUTTON

    HI PLS TELL ME HOW TO MAKE ROUND BUTTON ON FORM.

    Rounded end buttons (e.g. Oracle Look and feel) are do-able in both 6i and 9i using PJCs in the 9i demos see the rollover button example, in 6i I seem to remember that there is a RoundedButton sample in the demos.
    Both sets of demos can be downloaded from http://otn.oracle.com/products/forms.
    If you want circular buttons then you'd have to use an Image for that.

  • 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

  • Help!!! How to make quicktime plugin do not display on top of the web page?

    Any one knows how to make quicktime plugin do not display on top of the web page??? I've tried to change the zIndex property using javascript, but it doesn't work.
    Because we have some widgets which are required to be moved to anywhere on the page, we use iframe to implement that, so it can display on top of quicktime plugin, but the plugin flickers sometimes when we do some operation on the widget which is on top of it.
    Anyone can helps me? Thanks in advance!!!
      Windows XP Pro  

    > Can you tell me how to set the script so that the
    lightbox image is
    > displayed
    > on mouseover instead of mouse click.
    Check the docs. Trent is usually very thorough in his
    instructions.
    Hint: I haven't studied it but it probably involves modifying
    one of DW's
    built-in Behaviors.
    Walt
    "ducati1" <[email protected]> wrote in
    message
    news:gkb906$qrd$[email protected]..
    > Wow that DW extension is just what I needed.
    > Thanks..
    > Can you tell me how to set the script so that the
    lightbox image is
    > displayed
    > on mouseover instead of mouse click.
    > I currently have the thumbnails set to insert the ALT
    text into a text box
    > on
    > mouse click.
    >

  • How to make a button to stop and run a while loop?

    Hi all,
    I am a beginner in the Labview. I did a program that contains a while loop, its stop condition is connected to button. I selected “switch when pressed” to be the operation of this button. Our teacher asked us to make this button stops the loop if it is pressed and its name is converted to run instead of stop. And if it is pressed then again it starts the loop from the point it stopped in.
    Can anybody help me, please?

    First, please use a smaller font when composing your messages.
    You will need two while loops.  An inner loop which has its stop terminal attached to the stop button.  Put that in the False case of a case structure.  Wire a local variable of that stop button to the case selector of the case structure.  Put the case selector inside another while loop which is the one that keeps the program running no matter what the state of the original Stop button.  You will need a master stop button to stop the outer loop when you are ready to end the whole program.  Don't forget to put small millisecond waits in each of the loops so that the loops don't eat up all the CPU resources.
    For that stop button, you could rename the True title to Run, so that when it is pressed to stop the inner loop, the button will show the word Run.  Pressing it again pops it back out, allows the false case to execute and the innermost while loop to run.
    You could also change the words on the buttons by using property nodes.

  • How to make a button stay down when I click on it in  CSS nav bar.

    So I have created a horizontal navigation bar, I use the CSS
    Sprites/Pixy method to get the hover working with the same image as
    the link/in active stage of the buttons.
    Now how do I make the button stay down when someone click on
    them?
    These are the codes for the nav bar.
    #nav{
    width: 780px;
    list-style: none;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    padding: 0;
    height: 40px;
    #nav li{
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: bold;
    float: left;
    padding: 0;
    #nav a{
    width: 125px;
    display: block;
    color: #000000;
    text-decoration: none;
    text-align: center;
    background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    background-repeat: no-repeat;
    background-position: center 2px;
    padding-top: 14px;
    padding-bottom: 10px;
    background-color: #000000;
    #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    #nav a:hover{
    background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    background-repeat: no-repeat;
    background-position: center -36px;
    color: #FFFFFF;
    width: 125px;
    padding-top: 14px;
    padding-bottom: 10px;
    background-color: #000000;
    Everything works so far, the hover works when you roll the
    mouse but when you click the button goes right back.
    How can I make it stay down and then go back to normal when
    you click on another link/button?
    Thanks very much.
    Patrick

    Read my suggestion again. You are missing a critical point. I
    show you
    exactly where to put the stylesheet. And it doesn't matter
    how many
    stylesheets you have on a page.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Webethics" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Change this -
    >
    > #nav a{
    > width: 125px;
    > display: block;
    > color: #000000;
    > text-decoration: none;
    > text-align: center;
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center 2px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    >
    >
    > #nav a:hover{
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center -36px;
    > color: #FFFFFF;
    > width: 125px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > to this -
    >
    > #nav a{
    > width: 125px;
    > display: block;
    > color: #000000;
    > text-decoration: none;
    > text-align: center;
    > background-image: url(ZITTO_IMAGES/button_set1a.jpg);
    > background-repeat: no-repeat;
    > background-position: center 2px;
    > padding-top: 14px;
    > padding-bottom: 10px;
    > background-color: #000000;
    > }
    >
    > #link2,#link3,#link4,#link5,#link5,#link6 { margin-left:
    6px;}
    >
    >
    > #nav a:hover{
    > background-position: center -36px;
    > color: #FFFFFF;
    > }
    >
    > Then on each individual page, change this -
    >
    > </head>
    >
    > to this -
    >
    > <style type="text/css">
    > #nav a#link4 {
    > background-position:center - 36px;
    > }
    > </style>
    > </head>
    >
    > (for link4, for example)
    >
    >
    > --
    > Murray --- ICQ 71997575
    > Adobe Community Expert
    > (If you *MUST* email me, don't LAUGH when you do so!)
    > ==================
    >
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    >
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    > ==================
    >
    >
    > "Webethics" <[email protected]> wrote
    in message
    > news:[email protected]...
    > >
    quote:
    Originally posted by:
    Newsgroup User
    > > When they click on a button, do they go to another
    page? And is each
    > > button
    > > uniquely identified?
    > >
    > > If so, then put a little stylesheet on each such
    page that sets the
    > > particular button to the down sprite settings,
    e.g.,
    > >
    > > a#link6 { downspritevalues }
    > >
    > > --
    > > Murray --- ICQ 71997575
    > > Adobe Community Expert
    > >
    > >
    > > This is the link to the page.
    > >
    http://www.patrickjudson.com/zitto_web1d.html
    > > What state do I use to get this effect? The active
    or the visited?
    > >
    > > I want the buttons to remain down when click or
    even better, how do I
    > > get
    > > the
    > > welcome button to appear down when a person visits
    the page to show them
    > > they
    > > are at the home page.
    > >
    > > Thanks so much. Patrick
    > >
    > >
    > >
    >
    >
    >
    > Hey! Murray, thanks very much for the efforts. However
    I'm still confused
    > as
    > to where to insert the individual styles on each page.
    >
    > The pages already have a style sheet, in fact they all
    share the same
    > style
    > sheet. The following codes below is what you instructed
    but I'm confused
    > as to
    > where to insert them since the page already has a head
    opening and closing
    > as
    > well as a style opening and closing tags. Can you please
    add the codes you
    > instructed so I can see where they go and how to
    implement them?
    >
    > Thanks - Patrick
    >
    >
    > Then on each individual page, change this -
    >
    > </head>
    >
    > to this -
    >
    > <style type="text/css">
    > #nav a#link4 {
    > background-position:center - 36px;
    > }
    > </style>
    > </head>
    >
    > (for link4, for example)
    >
    >
    >
    >

  • How to make a button to search something in sql

    I am trying to make a button that can search for something like for example if like say i type yes, it will show me things that is under yes.But I am not sure how to make the code work as I cannot change the php code as it is under the requirement that I make the button work and not using the php code to make it work which means that I cannot type the yes to show the information and the button must somehow have the "yes" in the function to show the information.Please help me and Thanks for your help.
    This is my flash code.
    package  {
      import flash.display.MovieClip;
      import flash.net.NetConnection;
      import flash.net.Responder;
      import flash.events.MouseEvent;
      public class main extends MovieClip {
      var gateway:NetConnection;
      var responder:Responder;
      public function main() {
      gateway = new NetConnection();
      gateway.connect("http://localhost:8088/amfphp/gateway.php");
      responder = new Responder(OnPass,OnError);
      showAlBtn.addEventListener(MouseEvent.CLICK,doAvailable);
      function doAvailable(evt:MouseEvent):void
      gateway.call("Books.getBooksAvailable",responder);
      function OnPass(res:Object):void
       var i:int;
      albumDG.removeAll();
      for (i=0;i<res.length;i++)
      albumDG.addItem(res[i]);
      function OnError(res:Object):void
      trace("Error");
    .This is the code for the php code that works because I already tested it out because it allows me to type yes and it shows me the required information that I need and it is not tested on flash cs6 but on local host things that allows me to test it out.
    function getBooksAvailable($avail)
      $this->connect();
      $sql = "SELECT title as 'Book Title', author as 'Author', price as 'Price', available as 'Available'
      FROM tblbookinventory
      WHERE available ='" . $avail . "'";
      $result = mysql_query($sql, $this->_connection);
      $rows = array();
      while($row = mysql_fetch_array($result, MYSQL_ASSOC))
      array_push($rows, $row);
      return $rows;

    use the urlloader class to call your php file. 
    the php function you showed is expecting a variable ($avail)  that might accept a value of 'yes'.

  • How to make the  buttons same size on the toolbar

    Hi All,
    Can anyone please tell me how to make the size of buttons on the toolbar to be same .
    And i also want to add combo box at the right side of my menubar with prefered size.
    Please send me the solution if anyone knows . Thanks in advance.
    Regards,
    Shankar.

    how to make the size of buttons on the toolbar to be same Create a panel with a GridLayout. Add the buttons to the panel then add the panel to the menubar.
    add combo box at the right side of my menubar Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]How to Use Menu Bars for an example.

  • Canvas Remains Still While Output Monitor is Fine

    Recently the Mac Pro station I work on was upgraded from FCP 6.x to 7.03. Noting that everything worked fine prior to the upgrade and everything works fine after the upgrade except this new problem:
    When scrubbing the timeline audio and video playback fine on both the external monitor and the FCP canvas window. When I playback the timeline the output monitor works fine but the canvas window remains frozen on the first frame where the playhead was. As soon as you stop playback the canvas will update to the current and correct frame but it remains still or frozen during all playback except scrubbing.
    Thanks for any suggestions.

    Oops, sorry,wrong answer - let me try again:
    Go to the menu Final Cut Pro > Audio Video Settings and click on the A/V devices Tab. Make sure "Mirror on Desktop" is selected:
    MtD

  • How to make picture button in oracle forms?

    can any one tell me how to make a picture button in oracle form builder?
    please help?

    Hi,
    Only a icon can be pasted on the push button. We can not user jpg,,jpeg or gif for the picture only ico file can be used.
    go to properyt pallet,
    make iconic as yes
    give the path in icon filename --- C:\Program Files\Winamp\eMusic\eMusicClient
    where eMusicClient is -- icon file name without extension, dont use " " in path
    bye

Maybe you are looking for