Scrollpane location

Hi,
ive got the following problem. I use a JPanel to put a number of JTextFields in it. This number is not determined before. So sometimes the Panel gets to big to fit on a Screen. I decided to put it into a jscrollpane.
But now if got the problem if i navigate through the fields using the ENTER-key, the scrollpane does not follows the focussed JTextFields. if i use the Cursorkeys instead, the scrollpane scrolls simultaneously with the focussed fields. My idea was the following: I determine the height of such a TextField and multiple it with the number of the TextField which is currently focussed. So i can view on the focussed TextField by telling the scrollpane to scroll to the calculated position.
My Problem is, that i dont know how to let a JScrollPane scroll to a given position.
So i really would appreciate any hints for this problem.
Thanks in advance
Jens

The last reply in this thread may give you a place to start:
http://forum.java.sun.com/thread.jsp?forum=31&thread=174273

Similar Messages

  • Applying an onDrag actionscript to a loaded swf

    I want to make a loaded swf file dragable within the main
    stage. Can someone point me to a tutorial or show me how to do it?
    Thank you!

    This one took a few tries to get right. But I think I figured
    it out for yuh'. I assumed you were using a "ScrollPane" for your
    scrolling and that there was a button inside of that component. Let
    me know if this is wrong. It shouldn't be too different even if
    you're not using the "ScrollPane". Aslo, all the code below goes on
    the main timeline.
    notes:
    "container" is the empty clip that holds the content.
    "mc" is the MovieClip inside of the ScrollPane ( located in
    the loaded *.swf ).
    "mouseIsDown" is a boolean ( true/false). It checks to see if
    the user is holding down on the mouse or not.
    The rest is pretty easy to figure out.

  • How can we model different receipt days in a location depending on the start-destination relationship in an optimizer run in SNP?

    We have a business scenario where the receipt days for a location depends on the relationship between the Start-Destination Location. We need to include this constraint in an optimizer run with daily buckets.
    Example:
    Factory A (Start Location) ships to DC X (destination location) only on Mondays, with a lead time of 2 days. DC X should receive the stock from Factory A on Wednesday
    Factory B (Start Location) ships to DC X (destination location) only on Thursdays, with a lead time of 1 day. DC X should receive the stock from Factory B on Saturday
    Does anyone has been able to model this scenario?
    I tried using transportation calendars(time stream) in the means of transport, having undesired results:
    a) Transportation Lane A-X. Calendar 1A, only Monday is available
    The system creates stock transfers on Monday on Week 1 and ends on Monday of Week 3.
    b) Transportation Lane A-X. Calendar 2A, Monday and Wednesday are available
    The system creates stock transfers on Monday and Wednesday on Week 1:
          The stock transfer that starts on Monday-Week 1 ends on Monday-Week 2.
          The stock transfer that starts on Wednesday-Week 1 ends on Wednesday-Week 2.
    c) Transportation Lane A-X. Calendar 3A, Monday Tuesday and Wednesday are available
    The system creates stock transfers on Monday, Tuesday and Wednesday on Week 1.
         The stock transfer that starts on Monday-Week 1 ends on Wednesday-Week 1. (this is actually what I need)
         The stock transfer that starts on Tuesday-Week 1 ends on Monday-Week 2.
         The stock transfer that starts on Wednesday-Week 1 ends on Tuesday-Week 2.
    Regards

    you really don't need to post all that code, few people will read it, or try to compile/run it.
    just a tree in a scrollpane in a frame is all you need, then add the method/problem to the basic,
    and post that so its only 20 to 30 lines long.
    here's your basic tree/scrollpane/frame, with an expandAll()
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      public void buildGUI()
        JTree tree = new JTree();
        expandAll(tree);
        JFrame f = new JFrame();
        f.getContentPane().add(new JScrollPane(tree));
        f.pack();
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public void expandAll(JTree tree)
        int row = 0;
        while (row < tree.getRowCount())
          tree.expandRow(row);
          row++;
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }so, is your problem with the expandAll(), or with reading the properties file?

  • Using hyperlinks in a scrollpane.

    Well, Ive finally been able to display the webpages in my scrollpane now. But when i move my mouse over the hyperlinks.....it doesn't change, and won't go to the located urls. What am I doing wrong please?
    Thanx

    You need to add hyperlink event listeners to your JEditorPane. This is because the editor pane only displays the document, it doesn't do anything about the hyperlinks itself.
    This is the usual way to do it...
        JEditorPane myEditorPane;
        myEditorPane.addHyperlinkListener(new MyHyperlinkListener());
        class MyHyperlinkListener implements HyperlinkListener {
            public void hyperlinkUpdate(HyperlinkEvent evt) {
                HyperlinkEvent.EventType type = evt.getEventType();
                if (type.equals(HyperlinkEvent.EventType.ACTIVATED)) {
                    // the hyperlink was clicked or activated by the keyboard or some other way, so change the editor to that URL.
                    myEditorPane.setPage(evt.getURL());
                // there is also ENTERED and EXITED, which roughly equate to HTML's mouseover, mouseout events.

  • Scrollpane contents disappear

    I've got a AS3 scrollpane with a content source of an empty clip called holder.
    I've got a search function that returns an xmllist and then attaches a movieclip for each node in the list and adds some details from the xml node, then each movieclip gets added to the scrollpane. All this works well.
    The contents originally come in "relevance" order, but there are buttons for title and date orders as well. When the user clicks to change the order the xmllist is sorted and the code then figures out where each of the clips should be and TweenLite tweens them from their current location in the scrollpane to their new location. And most of the time this has worked well.
    Because of word stemming the words management and managers return the same results (the initial relevance rankings are most likely different). Oddly enough management results "lose" several of the clips when sorting to date or title. Oddly they come back/reappear when putting them back into relevance order. Even stranger, none of this happens with the managers results–the same results, but in a slightly different initial relevance order.
    The movieclips are arranged (for those specific results) in 25 rows and are probably about 4500 pixels high. Could that be the source of the problem?
    I just noticed the problem at the end of the day, so I haven't had much chance to try and figure it out. Anybody experienced this before? Any ideas?

    That seems to have fixed it. I'm using the killTweensOf() instead, but it seems that given how many rows of this there were some at the bottom hadn't faded in and still had a low alpha.

  • Set Location of JPanel in another JPanel

    Hello, i want to set the location of a JPanel in another JPanel.
    This is my code:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package nemo;
    * @author Administrator
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class BackgroundImage extends JFrame
         JScrollPane scrollPane;
         ImageIcon icon;
            ImageIcon iconDrinken;
         Image image;
         public BackgroundImage() {
              icon = new ImageIcon("startpage.JPG");
                    iconDrinken = new ImageIcon("drankje.JPG");
              JPanel panel = new JPanel() {
                   protected void paintComponent(Graphics g) {
                        //  Dispaly image at at full size
                        g.drawImage(icon.getImage(), 0, 0, null);
                        super.paintComponent(g);
                    JPanel panelDrinks = new JPanel() {
                        protected void paintComponent(Graphics g) {
                            g.drawImage(iconDrinken.getImage(), 0, 0, null);
                            super.paintComponent(g);
                    panelDrinks.setOpaque( false );
              panelDrinks.setPreferredSize( new Dimension(200, 215) );
              panel.setOpaque( false );
              panel.setPreferredSize( new Dimension(400, 400) );
              scrollPane = new JScrollPane( panel );
              getContentPane().add( scrollPane );
                    panel.add(panelDrinks);
         public static void main(String [] args)
              BackgroundImage frame = new BackgroundImage();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(800, 600);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }When i execute this i get this:
    [http://img208.imageshack.us/img208/738/nowml5.jpg]
    And i want the image in the first white box from the left.
    But how to do it???
    I've tried .setLocation and .setBounds
    Edited by: Sven.nl on Apr 17, 2008 2:42 AM
    Edited by: Sven.nl on Apr 17, 2008 2:43 AM

    I already found it. Thanks anyway.
                    JPanel panelDrinks = new JPanel() {
                        protected void paintComponent(Graphics g) {
                            g.drawImage(iconDrinken.getImage(), 100, 200, 200, 215, null);
                            super.paintComponent(g);
                    panelDrinks.setOpaque( false );
              panelDrinks.setPreferredSize( new Dimension(800, 600) );
                    panelDrinks.setLocation(300, 300);
                      Edited by: Sven.nl on Apr 17, 2008 3:05 AM

  • ScrollPane doesn't display its content

    I created a scrollpane in as3 and set its source to another object, which contains several rows of icons.
    The scrollbar in the scrollpane is getting the right length, which means the object was loaded as expected, but the contant is not showing correctly.
    I created a Thumbnail class for this file to load and make each individual thumbnail.
    Here is my code, the red text is where each thumbnail is loaded:
    import fl.containers.UILoader;
    import caurina.transitions.*;
    import flash.events.Event;
    import fl.containers.ScrollPane;
    var urlRequest:URLRequest = new URLRequest("pics.xml");
    var urlLoader:URLLoader = new URLLoader();
    var myXML:XML = new XML();
    var xmlList:XMLList;
    myXML.ignoreWhitespace = true;
    urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    urlLoader.load(urlRequest);
    var arrayURL:Array = new Array();
    var arrayName:Array = new Array();
    var holderArray:Array = new Array();
    var nrColumns:uint = 3;
    var sprite:Sprite = new Sprite();
    addChild(sprite);
    var thumb:Thumbnail;
    var thumbsHolder:Sprite = new Sprite();
    sprite.addChild(thumbsHolder);
    var loaderHolder:Sprite = new Sprite();
    loaderHolder.graphics.beginFill(0x666666,1);
    loaderHolder.graphics.drawRoundRect(0,0,450,340, 20,20);
    loaderHolder.graphics.endFill();
    loaderHolder.x = 280;
    loaderHolder.y = 240;
    sprite.addChild(loaderHolder);
    var photoLoader:UILoader = new UILoader();
    photoLoader.width = 450;
    photoLoader.height = 340;
    photoLoader.y = 5;
    photoLoader.x = 5;
    photoLoader.buttonMode = true;
    photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
    loaderHolder.addChild(photoLoader);
    var scrollPane:ScrollPane=new ScrollPane();
    var skin:MovieClip = new MovieClip();
    scrollPane.x = 805;
    scrollPane.y = 405;
    scrollPane.width = 215;
    scrollPane.height = 280;
    scrollPane.setStyle( "skin", skin );
    scrollPane.setStyle( "upSkin", skin );
    scrollPane.source = thumbsHolder;
    sprite.addChild(scrollPane);
    function fileLoaded(event:Event):void
    myXML = XML(event.target.data);
    xmlList = myXML.children();
    for (var i:int=0; i<xmlList.length(); i++)
      var picURL:String = xmlList[i].url;
      var picName:String = xmlList[i].big_url;
      arrayURL.push(picURL);
      arrayName.push(picName);
      holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
      holderArray[i].addEventListener(MouseEvent.CLICK,onClick);
      holderArray[i].name = arrayName[i];
      holderArray[i].buttonMode = true;
      if (i<nrColumns)
       holderArray[i].y = 440;
       holderArray[i].x = i * 65 + 840;
      else
       holderArray[i].y = holderArray[i - nrColumns].y + 65;
       holderArray[i].x = holderArray[i - nrColumns].x;
      thumbsHolder.addChild(holderArray[i]);
      scrollPane.update();
    function onClick(event:MouseEvent):void
    photoLoader.alpha = 0.1;
    photoLoader.source = event.currentTarget.name;
    photoLoader.addEventListener(Event.COMPLETE, fadeOut);
    function fadeOut(event:Event):void
      Tweener.addTween(photoLoader, {alpha:1, time:0.5, transition:"linear"});
    function onClickBack(event:MouseEvent):void
      Tweener.addTween(loaderHolder, {alpha:.5, time:2, transition:"linear"});

    Bold is about the only text editing feature that works in the current editor panel.  The rest were disabled due to spam-related abuse (addng white text, etc)
    I cannot really follow what is going into where and where it is being put (just too lazy to track it down at this time of night), but it sounds like it might be possible that your content is being planted at a location that it is not visible in the scrollpane panel.  The scrollpane is only 215 pixels wide but you have something called a loaderHolder that is being placed at x = 280.  And then elsewhere you have holderArray[i].x = i * 65 + 840;, which is placing it well beyond the 215 width.

  • Set location of components and reduce the size

    I want to resize JavaFX component and shrink the components which are next to it. Here is the result which I get:
    When I click on the angle of this component I can resize it down and right.
    http://i.stack.imgur.com/jqoNW.png
    The components which are next to it are pushed down and right. Part of them are behind the visible part of the screen.
    http://i.stack.imgur.com/rsi0L.png
    All components are placed in BorderPane,VBox,HBoxand againBorderPane. I don't want to allow components to move. I want to shrink them and use Scrollpane` when their size is reduced. Can you give me some hits how to solve these two problems?
    Ref javafx 2 - Set location of components and reduce the size - Stack Overflow

    I did something similar the other day. Based on the resizing of the scene I adjusted the position.
    widthProperty().addListener(new ChangeListener<Number>() {
        @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) {
            widthChange((Double)oldSceneWidth, (Double)newSceneWidth);
    heightProperty().addListener(new ChangeListener<Number>() {
        @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) {
            heightChange((Double)oldSceneHeight, (Double)newSceneHeight);
    You should be able to do something similar, when you add a change listener to your component and handle the resizing of the other components.
    What I don't understand is why you would need a scrollbar, when the components shrink down. I would think it would be the other way round.

  • ScrollPane - Changing various colors and appearance

    I am trying to change the color layout of my ScrollPane boxes.  My website (removed) has a clean, white background.  The default white and light grey color of the standard ScrollPane scheme blends in too much.  I would like to change the color of the vertical scrollbar so that it stands out more.  Also, maybe have the background of the text box a light blue hue with black lettering to give it some "pop" also.
    I am running Flash CS5 in AS 2.  I have read on another website to do the following in ActionScript:
    ScrollPane.setStyle("themeColor", "haloOrange")
    ScrollPane.setStyle("borderStyle", "none")
    ScrollPane.setStyle("scrollTrackColor", 0CC333)
    ScrollPane.setStyle("symbolColor", FF00FF)
    ScrollPane.setStyle("symbolDisabledColor", FFFF00)
    This did not work.
    Look at the bottom of the website for "Terms - Credits - Policies".  On this page there are three scrollPanes.  This is where I want to create these colorful ScrollPanes.  Please help.  If you want me to send you screenshots, I can do that, but looking at the live website might be all you need.  By the way, I am a novice in ActionScripting.  Thanks.  djm

    Thank you.  We are one step closer....
    Here is what I have done with its results.
    I removed the action scripting in the ScrollPane page noted in previous replies.  I left in your original step of "backgroundColor".  This is the only step that works.  I altered the "ThemeColor" from "haloBlue" to "haloOrange" to see if the buttons change, and they do.  So that is a good thing.  I then removed the scripting altogether because they are not the corect color selections for my website.
    Now, I followed your suggestions found on both links noted above.  There must be something I am missing. 
    I opened the HaloTheme.FLA file and FLASH opened it in a separate window.  From that window, I located "VScrollBarAssets" movie clip.  I dragged that movie clip into my document's library.  FLASH created a new folder with the following format:
          Flash UI Components 2 >  Themes > MMDefault > Scrollbar Assets
    In the last folder, VScrollBarAssets Movie Clip exists with "States" and "Elements" folders.
    I am able to change the colors in "VScrollBarAssets", but when I test the movie (either by Publishing (F12) or selecting "Control -Test Movie"), there is no change in the tested version.
    I do the same by changing the colors of  "ScrollThemeColor1" and "ScrollThemeColor2" in Elements folder.  Still no change when tested.
    I made the color choices a brown color to make it obvious.  The default light blue and grey colors remain.  What am I missing?  THANKS!!  djm

  • Add Dynamic Content to ScrollPane

    I have created a Address Class that uses Remote Hosting to
    get addresses for site locations and creates the appropriate
    listings in a MovieClip.
    I am trying to use this class as the source for a scroll pane
    inside another movie clip.
    I get the site locations to show up in the scrollPane but
    they will not scroll.
    I believe I need to pause some how in the constructor until I
    have all the site addresses created.
    Anyone know how I would do that or know how to get the
    scrollpane to scroll.
    Thanks
    Adam
    Here are some snippets
    The container MovieClip
    import FlashCFMXApplication.AL_Addresses;
    import fl.containers.ScrollPane;
    var scrollPane:ScrollPane;
    scrollPane = new ScrollPane;
    scrollPane.scrollDrag = true;
    scrollPane.width = 270;
    scrollPane.height = 380;
    scrollPane.y = -180;
    scrollPane.source = new AL_Addresses;
    addChild(scrollPane);
    stop();
    AL_Addresses.as
    package FlashCFMXApplication{
    import flash.display.Sprite
    public class AL_Addresses extends Sprite
    import flash.display.*;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.net.Responder;
    import fl.data.DataProvider;
    import FlashCFMXApplication.ArrayCollectionDP
    private var siteTitleFormat:TextFormat;
    private var siteCityFormat:TextFormat;
    private var requestObject = new Object;
    private var getStateSites = new Responder(getSites,
    onFault);
    private var getStats = new Responder(getSiteStats, onFault);
    public var maxWidth:int;
    public var Addresses_mc = new MovieClip();
    public var getStateSites_mc:MovieClip;
    public var box:Shape = new Shape();
    public function AL_Addresses() {
    import flash.net.NetConnection;
    var myService:NetConnection;
    myService = new NetConnection();
    //set encoding to AMF0 for complex objects
    myService.objectEncoding = 0;
    myService.connect("
    http://site.com/flashservices/gateway")
    requestObject.requestType = "rs"
    requestObject.requestData = "AL";
    myService.call( "sites.functions.getStateSites" ,
    getStateSites,requestObject);
    private function getSites(result){
    siteTitleFormat = new TextFormat();
    siteTitleFormat.font = "Arial";
    siteTitleFormat.size = 13; //12
    siteTitleFormat.color = 0xBCBCBC;
    siteTitleFormat.bold = true;
    siteCityFormat = new TextFormat();
    siteCityFormat.font = "Arial";
    siteCityFormat.size = 13; //12
    siteCityFormat.color = 0xF87A04;
    siteCityFormat.bold = true;
    var myDataProvider:DataProvider;
    myDataProvider = new DataProvider();
    myDataProvider =
    ArrayCollectionDP.toDataProvider(result.SITES_RS);
    var x:int = 10;
    var y:int = 5;
    var tmp_mc:MovieClip;
    for (var i:int = 0; i <= myDataProvider.length-1; i++){
    var x_text:int = 0;
    var y_text:int = 0;
    tmp_mc = new MovieClip;
    var Name:TextField = new TextField();
    Name.width = 270;
    Name.x = x_text;
    Name.y = y_text;
    Name.text = myDataProvider.getItemAt(i).NAME;
    Name.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Name);
    y_text = y_text + 15
    var Address:TextField = new TextField();
    Address.width = 270;
    Address.x = x_text;
    Address.y = y_text;
    Address.text = myDataProvider.getItemAt(i).ADDRESS;
    Address.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Address);
    y_text = y_text + 15
    var City:TextField = new TextField();
    City.x = x_text;
    City.y = y_text;
    City.text = myDataProvider.getItemAt(i).CITY;
    City.setTextFormat(siteCityFormat);
    tmp_mc.addChild(City);
    x_text = x_text + City.textWidth + 5;
    var State:TextField = new TextField();
    State.width = 100;
    State.x = x_text;
    State.y = y_text;
    State.text = myDataProvider.getItemAt(i).STATE;
    State.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(State);
    x_text = x_text + State.textWidth + 3;
    var Zip:TextField = new TextField();
    Zip.x = x_text;
    Zip.y = y_text;
    Zip.text = myDataProvider.getItemAt(i).ZIP;
    Zip.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Zip);
    tmp_mc.x = x;
    tmp_mc.y = y;
    Addresses_mc.addChild(tmp_mc);
    y = y + 120;
    getStateSites_mc.addChild(Addresses_mc);
    public function onFault( f){
    trace("There was a problem: " + f.description);
    }//class
    } //package

    I don't see it in your code anywhere, but maybe you removed
    it (or I'm just not seeing it). You should update it only after you
    have filled the scrollpane, not when you add the scrollpane to the
    stage. It is not likely the scrollpane is filled by the time these
    two lines are processed, especially if you are loading content from
    a server...
    scrollPane.source = new AL_Addresses;
    addChild(scrollPane);

  • Complete ScrollPane Control (SSCCE)

    Alright.. you can see my original ideas about how I want scrolling to happen in a real-time situation in my first post:
    http://forum.java.sun.com/thread.jspa?threadID=5168056
    I've since tried to move forward but immediately hit another snag.
    Problem: Now I can keep the text from jumping as it is inserted and deleted, but when I resize the JFrame in the SSCCE below MyTextPane calculates the preferredSize based on if the text pane had word wrapping on. So this causes my scrollbar to be WAY off if you shorten the width of the JFrame. I've tried to changing up my "Dimension getPreferredSize()" method in MyTextPane, but for some reason I can't get it to work.
    Example:
    1. Open the program and "add" 10 lines. Everything is fine here.. I do not want the scrollbar to scroll with the text because this is trivial to program. Verify that the vertical scrollbar only goes down to 1 line past the last text in the MyTextPane.
    2. Now take the left edge of the JFrame and shorten the width of the JFrame as much as it will allow you. Now verify that the vertical scrollbar is WAY too long for the text. This is because the overloaded getPreferredSize() in MyTextPane doesn't taken into account if the super.getPreferredSize() has sizes bigger than maxWidth or maxSize.
    Now, I've experimented endlessly with the getPreferredSize() in MyTextPane and I cannot find a suitable answer to this problem.
    If any of this seems insane, and there is an easier approach to all of this (if you even understand what I am aiming for) I am all ears. I will keep you all posted of any breakthroughs! :-)
    Thanks guys,
    Js
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    public class DeleteTextResetExample extends JFrame
         //STATICS
         private static final String LINE_STR = "This is a new line and is amazing for me to see!\n";
         //DATA
         private int lineCount;
         private int maxLineWidth;
         //GUI
         private JLayeredPane myLayeredPane;
              private JScrollPane scrollPane;
                   private MyTextPane textPane;
         //MENU
         private JMenuBar mainMenuBar;
              private JMenu actionMenu;
                   private JMenuItem addLineMenuItem;
                   private JMenuItem delLineMenuItem;
         public DeleteTextResetExample()
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setContentPane(getMyLayeredPane());
              this.setJMenuBar(getMainMenuBar());
              this.pack();
              this.setVisible(true);
         //GUI
         private JLayeredPane getMyLayeredPane()
              if(myLayeredPane == null)
                   myLayeredPane = new JLayeredPane();
                   myLayeredPane.setPreferredSize(new Dimension(200,100));
                   myLayeredPane.add(getScrollPane(), new Integer(0));
                   myLayeredPane.addComponentListener(new ComponentAdapter()
                       public void componentResized(ComponentEvent e)
                            System.out.println("LAYERED PANE RESIZED");
                            //First make sure the objects inside the layered pane are in the correct spot
                            getScrollPane().setBounds(0,0,myLayeredPane.getWidth(),myLayeredPane.getHeight());
                             //Force the size of the Non-Shrinking Text Pane to either the size of the text or the size of
                             //the layered pane depending on who is bigger.
                             int newHeight = lineCount*getTextPane().getFontMetrics(getTextPane().getFont()).getHeight();
                             int newWidth = maxLineWidth;                         
                             System.out.println("TEXT HEIGHT: " + newHeight);
                             System.out.println("PANE HEIGHT: " + myLayeredPane.getHeight());
                             System.out.println("TEXT WIDTH: " + newWidth);
                             System.out.println("PANE WIDTH: " + myLayeredPane.getWidth());
                             if(myLayeredPane.getHeight() > newHeight)
                                  System.out.println("\tHEIGHT: FRAME IS BIGGER THAN TEXT");
                                  newHeight = myLayeredPane.getHeight();
                             else
                                  System.out.println("\tHEIGHT: TEXT IS BIGGER THAN FRAME");
                             if(myLayeredPane.getWidth() > newWidth)
                                  System.out.println("\tWIDTH: FRAME IS BIGGER THAN TEXT");
                                  newWidth = myLayeredPane.getWidth();
                             else
                                  System.out.println("\tWIDTH: TEXT IS BIGGER THAN FRAME");
                             System.out.println();
                             //Now force the size to the correct size
                             getTextPane().forceSize(new Dimension(newWidth,newHeight));
              return myLayeredPane;
         private JScrollPane getScrollPane()
              if(scrollPane == null)
                   scrollPane = new JScrollPane(getTextPane());
              return scrollPane;
         private MyTextPane getTextPane()
              if(textPane == null)
                   textPane = new MyTextPane();
                   textPane.setEditable(false);
              return textPane;
         //MENU
         private JMenuBar getMainMenuBar()
              if(mainMenuBar == null)
                   mainMenuBar = new JMenuBar();
                   mainMenuBar.add(getActionMenu());
              return mainMenuBar;
         private JMenu getActionMenu()
              if(actionMenu == null)
                   actionMenu = new JMenu("Action");
                   actionMenu.add(getAddLineMenuItem());
                   actionMenu.add(getDelLineMenuItem());
              return actionMenu;
         private JMenuItem getAddLineMenuItem()
              if(addLineMenuItem == null)
                   addLineMenuItem = new JMenuItem("Add Line");
                   addLineMenuItem.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                             Thread t = new Thread()
                                  public void run()
                                       Document d = getTextPane().getDocument();
                                       try
                                            //Insert the string
                                            d.insertString(d.getLength(), LINE_STR, null);
                                            //Up our line count
                                            lineCount++;
                                            //Update our max line width if necessary
                                            Rectangle2D strBounds = getTextPane().getFontMetrics(getTextPane().getFont()).getStringBounds(LINE_STR,getTextPane().getGraphics());
                                            int strWidth = (int)strBounds.getWidth();
                                            if(strWidth > maxLineWidth)
                                                 maxLineWidth = strWidth;
                                       catch(BadLocationException ble)
                                            ble.printStackTrace();
                             t.start();
              return addLineMenuItem;
         private JMenuItem getDelLineMenuItem()
              if(delLineMenuItem == null)
                   delLineMenuItem = new JMenuItem("Delete Line");
                   delLineMenuItem.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                             Thread t = new Thread()
                                  public void run()
                                       Document d = getTextPane().getDocument();
                                       try
                                            d.remove(d.getLength()-LINE_STR.length(),LINE_STR.length());
                                            lineCount--;
                                       catch(BadLocationException ble)
                                            ble.printStackTrace();
                             t.start();
              return delLineMenuItem;
         //MAIN
         public static void main(String args[])
              new DeleteTextResetExample();
         private class MyTextPane extends JTextPane
              //DATA
              private int maxHeight;
              private int maxWidth;
              //This keeps the pane from resizing the width to the viewport(stops word wrapping)
              public boolean getScrollableTracksViewportWidth()
                   return false;
              //This keeps the size of the text pane from ever getting smaller
              public void setSize(Dimension d)
                   if(d.width > maxWidth)
                        maxWidth = d.width;
                   if(d.height > maxHeight)
                        maxHeight = d.height;
                   System.out.println("SETTING SIZE: " + maxWidth + "," + maxHeight);
                   System.out.println();
                   super.setSize(new Dimension(maxWidth,maxHeight));
              //This tells the viewport and others that we want to have a preferred size at least as big as our
              //text pane, but we cannot set d.width = maxWidth or d.height = maxHeight for some reason.
              public Dimension getPreferredSize()
                   Dimension d = new Dimension(super.getPreferredSize());
                   if(d.width < maxWidth)
                        d.width = maxWidth;
                   if(d.height < maxHeight)
                        d.height = maxHeight;
                   System.out.println("GETTING PREFERRED SIZE: " + d.width + "," + d.height);
                   System.out.println();
                   return d;
              //This forces the text pane to any size decided. This is the only way to make the text pane smaller.
              public void forceSize(Dimension d)
                   System.out.println("FORCING SIZE: " + d.width + "," + d.height);
                   System.out.println();
                   maxWidth = d.width;
                   maxHeight = d.height;
                   super.setSize(d);
    }

    Ty Michael_Dunn, you are right. But you are also right about the problems that the fix causes.
    I've actually gotten one giant step closer. See... I was not taking into account the insets of my text pane and THAT was what was causing the "word wrapped" preferred size even when there was no word wrap. I was setting the size so that when the fixed width text pane tried to calculate its preferred size... it thought it should have wrapped text. Even though in the end I was denying it from actually wrapping the text.
    Take a look at this code... it is much cleaner and almost works 100 percent.
    The problem I have now:
    1. Open program and "add" 10 lines. Verify that both the scrollbars are behaving correctly.
    2. Move the JFrame so its left edge is located near the left edge of your screen.
    3. Resize the JFrame by dragging its right edge all the way over to the right edge of your screen. Verify that you see the gray background near the right side of the text pane.
    This is unwanted. I added some System.out.println()'s in there to show how the scrollpane is not being updated to the correct size, and therefore my forced resize does not work as expected.
    Also verify that the old problem that started this post has been resolved as well.
    Thanks!!
    -Js
    import java.awt.Dimension;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    import javax.swing.JLayeredPane;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.SwingUtilities;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    public class DeleteTextResetExample extends JFrame
         //STATICS
         private static final String LINE_STR = "This is a new line and is amazing for me to see!\n";
         //DATA
         private int lineCount;
         private int maxLineWidth;
         //GUI
         private JLayeredPane myLayeredPane;
              private JScrollPane scrollPane;
                   private MyTextPane textPane;
         //MENU
         private JMenuBar mainMenuBar;
              private JMenu actionMenu;
                   private JMenuItem addLineMenuItem;
                   private JMenuItem delLineMenuItem;
         public DeleteTextResetExample()
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setContentPane(getMyLayeredPane());
              this.setJMenuBar(getMainMenuBar());
              this.pack();
              this.setVisible(true);
         //GUI
         private JLayeredPane getMyLayeredPane()
              if(myLayeredPane == null)
                   myLayeredPane = new JLayeredPane();
                   myLayeredPane.setPreferredSize(new Dimension(200,100));
                   myLayeredPane.add(getScrollPane(), new Integer(0));
                   myLayeredPane.addComponentListener(new ComponentAdapter()
                       public void componentResized(ComponentEvent e)
                            SwingUtilities.invokeLater(new Runnable()
                                 public void run()
                                      //First make sure the objects inside the layered pane are in the correct spot
                                      getScrollPane().setBounds(0,0,myLayeredPane.getWidth(),myLayeredPane.getHeight());
                                       //Force the size of the Non-Shrinking Text Pane to either the size of the text or the size of
                                       //the scrollPane
                                      Insets insets = getTextPane().getInsets();
                                      //Figure out the new heights for both the text and the scrollPane
                                       int newHeight = lineCount*getTextPane().getFontMetrics(getTextPane().getFont()).getHeight() + insets.top + insets.bottom;
                                       int newWidth = maxLineWidth + insets.left + insets.right;
                                       int scrollPaneHeight = getScrollPane().getHeight();
                                       if(getScrollPane().getHorizontalScrollBar().isShowing())
                                            scrollPaneHeight -= getScrollPane().getHorizontalScrollBar().getHeight();
                                       int scrollPaneWidth = getScrollPane().getWidth();
                                       if(getScrollPane().getVerticalScrollBar().isShowing())
                                            scrollPaneWidth -= getScrollPane().getVerticalScrollBar().getHeight();
                                       System.out.println("LAYERED PANE: " + myLayeredPane.getWidth() + "," + myLayeredPane.getHeight());
                                       System.out.println("TEXT BOUNDS: " + newWidth + "," + newHeight);
                                       System.out.println("SCROLL PANE: " + scrollPaneWidth + "," + scrollPaneHeight);
                                       System.out.println();
                                       //Now compare the text bounds and the scrollpane bounds and choose to set
                                       if(scrollPaneHeight > newHeight)
                                            newHeight = scrollPaneHeight;
                                       if(scrollPaneWidth > newWidth)
                                            newWidth = scrollPaneWidth;
                                       //Now force the size to the correct size
                                       getTextPane().forceSize(new Dimension(newWidth,newHeight));               
              return myLayeredPane;
         private JScrollPane getScrollPane()
              if(scrollPane == null)
                   scrollPane = new JScrollPane(getTextPane());
              return scrollPane;
         private MyTextPane getTextPane()
              if(textPane == null)
                   textPane = new MyTextPane();
                   textPane.setEditable(false);
              return textPane;
         //MENU
         private JMenuBar getMainMenuBar()
              if(mainMenuBar == null)
                   mainMenuBar = new JMenuBar();
                   mainMenuBar.add(getActionMenu());
              return mainMenuBar;
         private JMenu getActionMenu()
              if(actionMenu == null)
                   actionMenu = new JMenu("Action");
                   actionMenu.add(getAddLineMenuItem());
                   actionMenu.add(getDelLineMenuItem());
              return actionMenu;
         private JMenuItem getAddLineMenuItem()
              if(addLineMenuItem == null)
                   addLineMenuItem = new JMenuItem("Add Line");
                   addLineMenuItem.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                             Thread t = new Thread()
                                  public void run()
                                       Document d = getTextPane().getDocument();
                                       try
                                            //Insert the string
                                            d.insertString(d.getLength(), LINE_STR, null);
                                            //Up our line count
                                            lineCount++;
                                            //Update our max line width if necessary
                                            Rectangle2D strBounds = getTextPane().getFontMetrics(getTextPane().getFont()).getStringBounds(LINE_STR,getTextPane().getGraphics());
                                            int strWidth = (int)strBounds.getWidth();
                                            if(strWidth > maxLineWidth)
                                                 maxLineWidth = strWidth;
                                       catch(BadLocationException ble)
                                            ble.printStackTrace();
                             t.start();
              return addLineMenuItem;
         private JMenuItem getDelLineMenuItem()
              if(delLineMenuItem == null)
                   delLineMenuItem = new JMenuItem("Delete Line");
                   delLineMenuItem.addActionListener(new ActionListener()
                        public void actionPerformed(ActionEvent e)
                             Thread t = new Thread()
                                  public void run()
                                       Document d = getTextPane().getDocument();
                                       try
                                            d.remove(d.getLength()-LINE_STR.length(),LINE_STR.length());
                                            lineCount--;
                                       catch(BadLocationException ble)
                                            ble.printStackTrace();
                             t.start();
              return delLineMenuItem;
         //MAIN
         public static void main(String args[])
              new DeleteTextResetExample();
         private class MyTextPane extends JTextPane
              //DATA
              private int maxHeight;
              private int maxWidth;
              //This keeps the pane from resizing the width to the viewport(stops word wrapping)
              public boolean getScrollableTracksViewportWidth()
                   return false;
              //This keeps the size of the text pane from ever getting smaller
              public void setSize(Dimension d)
                   if(d.width > maxWidth)
                        maxWidth = d.width;
                   if(d.height > maxHeight)
                        maxHeight = d.height;
                   super.setSize(new Dimension(maxWidth,maxHeight));
              //This tells the viewport and others that we want to have a preferred size at least as big as our
              //text pane, but we cannot set d.width = maxWidth or d.height = maxHeight for some reason.
              public Dimension getPreferredSize()
                   Dimension d = super.getPreferredSize();
                   if(d.width < maxWidth)
                        d.width = maxWidth;
                   if(d.height < maxHeight)
                        d.height = maxHeight;
                   return d;
              //This forces the text pane to any size decided. This is the only way to make the text pane smaller.
              public void forceSize(Dimension d)
                   maxWidth = d.width;
                   maxHeight = d.height;
                   super.setSize(d);
    }

  • Accessing Button inside Movieclip/ScrollPane

    Hello all,
    I'm trying to understand how to build a button inside a movieclip.  I have a template that has movieclips within movieclips, and when I create a button (all using AS2) the button will work if I test the scene, but in the whole flash movie it does not work.  I also have some buttons located inside a ScrollPane that also do not call correctly.
    For my button I am using this code:
    facebookbtn.on (release) {
    getURL("http://www.facebook.com/","_blank","GET");
    ^ This is placed on the button "facebookbtn". I also tried using: _root.bgPages.pg1.facebookbtn.on (release), to no avail.
    For the one inside a ScrollPane I am attempting to call a javascript function:
    on(release){
         import flash.external.ExternalInterface;
         ExternalInterface.call("GroupDelegate","dayone1");
    ^ This also does not work, with or without the button name before on(release).
    I'm putting the FLA file here so that if anyone has the time, could help me with this quick problem. Thanks!
    FLA: Download FLA

    Do not place code inside objects with code on(blah2x). It will lead to unpredictable behaviors and besides it is bad practice. Centralize all your code on one frame in the timeline. Use this format on the main timeline:
    import mx.utils.Delegate; //declare at top only ONCE
    YourButton.onRelease = Delegate.create(this, YourFunctionCall);
    or
    YourButton.onRelease = function()
       //do your stuff here
    Do the same thing with the ExternalInterface. You can put the import at the top along with Delegate.

  • Scrollpane all screwy  inside loaded swf

    I have had this problem using both the scrollPane component
    from Flash 8 and an open source code scrollpane that I found in
    Flashkit. I have an swf in which I'm using a scrollPane which works
    fine when I test the movie. However, I'm loading this swf into
    another master swf using loadMovie. When I do this, the scrollpane
    inside the loaded swf gets really buggy. First, the scrollbar will
    not stop scrolling when I release the mouse. Also, the whole
    scrollPane gets a green highlight around the edges (except in the
    open-source code scrollpane). HELP!! Does anyone know how to load a
    scrollPane into another swf without it getting all weird?

    //below is the code for the "slideshow.swf"
    //For the main movie.. I'm doing....
    button_btn.onRelease = function() {
    myMovieClipLoader_mc.loadMovie("slideshow.swf")//
    this.createEmptyMovieClip("container_mc",this.getNextHighestDepth());
    this.createEmptyMovieClip("buttons_mc",this.getNextHighestDepth());
    //loader//
    this.attachMovie("loader2","loader_mc",this.getNextHighestDepth());
    loader_mc._x = (Stage.width - loader_mc.width)/2;
    loader_mc._y = (Stage.height - loader_mc.height)/2;
    var myMCL:MovieClipLoader = new MovieClipLoader();
    var myListener:Object = new Object();
    myMCL.addListener(myListener);
    myListener.onLoadProgress =
    function(target,bytesLoaded,bytesTotal) {
    loader_mc._alpha = 100;
    var pct = Math.round(bytesLoaded/bytesTotal*100);
    loader_mc.bar_mc._xscale = pct
    myListener.onLoadComplete = function(target) {
    loader_mc._alpha = 0;
    //button movies//
    buttons_mc.attachMovie("prev","prev_mc",buttons_mc.getNextHighestDepth());
    buttons_mc.attachMovie("next","next_mc",buttons_mc.getNextHighestDepth());
    buttons_mc.next_mc._x = Stage.width -
    buttons_mc.next_mc._width;
    buttons_mc.next_mc._y = 10;
    buttons_mc.prev_mc._x = 10;
    buttons_mc.prev_mc._y = 10;
    //variables//
    var numPics:Number = 5
    var picArray:Array = new Array();
    var currentElement:Number = 0;
    for (i=0;i< numPics;i++) {
    var location:String = "pics/pic0" + (i+1) + ".jpg";
    picArray.push(location);
    myMCL.loadClip(picArray[currentElement],container_mc);
    //next button//
    buttons_mc.next_mc.onRelease = function() {
    if (currentElement < picArray.length-1) {
    currentElement++;
    else
    currentElement = 0;
    myMCL.loadClip(picArray[currentElement],container_mc);
    //prev button//
    buttons_mc.prev_mc.onRelease = function() {
    if (currentElement > 0) {
    currentElement--;
    else
    currentElement = picArray.length-1;
    myMCL.loadClip(picArray[currentElement],container_mc);
    }

  • Import fl.containers.ScrollPane;

    Hello,
    I was looking over some of the AS3 packages, and I was
    trying sample code for ScrollPane.
    In any case, I kept getting errors, so I reduced the
    FLA down to
    import fl.containers.ScrollPane;
    I also tried:
    import fl.containers.*;
    The error is:
    1172: Definition fl.containers could not be found.
    I would think the Flash enviroment "knows"
    where this is located.
    What is wrong? Do I have to explicitly add the path?
    Thanks,
    Jim

    i know that "no" sounded curt but that's what it seemed you wanted.  i gave a complete answer in the message prior to that "no" response.
    for example, you can use the easing classes without using any component:
    import fl.transitions.easing.Back;
    var n:Number = Back.easeInOut(3,3,3,3);
    and, of course,  you can use the tween class without using any component.  but most of the fl classes do involve components and when you want to reference a component, it needs to be your library.

  • Stream 8 tablet location does not work on T-mobile broadband

    On my HP Stream 8 tablet, location works fine with GPS only (GNSS on; Mobile Broadband, Wi-Fi, and Bluetooth off).
    However, if I turn on Mobile Broadband and connect to T-Mobile and turn off GNSS (or GNSS on inside where there is no GPS signal) and keep Wi-Fi and Bluetooth off, the location gives very odd results.  Last week the map showed Phoenix as my location (I am actually located in San Francisco).  This week, it gives Brentwood or Clayton, CA, both more than 30 miles away.
    HP tech support said call T-Mobile.  T-Mobile said they had occasionally seen equally odd locations.
    I went to a nearby T-Mobile store.  They had a Samsung Galaxy Tab 4 which always gave a correct location, within 100 feet using T-Mobile alone.  Manually moving the map to a different location in an attempt to confuse it and turning it on and off, it would still find the correct location.  No surprise there, my three year old Virgin Mobile LG android cell phone does just as good a job at finding locations.
    (The T-mobile store also had an iPad Mini 3 that I was able to confuse.  On T-Mobile alone and clicking on My Location in maps, it produced a grid that was blank except for a line saying that it was unable to find a location, no info or link to what to do next.  The T-Mobile store did not have a Stream 8.  The Microsoft Store has a Stream 8 but it is not connected to Mobile Broadband.)
    Does anyone else have this problem?  Is my unit defective? There  are times that a GPS signal is unavailable and a T-mobile broadband signal is available, and it seems that this unit should be able to find a location at least as well as my cell phone.
    Thanks.

    I see the same basic results, wifi=off, bluetooth=off, gnss=off, t-mobile=on. Open win8.1 map-app shows my location in LA south of the 101/110 junction. I'm in SF Bay area near San Jose about 400 miles away. Turn on wifi and map-app shows me at my real address. With t-moile only, opened win8.1 IE, went to www.bing.com/maps location also shows LA.
    My only t-mobile account is the stream8 free 200mb/month data plan, don't think they have my real address anywhere. My t-mobile "phone" number is 720 area code in the Denver area. No idea why middle of LA is the t-mobile location. Must be a "feature, not a bug".

Maybe you are looking for

  • Possible reason for the iMac G5 with 10.4.3 Sleep Problems

    Ok first off let me say that I got this new iMac G5 20" about 4 days ago. It's wonderful. If anyone out there is holding out for the intel machines, don't wait, get a G5. It's a fantastic machine. Now on to the meat of the subject. The story goes lik

  • Does not load windows.

    hp g62 notebook. windows 7 home premium. Can go to F2 for testing.. Cannot go to F11 for system recovery Only see cursor blinking on the top left after pressing on F11 or finishing testing

  • Change of GOA in R3

    Hi All, I would like to have a opinion for a doubt. Can we change a SRM GOA transferred to R3 in R3? I have my own doubts about it....but would like to have a opinion of some expert. Also, if yes, is there a way of avoiding this?

  • Troubleshooting Webservices

    Hi, So, I'm in the midst of troubleshooting a 3rd party tool, that connects to sap me via web services. And I throws me an error I just can't figure out. this is the error: System.ServiceModel.Security.MessageSecurityException: The HTTP request is un

  • What advantages do Spry datasets have over database datasets

    I have been studying the Spry Dataset and have found it terribly difficult to understand what use it is. Can anyone explain why I should use it rather than using a database? On the face of it, Databases are much easier to construct and access, so why