Grow and shrink JLabel to the left?

I'm interested in putting a JLabel on the right hand side of the screen and having it resize (grow and shrink) on an on-going basis to the left. Any pointers on this? Here's some code that places a label on the upper right of the screen and then resizes the label. It grows off the right hand side of the screen...
import javax.swing.*;
import java.awt.*;
public class GrowRight
public static void main (String args[]) throws InterruptedException
JLabel label = new JLabel ("this is a test...");
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();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation (d.width - frame.getSize().width, 0);
frame.setVisible (true);
Thread.sleep (50000);
label.setText ("for the next sixty seconds, this station...");
frame.setSize (label.getPreferredSize());
frame.pack();
Any help would be appreciated! Thanks.

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();
}

Similar Messages

  • 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();
    }

  • Growing and shrinking text

    hi,
    does anyone know how to make text grow and shrink? i'm using oprea web browser, and when i place my mouse over some buttons text appears and then moving it off the button the text shrink, it does not appear and disappear, but actually grows out and shrinks in from a point. does anyone know how to do this?
    Thank you.

    hi,
    thank you for the response, i know about the listener, question was really regarding how to resize text so that it resizes smoothly, looks like it's growing and shrinking not just one second it's size 10 and then size 1, i want to make it flow from 10 to 1 for example, like opera browser, should i use a thread or is there a better way?
    Thank you.

  • I need to reprogram the delete and enter key to the left side of a external keyboard for the ipad mini. don't need the caps/lock or ctrl key and due to an injury my daughter can only use her left hand to type. She is using a text to speech app to verbaliz

    I need to reprogram the delete and enter key to the left side of a external keyboard for the ipad mini. I don't need the caps/lock or ctrl key. Due to a brain injury my daughter can only use her left hand to type. She also uses a text to speech app to verbalize all of her needs since her speech isn't intelligible any longer either. And her vision was significantly affected also, so the keyboard has to be mounted about 6 inches from her face. So to reach across the keyboard with her left hand to the right side delete and enter button is physically difficult and causes typing errors, which cause people to not understand what shes trying to say.
    The best keyboard so far is the Zagg folio mini. I just had to make stickers to enlarge the letters on the key buttons.
    Does anyone know how I can reprogram these two keys? Or where I can buy a wireless mini keyboard for Ipad made for lefthanders with these two functions on the left side. I have searched for days and days. It's sooooo important to me that she be able to contribute her voice again. Imagine if you got in a car accident and couldn't speak clearly any longer, but understood everything still. Thanks for any help and suggestions you all take the time to share with me. I really appreciate the kindness of strangers to help me help my daughter.
    Sami's mom

    Sami\'s mom wrote:
    I need to reprogram the delete and enter key to the left side of a external keyboard for the ipad mini.
    You cannot.

  • [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

  • No printing :I can't print anymore, printing the same file with another programs is ok, printing form LR: Preparing  and Printing indicatorbar in the left hand upper corner are running, but no output at all rom my printer. I have been printing before. I u

    No printing :I can't print anymore, printing the same file with another program is ok, printing form LR (in the same system and printer of course :-) ): Preparing  and Printing indicatorbar in the left hand upper corner are running and completing, but no output at all to my printer. I have been printing before. Next I upgraded to LR5.7.1 but the problem stays. Perhaps some adjustment is changed by me unintentionally, but I have no idea. Does anybody know what to check? Printing to file is also strange,the canvas only seems to accept A4, and crops any image relative to that size, so a 10x15 cm print on 10 x 15 cm paper is cropped to 10x15/2. Anybody any idea? (system win 8.1 64, printer HP B8550)

    I accidentally solved my mystery.  For some reason it was set to "print to file".  I changed it to "printer" and now I am able to print.

  • My albums and slideshows disappeared from the left column when I ejected a Canon camera after a download.  My version of iPhoto '08 (V7.1.5(378)) had just crashed when I first connected the Canon camera to download.  I restarted iPhoto.....

    My albums and slideshows disappeared from the left column when I ejected a Canon camera after a download.  My version of iPhoto '08 (V7.1.5(378)) had just crashed when I first connected the Canon camera to download.  I restarted iPhoto.....successfully downloaded 22 photos, and ejected Canon camera, upon which albums & slideshows highlighted blue and disappeared from the left column.  The photos still seem to be under the EVENTS and PHOTOS in the LIBRARY.  Any thoughts?

    Restore from your back up.

  • Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hey NicolasZen,
    Thanks for the question and welcome to the Apple Support Communities. I understand that you are experiencing issues with “No Service” or “Searching” on your iPhone. The following resource provides some great troubleshooting steps that you may wish to try:
    iPhone: Troubleshooting No Service
    http://support.apple.com/kb/TS4429
    Your iPhone may have one of these symptoms:
    - iPhone displays "No Service" or "Searching" in an area of good coverage
    - iPhone doesn't regain service when returning to an area of coverage
    Resolution
    If you encounter either of the above symptoms on your iPhone, follow these steps to attempt to resolve the issue. Test after each step.
    1. Toggle airplane mode: Tap Settings > Enable Airplane Mode, wait five seconds, then turn off airplane mode.
    2. Turn iPhone off and then on again.
    3. Remove the SIM card and verify that it's a valid, carrier-manufactured SIM. Also verify that it isn't damaged, worn, or modified. Then reinsert it.
    4. Check for a carrier-settings update. Connect to a Wi-Fi network. Then tap Settings > General > About. If an update is available, iOS will ask you if you want to install it. If Wi-Fi isn't available, connect your device to iTunes.
    5. Update your iPhone to the latest version of iOS.
    6. Reset network settings by tapping Settings > General > Reset > Reset Network Settings. This will reset all network settings, including Bluetooth pairing records, Wi-Fi passwords, VPN, and APN settings.
    7. Restore the iPhone.
    Thanks,
    Matt M.

  • When i open facebook and only text shows and all is to the left and when i open hotmail nothing shows on my screen and other webpages have problems also when click at a link all the text comes up also to the left in my screen whats wrong ???

    When i open facebook and only text shows and all is to the left and when i open hotmail nothing shows on my screen and other webpages have problems also when click at a link all the text comes up also to the left in my screen whats wrong ???

    Clear the cache and the cookies from sites that cause problems.
    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites causing problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    See also:
    * http://kb.mozillazine.org/Websites_look_wrong
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • ArrayList will grow and shrink implicitly

    Hi,
    I have an ArrayList which is going to hold 1000 elements, hence I have defined the List as :-
    List list = new ArrayList(1000);
    If the number of elements is less than 1000 , in such case whether the ArrayList will shrink implictly and similarly
    if the number of elements grows from 1000 to 1500 whether the ArrayList will increase the size implicitly to 1500?
    I know that ArrayList will increase the size of its internal array to 50 % when compared to Vector?
    If the above wont happen then it will be a problem as unnecessary memory space will be available List?
    Please clarify.
    Thanks.

    797836 wrote:
    Thanks.
    This clearly indicates that if we are entirely sure that you are going to work with 1000 elements then better to define the initial capacity that way ,It can be better. In many cases--probably most cases--it will make no noticeable difference.
    if not, use always use the default value (ie) 10. That can be better. In many cases, it will make no noticeable difference. Also note that resizing costs time and memory. For a brief period, there are two copies of the backing array--the initial one and the new, larger one. And of course copying the references takes CPU cycles. Most of the time this will not be noticeable, but if you're comparing specifying the initial size vs. going with the default, it's worth considering.
    Also note that there exists a method to shrink the array. I think it's called trimToSize() or something like that.
    In the end, if you think you have a rough idea how big the list will get, you may get some benefit from creating it with an appropriate initial capacity. Most of the time, however, it won't make a noticeable difference either way, so it's not usually worth spending much time thinking about it. When you test for scalability, if you find a bottleneck there, you can adjust the initial capacity as needed.

  • Have a new macbook pro and on the display there are 2 lines, one blue and one green on the left side.  Does anyone know what the problem is.  Happened after 2 weeks.

    I just purchased a new macbook pro.  Have had it about 2 weeks.  Last night there were 2 thin lines that are on the left side of the desktop, 1 green and 1 blue from top to bottom.  This happened after I added a printer.  Anyone know what this is.  Fearing that is a flaw in the screen.

    Sounds like a hardware problem.  You'll need to contact Apple ASAP.  Since it's so new, hopefully they will just replace it rather than making you go through the repair process, but that's up to them.

  • How do I see the front and back arrows on the left hand side of my macbook pro?

    How do I see the front and back arrows on the top left hand side of my macbook pro?

    Click "View' menu in the application menu bar select Show Toolbar
    or
    click "Customize Toolbar" and drag the arrows or "default set to the Toolbar".
    Best.

  • Hi anyone help me? I can't get the texts of my emails to appear. It just shows the titles and senders etc. on the left it shows a two line preview but no text on right. Help!

    Help my email messages do not appear in the right hand side. Just the headings but no text at all. On the left the preview shows but nothing on right.

    Restart your iPad. If that doesn't work, reset it.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • The screen on my ipod touch is white all over and black in the upper right hand corner only with color dots and lines run to the left hand side but stop in the middle. how do i fix it?

    right now it is the middle of april and i bought the ipod at the beging of Agust the year befor so it still has not been a year. currently it is thursday and the screen changed to the white and black corner on the monday earlier in the week (so 4 days ago). i had just broken up with my gril friend and we were fighting. in anger i through my ipod at the wall. i was aiming for my pillow on my bed so it would hit something soft but i missed and it hit the hard concrete wall in my room. when i looked at my ipod it had turn itself off and when turn on the screen was white with a little black in one corner. i have tryed to restart it by holding down the power and home button till it restarted but the screen only got brighter and then eventually went back the the brightness it was before and turn off. i can still turn the screen on but cant unlock. i know it is still working cause my alram still goes off in the morning. the ipod is a 4th generation ipod touch 16 GB memory and is black. can this be fixed at home on my own or do i have to take it in to apple. can apple even fix it or is my ipod past the point of repair. any advice would be nice. thanks in advance.

    - Restore to factory settings/new iOS device.                       
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
      Apple Retail Store - Genius Bar                                                              
    Apple will exchange your iPod for a refurbished one for $99 fr a 16 GB 4G. They do not fix yours.
      Apple - iPod Repair price

  • HashMap will grow and shrink dynamically

    Hi,
    By default Hashmap takes 16 as an initial capacity. If it is more than 16 it will grow dynamically based on the constant factor.
    If it is less than 16 elements set whether it will shrink dynamically as well? Please clarify.
    Thanks.

    797836 wrote:
    Hi,
    By default Hashmap takes 16 as an initial capacity. If it is more than 16 it will grow dynamically based on the constant factor.
    If it is less than 16 elements set whether it will shrink dynamically as well? Please clarify.
    Thanks.The size() call will give you a reduced number of entries. Entries are stored internally in an array, that will grow, but never shrink. I.e. if you add 25 entries to a new HashMap it will have a capacity of 32 and a size of 25. After removing 10 of those entries capacity will still be 32, but size will be 15.

Maybe you are looking for

  • CPU Upgrade on Satellite L30?

    Tried searching but didn't get an answer. Bought a laptop from ebuyer the other week, and so far so good, but good do with a bit more juice. Currently running a CoreDuo 1.73 processor, wondering if Core2 or something a bit better will suit. Heard som

  • Can I delete the Mobile Apps Folder from my Mac?

    I would like to separate my two iPad 2 units from my desktop Mac. Each time I open iTunes it tells me how many updates to my apps are available, usually over 100. I have tons of apps stored on this system. I would rather use my iPad 2's separately an

  • [SOLVED] enable Ctrl+Alt+L to lock?

    I just installed and configured gnome after moving from ubuntu on my netbook, and I always used Ctrl+Alt+L to lock my workstations. How can I enable this in Arch? I installed the xscreensaver package based on a tip I found elsewhere, but that doesn't

  • Message+ PC Backup Assistant pop-up

    I recently installed this on my wife's laptop and she started getting these message pop-ups saying "Get Backup Assistant, Sync contacts from your mobile device to your desktop with Back Up Assistant. Click Here to get this service." I tried installin

  • Family calendar not showing on new iPhone

    I have a computer, an iPhone 5s and a brand new iPhone 6+. I setup family sharing between all the devices and I can share apps between the phones without problem. If I take a picture on a phone, it will be shareable with the other devices BUT if I cr