Expand and Shrink

hey guys I am writing a program using gui's that is supposed to expand and shrink the JFrame that it is in.
Here is my code why doesn't this work?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class expandAndShrink extends JFrame implements ActionListener
  JButton expandButton ;
  JButton shrinkButton ;
  // constructor for TwoButtons
  public expandAndShrink()                          
    expandButton = new JButton("Expand");
    shrinkButton = new JButton("Shrink");
    expandButton.setActionCommand( "expand" );   // set the  command
    shrinkButton.setActionCommand( "shrink" ); // set the  command  
    getContentPane().setLayout( new FlowLayout() );
    getContentPane().add( expandButton );                     
    getContentPane().add( shrinkButton );
    expandButton.addActionListener( this );
    shrinkButton.addActionListener( this );    
  public void actionPerformed( ActionEvent evt)
    // check which command has been sent
    if ( evt.getActionCommand().equals( "expand" ) ){
      expandAndShrink.setSize(220,170 );   
    else {
     expandAndShrink.setSize(180,130);   
  public static void main ( String[] args )
    expandAndShrink demo  = new expandAndShrink() ;
    WindowQuitter wquit = new WindowQuitter(); 
    demo.addWindowListener( wquit ); 
    demo.setSize( 200, 150 );    
    demo.setVisible( true );     
class WindowQuitter extends WindowAdapter
  public void windowClosing( WindowEvent e )
    System.exit( 0 ); 
}

change this code
public void actionPerformed( ActionEvent evt)
    // check which command has been sent
    if ( evt.getActionCommand().equals( "expand" ) ){
      expandAndShrink.setSize(220,170 );   
    else {
     expandAndShrink.setSize(180,130);   
  }to this
public void actionPerformed( ActionEvent evt)
    // check which command has been sent
    if ( evt.getActionCommand().equals( "expand" ) ){
      this.setSize(220,170 );   
    else {
     this.setSize(180,130);   
  }~Tim

Similar Messages

  • Expand and Shrink window

    Hey I am writing a program that expands and shrinks the JFrame that it is in but all the program does is expand the window here is my code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class expandAndShrink extends JFrame implements ActionListener
      JButton expandButton ;
      JButton shrinkButton ;
      int x,y;
      int x2,y2;
      // constructor for TwoButtons
      public expandAndShrink()                          
        expandButton = new JButton("Expand");
        shrinkButton = new JButton("Shrink");
        expandButton.setActionCommand( "expand" );   // set the  command
        shrinkButton.setActionCommand( "shrink" ); // set the  command  
        getContentPane().setLayout( new FlowLayout() );
        getContentPane().add( expandButton );                     
        getContentPane().add( shrinkButton );
        expandButton.addActionListener( this );
        shrinkButton.addActionListener( this );    
      public void actionPerformed( ActionEvent evt)
        // check which command has been sent
        x=200+x;
        y=150+y;
        if ( evt.getActionCommand().equals( "expand" ) ){
        x2 = (int)(x * 0.1); // This cast is the same as a Floor function
         y2 = (int)(y * 0.1);
         x=x+x2;
        y=y+y2;
        this.setSize(x,y);
        else{
        x2 = (int)(x * 0.1); // This cast is the same as a Floor function
         y2 = (int)(y * 0.1);
         x=x-x2;
        y=y-y2;
        this.setSize(x,y);
      public static void main ( String[] args )
        expandAndShrink demo  = new expandAndShrink() ;
        WindowQuitter wquit = new WindowQuitter(); 
        demo.addWindowListener( wquit ); 
        demo.setSize( 200, 150 );    
        demo.setVisible( true );     
    class WindowQuitter extends WindowAdapter
      public void windowClosing( WindowEvent e )
        System.exit( 0 ); 
    }

    x=200+x;
    y=150+y;The first thing you do is increase the values of x and y. Then you expand and shrink from there. Doesn't look right to me.

  • Allowing a website to expand and shrink with a browser

    I am working on a website and wanted to know how to let a
    logo with butts right up to the left side of the screen but can
    also shrink and strectch with the browser so it will always start
    and end at the bottom and top of the browser.

    Ask your boss, "How high is up?"
    The notion that all the space on a page has to be filled is a
    hallmark of a
    rookie designer, whether on paper or screen. Your boss needs
    to hire someone
    with professional web design skills and then follow what he
    or she suggests.
    A boss who dictates things he or she has no knowledge of or
    experience in is
    going to end up with a disaster. The page you have created so
    far is doomed
    to failure. 20 layers?
    (Please show this message to your boss & suggest he or
    she log on here and
    learn the realities of web design.)
    Walt
    "margin_walker" <[email protected]> wrote in
    message
    news:f8or9s$4hn$[email protected]..
    > this is the site so far
    http://www.trinity3marketing.com/
    >
    > i would like the left icon to stretch to the bottom but
    also adapt to the
    > window size i guess is what i wanted to say. my boss is
    very adamant about
    > that,
    >

  • Expanding movieclip when mouse go out and shrinking it when mouse go in

    Dear all friends,
    I have movieclip called view_mc and button called btn_scale.
    I want when the user click and drag the button btn_scale, he can scale the movieclip view_mc.
    but when he goes out with the mouse, the movieclip is expanding.
    and when he goes in, the movieclip is shrinking.
    I have written the code, but it does the opposite: when he goes out, it shrinks. and when goes in, it expands:
    var clickedX:Number;
    var clickedY:Number;
    var newScale:Number;
    stage.addEventListener(MouseEvent.MOUSE_DOWN, on_stage_down);
    stage.addEventListener(MouseEvent.MOUSE_UP, on_stage_up);
    function on_stage_down(e:MouseEvent):void
    if(btn_scale.hitTestPoint(stage.mouseX, stage.mouseY))
      clickedX = stage.mouseX - view_mc.x;
      clickedY = stage.mouseY - view_mc.y;
      newScale = view_mc.scaleX;
      view_mc.addEventListener(Event.ENTER_FRAME, on_enter_scale);
    function on_enter_scale(e:Event):void
      if(view_mc.width < restricted.width && view_mc.height < restrictedArr.height)
        view_mc.scaleX = newScale * (clickedY / stage.mouseY);
        view_mc.scaleY = view_mc.scaleX;
    function on_stage_up(e:MouseEvent):void
      view_mc.removeEventListener(Event.ENTER_FRAME, on_enter_scale);
    Please help me to do the right scaling.

    iOS: Troubleshooting FaceTime and iMessage activation
    FaceTime, Game Center, Messages: Troubleshooting sign in issues

  • Intel iMac; upgraded adobe flash; bluetooth keyboard no longer pairs but magic mouse still OK. With Bluetooth switched on the screen splits into 4 areas and open windows seperate and shrink. Switch off Bluetooth and problem disappears and iMac works OK

    Intel iMac; upgraded adobe flash; bluetooth keyboard no longer pairs but magic mouse still OK. With Bluetooth switched on the screen splits into 4 areas and open windows seperate and shrink. Switch off Bluetooth and problem disappears and iMac works OK with plug-in keyboard and mouse

    Hi, Derek -
    ...the screen splits into 4 areas and open windows seperate and shrink.
    Sounds like Spaces is being activated somehow. With the wired keyboard and mouse in use, select the Exposé & Spaces control pane in System Preferences, click the choice in that pane for Spaces. See what the settings are. There are some activation settings in that pane - by default, F8 activates it.
    It could be that the bluetooth keyboard has some stuck keys and is activating Spaces; or that the activation command has somehow been reset to something that the bluetooth mouse, or bluetooth itself, is triggering.

  • Adding a link to expand and collapse all DHTML drop downs

    Hi, can anyone help me adapt the "Skinny on Skins" example "Add a Toolbar button to expand and collapse all DHTML drop downs" so that it will work with just a simple HTML link in RH8, instead of being attached to a custom skin button?
    The example looks like this:
    Step 1. Open the Skins Editor for the skin where you want to add the button.
    Step 2. After the preview loads into the window, ensure that the Toolbar tab has focus, then click the plus symbol. The Custom Toolbar Item dialog should display.
    Step 3. Type the Item Name (This is simply an internal reference for the button).
    Step 4. Type the Text (This is the text that will be seen by the end user. The field must contain something. So if you don't want any verbiage to display for your toolbar item, simply type a space.)
    Step 5. Choose your Image Options, then click the Action tab.
    Step 6. Click the JavaScript option button.
    Step 7. Enter the following code in the OnClick field:
    javascript:toggle()
    Step 8. In the JavaScript area, ensure the Inline JavaScript option button is selected, then click the edit (Pencil) icon located to the right.
    Step 9. Enter the following code in the Inline JavaScript dialog
    var show = "false";
    function toggle() {
    parent.frames[1].bsscright.focus();
    var arrayofDivs = parent.frames[1].bsscright.document.all.tags('DIV');
    if (show == "false") {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "block";}
    show = "true";}
    else {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "none"; }
    show = "false"; }
    Step 10. Click the OK button to close the Inline JavaScript dialog.
    Step 11. Click the OK button to close the Custom Toolbar Item dialog.
    Step 12. Click the OK button to close the Skin Editor.
    Step 13. Generate WebHelp via File > Generate > WebHelp and ensure that you have the new button selected with a check mark. This will probably require stepping through some screens to see the place where you can select it.
    Many thanks
    Jonathan

    Hi again
    I want to use it in the header of one of my Master Pages, so it will only be created/maintained once. Not all my pages have drop downs in so rather than have a toolbar button available for every page, I was trying to be a bit cuter by having two Master Pages - one for normal pages and one for pages with drop downs in.
    I'm no javascript expert so I'll see if one of my developers can help.
    Thanks anyway
    Jonathan

  • The bottom rubber case of my macbook 13" late 2009 has expanded and has detached from the main body..As i'm not presently under warrantty i wanted to know will the repair be free of charge for me. I had once got it replaced for free but in warranty.

    The bottom rubber case of my macbook 13" late 2009 has expanded and has detached from the main body..As i'm not presently under warranty i wanted to know will the repair be free of charge for me. I had once got it replaced for free but in warranty. As i read some where in the support that apple had agreed with the defect and had decided to replace the bottom covers without any charge. And even if i'm charged for it what will be the amount  will hav to pay for it..
    Thankx

    Hi,
    Here's the Bottom Case Replacement Link
    http://www.apple.com/support/macbook-bottomcase/
    It doesn't answer your specific questions about cost... but it does advise to contact an Apple Store or an AASP...
    Anyway have a look at it... if you haven't already..
    Cheers and Good Luck...

  • How to perform expand and collapse operation on click of link or button

    Hi
    Is there anyway by which i can perform expand and collapse operation over a table on click of a command link or button without using show details component.
    Is there any other alternative to show detail.
    I do not want to use show detail because of the following reason.
    I have got a page where in i pass some parameters to the URL based on which details get displayed on the page.
    Now when i pass a parameter, change the parameter, once again send the previously used parameter(i,e the parameter that i passed initially), values in the table under show detail do not show any change in values.
    Once i pass values which i have already passed, values in the table under show detail component do not refreshed.
    If anyone has encountered with similar situation, then please post me reply's as to how you could over come the problem??

    Hi
    Perhaps you could use an on-demand application process instead - you can specify these in the URL.
    The URL syntax (for your link) would be like...
    f?p=application_id:page_id:session:APPLICATION_PROCESS=process_idIs this what you mean?
    Cheers
    Ben

  • Expand and Collapse(+/-) option in a Matrix SQL Reporting Services 2008

    Hello All,
    I am having Expand and Collapse(+/-) option in a Matrix SQL Reporting Services 2008. It's not working when it is havnig a Row Group and Column Group.
    Does reporting services has this flexibulity?? It's working fine if it's only have a Row Group an it's not working if it is having Row and a Column Group. Can any one suggest how to work aroung with this.
    any help much appriciated.
    Thanks & Regards,
    Jeevan Dasari.
    Dasari

    Drill-down feature is a basic requirement, it is concluded in Reporting service from SSRS2000 to SSRS2008 R2, To
    your scenario I think the root cause is relevant to your incorrect steps. Please follow the steps below and then give the feedback:
    1.     Right-click the child groups in the
    Row Groups panel which is at the left-bottom of the BIDS, and then select
    Group Properties…
    2.   
    Switch to Visibility tab, and then select
    Hide Radio-button, click the checkbox of Display can be toggled by this report item.
    3.   
    Then select the parent group datafield in the drop-down list.
    4.   
    Click OK.
    Thanks,
    Challen Fu
    Challen Fu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • My iPad mini with OS 7.1.2 suddenly will engage in uncontrolled actions such as opening and closing pages, switching between apps, expanding and minimizing pages etc... uncontrollably and I have to shut the mini down to stop the uncontrolled actions

    My iPad Mini #1 with OS 7.1.2 began uncontrolled actions recently.  While reading a book in 3M Cloud App the pages would expand and then minimize on their own and then the uncontrolled action would open other apps and do the same by uncontrollably expanding and minimizing different pages in that app and then the actions would move on to another App and open it and expand and minimize pages and open different pages etc . . .  Initially I thought the problem was connected to the 3M Cloud Library App so I deleted it on my Mini iPad and also in iTunes on my iMac and downloaded a fresh app to install on my Mini.  However, that did not affect the problem.    The uncontrolled actions start in any app and begin every time I open my Mini to the point it is becoming useless.  Please help as I don't have a clue as to the cause of the problem or how to go about fixing it. 

    If this is still happening have you contacted APPLE support with the problem (same question to other posters).
    If it is always after a certain length of time with active use - it may be overheating causing wear and tear on internal components.
    Or - a bug in the software is causing sudden replay of what you just did.
    Had similar issue with work owned IBM think Pad due to age and use in office area that was warm (not my choice) - it behaved as though the track mouse or keyboard was stuck - repeating same single character - open/close folders- would have to do quick shut down by pulling the pad out of dock and pulling the battery out -- solution - was to get new lap top after PC techs cleaned it and it still happened.

  • Grow and Shrink the gallery's "mainImage"

    Grow and Shrink the gallery's "mainImage"
    I may pursue another option with the
    Class on trigger
    In this sample, a CSS class is set on the trigger to alert the user that something happens on the element. This is set as an option in the constructor.
    <script type="text/javascript">
    var highlight_tooltip = new Spry.Widget.Tooltip('highlighttrigger', '#classonme', {hideDelay:500, hoverClass:"enlarge"})
    </script>
    We have the main image in the photo gallery at full size.
    This is the image placeholder called "main image".
    Currently it is looks like this:
    <img id="mainImage" alt="main image" src=""/>
    I assume we add a mark-up similar to the icon grow effects code.
    So I will take a stab it now;
    <div id="Photograph" spry:region="dsPhotograph" onclick="HandlePhotograhClick('{ds_RowID}');" onmouseover="GrowPhotograph(this.getElementsByTagName('img')[0], '{@thumbwidth}', '{@Photographheight}');" onmouseout="ShrinkPhotograph(this.getElementsByTagName('img')[0]);"> <img src="galleries/{dsGalleries::@base}{dsGallery::Photograph/@base}{@Photographpath}" alt="Photograph for {@Photographpath}" width="Not Sure" height="Not Sure" id="tn{ds_RowID}" style="left: 0px; right: 0px;" onmouseover="this.style.cursor='pointer'" /> </div>
          <p class="ClearAll"></p>
    //need to look at ClearAll
        </div>
    //Now Add stuff the gallery.js
    // Show the image of the current selected row inside the dsPhotos data set.
    function ShowCurrentImage()
         var curRow = dsPhotos.getCurrentRow();
         SetMainImage("galleries/" + dsGalleries.getCurrentRow()["@base"] + "images/" + curRow["@path"], curRow["@width"], curRow["@height"], "tn" + curRow["ds_RowID"]);
    //I Need a variable like;
    ["@bigPhoto"]
    //Now I need add a function
    function HandlePhotographClick(id)
         //StopSlideShow();
         //dsPhotos.setCurrentRow(id);
         //ShowCurrentImage();
            //call Photograph grow ???
    // Trigger the animation of the Photograh growing to it's next largest size.
    function GrowPhotograph(img, width, height)
         Spry.Utils.addClassName(img, "inFocus");
         img.style.zIndex = 150;
         var id = img.getAttribute("id");
            //ADD This to the function GrowThumbnail in Gallery.js
    //after//
         //var twidth = Math.floor(width * .75);
         //var theight = Math.floor(height * .75);
         //var tx = (gThumbWidth - twidth) / 2;
         //var ty = (gThumbHeight - theight) / 2;
         var pwidth = Math.floor(width * 1.75);
         var pheight = Math.floor(height * 1.75);
         var px = (pThumbWidth - pwidth) / 2;//need to check this may not need
         var py = (pThumbHeight - pheight) / 2;//need to check this
         SizeAndPosition(id, tx, ty, twidth, theight, function(b){gBehaviorsArray[id] = null;});
    // Trigger the animation of the Photograph shrinking.
    function ShrinkPhotograph(img)
         Spry.Utils.addClassName(img, "inFocus");
         img.style.zIndex = 1;
         var id = img.getAttribute("id");
    //Need to look at this stuff below, any input from anybody would be good....
         SizeAndPosition(id, 0, 0, gThumbWidth, gThumbHeight, function(b){gBehaviorsArray[id] = null; Spry.Utils.removeClassName(img, "inFocus");});
    // Show the image of the current selected row inside the dsPhotos data set.
    function ShowCurrentImage()
         var curRow = dsPhotos.getCurrentRow();
         SetMainImage("galleries/" + dsGalleries.getCurrentRow()["@base"] + "images/" + curRow["@path"], curRow["@width"], curRow["@height"], "tn" + curRow["ds_RowID"]);
    Message was edited by: W_Bell

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class GrowRight
    public static void main (String args[]) throws InterruptedException
    JLabel label = new JLabel ("this is a test...");
    final JFrame frame = new JFrame ("GrowRight");
    frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout (new FlowLayout());
    frame.getContentPane().add (label);
    frame.setSize (label.getPreferredSize());
    frame.pack();
    final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation (d.width - frame.getSize().width, 0);
    frame.setVisible (true);
    frame.addComponentListener(new ComponentAdapter(){//<---------------------
      public void componentResized(ComponentEvent ce){
        frame.setLocation (d.width - frame.getSize().width, 0);
    Thread.sleep (5000);
    label.setText ("for the next sixty seconds, this station...");
    frame.setSize (label.getPreferredSize());
    frame.pack();
    }

  • Trying to override the default af:tree expanded and collapsed icons

    Hi,
    I initially hijacked a thread from 2010 that was vaguely similar to what I need to ask, but a kind forum moderator split my post out to stand on its own merits.
    I am trying to override the default af:tree expanded and collapsed icons I am using the following styles for my af:tree but they are not reflecting any thing on my tree with the styleclass orgType.
    af|tree.orgType::expanded-icon {
    content: url("../images/ac-expand.png");
    cursor: default;
    af|tree.orgType::collapsed-icon {
    content: url("../images/ac-collapsed.png");
    cursor: default;
    af|tree::expanded-icon {
    content: url("../images/folder_open.png");
    cursor: default;
    af|tree::collapsed-icon {
    content: url("../images/folder_close.png");
    cursor: default;
    After working for long hours I realized that there is some problem with af:tree and treeTable. They are not taking the styles where as for the other components, every thing works fine. Is there any way to achieve the task. Could you suggest any alternative way to do this. Thanks in advance. Your suggestions for this task can really help me and my team a lot.
    Regards,
    Krishna Sumanth.

    Hi,
    do the icons show without the style class reference used in the skin file? If so, then the style class for this component might be rendered differently for the tree, e.g.
    .orgType af|tree ...
    Frank

  • Arabic characters is expands and repeated

    Hi,
    Please help in the following problem which is when we print standard
    reports including Arabic characters through SAP system the Arabic
    characters is expands and repeated, we already used device type u201C ARSWINu201D
    Moreover, we already applied sap note u201C822634u201D but nothing is changed
    Also, we changed the language of the local pc to be Arabic but nothing
    is changed
    Furthermore, we logged into system with Arabic language and the problem
    still occurred
    Regards,
    Ahmed

    Hi Vincent,
    As I mentioned in problem details I tried to print standard reports, which is mean the problem appears at the level of the whole system, which is mean itu2019s occurred in any sap screen including Arabic characters such as sap menu in Arabic login, regarding the sap notes u201C809034u201D my release is 7.00.
    Regards,
    Ahmed

  • WRE54G expander and D-LINK 624 router

    Note: DI-624 has 4 lines ethernet wired connectors and 1 wireless antena.
    With WRE54G powered and ethernet connected to the router line 2, the CD used to setup the expander did not worked at first time and resulted in a message in the computer: The WRE54G can not associated this AP in repeater mode.  The next step was to change the configuration of DI-624 by accessing the IP address of the router (Web page of D-link). I put security desable and applied the new configuration to the router but loss the wired (line 1) connection to the internet by DI-624. I reboot the computer and internet came back. I started again with CD setup and the message desappeared but the red light still ON even with the message congratulations in my screen for Linksys setup. When I disconnected the ethernet cable to the expander and after few seconds, for my surprise the both leds went to blue light. When I returned to secure mode in the router, the expander return to red light. Then I decided to run setup with WPA enable until final with congratulations in my screen of Linksys setup wizard but with red light on the expander. After removing the ethernet cable, then after few seconds the Expander turn both leds to blue color. I sent this mail by a computer in the lower floor using this WRE54G expander.

    Well is your D-Link router supports WDS (wireless distribution system), if yes… WRE54G may work with this router…

  • Can please tell me how to implement expand and collapse table row data?

    i am trying implement expand and collapse table row data but i do not get any ideas..can please any one help me its an urgent requirement

    Yes, we can.   
    I think the best place for you to start for this is the NI Developer Zone.  I recommend beginning with these tutorials I found by searching on "data log rio".  There were more than just these few that might be relevant to your project but I'll leave that for you to decide.
    NI Compact RIO Setup and Services ->  http://zone.ni.com/devzone/cda/tut/p/id/11394
    Getting Started with CompactRIO - Logging Data to Disk  ->  http://zone.ni.com/devzone/cda/tut/p/id/11198
    Getting Started with CompactRIO - Performing Basic Control ->  http://zone.ni.com/devzone/cda/tut/p/id/11197
    These will probably give you links to more topics/tutorials/examples that can help you design and implement your target system.
    Jason
    Wire Warrior
    Behold the power of LabVIEW as my army of Roomba minions streaks across the floor!

Maybe you are looking for

  • Basic questions on data modeling

    Hi experts, I have some basic questions regarding data modeling within MDM. I understand the available table types and the concept of lookup fields. I know that the MDM data modeling concept is different to the relational concept. But having a strong

  • Backup from 9i and restore this backup to 10g using RMAN

    Hi all; I have a database 9i on SuSE9. And I want to restore another server this database's backupsets to 10g on SuSE10 using RMAN. Then I have run following scripts. On 9i Database: (SID=discoden)_ RMAN > backup database plus archivelog; and I have

  • Ever since update, my torch will not send bbm's to any Z10 users

    I updated the latest version on my bb and now it takes forever to send a bbm.  Also, I can receive the messages from Z10 users, but cannot send anything to them.  No bbm messages will go through. 

  • Adobe slide fx sample toggle not working

    Hi, http://labs.adobe.com/technologies/spry/samples/effects/multiple_slides_sample.html is the url for a sample of using the slide FX on multiple elements. The toggle doesn't seem to work. I need this for a project of mine, and I desperately need a s

  • Can i get the iphone from USA and get it unlocked in India

    can i get the iphone from USA and get it unlocked in INdia