JTree - Position & Size

I would like to display a JTree within a JScrollPane in JFrame.
My problem is: I can't set the position and size of the scrollPane.
     public void SimpleTree() {
         WindowUtilities.setNativeLookAndFeel();
         addWindowListener(new ExitListener());
         Container content = getContentPane();
         DefaultMutableTreeNode root = readXMLFile();     
         JTree jtree = new JTree(root);
         jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
         JScrollPane scrollPane  = new JScrollPane(jtree);
         scrollPane.setViewportView(jtree);
           // ? ? ? what do I need in here       
         content.add(scrollPane);
         setVisible(true);
       } I tried a lot, bot It does not working :(
Aykut

Hi Aykut,
The usual way to control the way components appear is to use a LayoutManager, which will allow you to dictate the overall layout for your content Container.
Alternatively, if you want to place the JScrollPane at a specific place and a specific size, you can set the LayoutManager to be null, then use scrollPane.setBounds(...) to prescribe exactly where it will sit.
The problem with the second choice (which appears at first glance to meet your requirements) is that different operating systems, with different native look-and-feels (as you're using) may vary in the exact size of components, borders, etc. and so may look better on one system than on others.
For this reason, I'd take the time to look at the alternative LayoutManagers (you may find that the relatively simple BorderLayout or BoxLayout meets your needs), the added advantage being automatic resizing of your scrollPane when the main window is resized.
I hope this is a helpful start though.
Chris.

Similar Messages

  • Safari Browser Position / Size

    How do I make Safari open every time in the same position / size? As it is now, I have to keep dragging the corners and moving the window so that it will fill the screen. Can I also use the same method with the windows of the other applications?

    Most applications open the same way as when you quit the application. However, for full screen it is different. For Safari you can create a bookmark and name it whatever you want (Full Screen would be a great name).
    Now go to this bookmark and change the web address to:
    javascript:self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);
    You can use this as a shortcut to make your screensize maxed out.

  • External Discs; Wndows not Remembering Positions/Size...

    Hi all,
    OK, this is driving me nuts: for some reason, my Mac won't remember the position/size of a window after I close one and open the app back up again, nor will things like external discs, ipods, etc. show up on my desktop when they are connected (ipods show up for an instant, then disappear.) It worked fine for a while then, one day, both things just gave up the ghost--any ideas what might be causing this?
    Note: Yes, I have Prefs in Finder set to display extrenal drives, ipods, etc.

    As far as I can tell this problem was never fixed and it goes back years:
    [https://bugzilla.mozilla.org/show_bug.cgi?id=251024 Bug 251024 - On startup the main window is incorrectly sized according to the workspace of the primary monitor]
    Even more bugs about it here:
    https://www.google.com/#q=firefox+dual+monitor+size+site:bugzilla.mozilla.org

  • Position/size properties messed up of imported svg's in An CC 2014?

    Hello,
    Opening an existing project in Edge Animate CC 2014 gave specific, big negative x and y coordinates of objects on the stage, while the objects still appeared at the right place on the stage. However, trying to alter the position, the object suddenly disappeared of screen.
    Starting a new project with a number of imported svg's made in Illustrator, trying to manipulate there position and scale is a nightmare. The size amounts are all over the place. I guess there is a serieus bug because of the now standard 10% scaling, when importing svg's.
    I sure hope Adobe is fixing this problem very soon and prevents such hiccups in future releases. Who has a work around or solution?
    Thanks for your response,
    Ad

    Hey Troy, apologies for the delay.
    I just tried this and did not experience the issue you describe. I went through nine copy (Illustrator) and paste (Edge) process. Each came through successfully.
    I don't suppose you are hitting a memory issue! I have 16gigs of Ram so I may be getting more use out of my upper memory allocation. I am also using the latest versions of both - is this your case as well.
    If need be and you want to get all of the states separated as svg, individually, you may want to have to a look at this Illustrator script - Export Illustrator Layers to SVG files | Thomas Byrne
    Darrell

  • How to get Graph's PlotArea Position & Size

    With Measurement Studio V6.0 it is possible to put annotation on Graph, in PlotArea coordinates.
    But to use these annotations correctly, I need to know the Graph's PlotArea position (relative to ClientRectangle) and the size.
    Hot to do that?
    Regards

    Here is a function that calculate X position relative to the graph control's parent window, from any X-axis value in the plot.
    int CDlgWithGraph::GetXForPlotPoint( double dbPlotXValue )
    CNiAnnotation annotation = m_ctrlGraph.Annotations.Item(1);
    annotation.SetCoordinateType( CNiAnnotation::AxesCoordinates );
    annotation.GetCaption().SetXCoordinate( dbPlotXValue );
    annotation.SetCoordinateType( CNiAnnotation:creenCoordinates );
    CPoint pt( annotation.GetCaption().GetXCoordinate(), 0 );
    m_ctrlGraph.ClientToScreen( &pt ); // pt in screen
    ScreenToClient( &pt );
    return pt.x;
    To get the SIZE of the plot area, pass min_x and max_x to width; pass min_y and max_y to get height. ( x,y values passed in are in pl
    ot axes ).

  • Programmatically adjust object's position/size while resizing a labview window

    Although I tried to achieve this result, i.e. rescale and display buttons at proper positions after a panel resize event, I obtained very poor results. It would be nice if anyone could help me to find the proper way to do it. Please, find enclosed a sample file. There I have attempted to rescale a chart after labview panel has been resized...
    if D0=(D0x,D0y) is a vector having FP sizes, prior resize, as its components,
    and  D=(Dx,Dy) is a vector having the FP sizes, after resize, as its components,
    I look for a Factors vector=(fx,fy) where fx=Dx/D0x  and fy=Dy/D0y
    Provided that chart has dimensions d0x (horiz.) and d0y (vert.); if Z0=(z0x,z0y) is the vector pointing to pane origin and Z=(zx,zy) is the position of the chart (top-left corner) before resize,
    I expect the position of the chart after resize operation to be Zf=(fx*(zx-z0x)+z0x,fy*(zy-z0y)+z0y). Moreover, after resize, the chart sizes should be fx*d0x (horiz.) and fy*d0y (vert.).
    But so far, all this does not seem to be fully correct...as you can test on your own.
    Regards,
    Daniele Cannavo
    Attachments:
    resize.vi ‏24 KB

    In this particular case the problem occurs if you shrink the window too much. What can happen is that the button gets moved onto the graph. When you then enlarge the window, the button remains on top of the graph. In the VI I uploaded the graph was the only thing that was being resized. In that particular setup resizing did not create any crazy conditions.
    In your original example you seem to only want to resize the graph. Are you trying to find a solution that applies to all objects on the front panel, or to a single object? If it's a single object then it appears to me that the example I provided should be adequate. If it's all objects, then you have a lot more to consider because you have to consider the size of the objects relative the positions. Technically, a resize of the panel should resize objects, and not move them. Your original VI seems to also move the graph. However, you can run into problems if the growth is too large. For instance, what do you do if you make the button so large that it would cover the LED? Also, which way is the LED grown? Diagonally towards the left and bottom, or radially?

  • Bitmap position & size in labels

    Hi All,
    I am developing an SAPScript form which is being used to print labels for different company codes. Each label should contain a logo (same logo for all labels) which has been given a specific position and size.
    Now since it is label printing, I have one main window with multiple instances. Is it possible to vary the size and position of a bitmap image in main window?
    I searched the forums and also in general over the Internet but did not find anything specific to my problem. I did find one SAP note which mentions the use of XPOS addition with the BITMAP control command, but it only applies to the horizontal position of the bitmap. What about the size and the vertical position? Is it possible at all?
    Thanks and Regards,
    Vidya.

    You may want to look into the DBMS_SPACE.CREATE_INDEX_COST procedure.
    Usage Notes* The table on which the index is created must already exist.
    * The computation of the index size depends on statistics gathered on the segment.
    * It is imperative that the table must have been analyzed recently.
    * In the absence of correct statistics, the results may be inaccurate, although the procedure will not raise any errors.

  • Jtree label size

    How can i set the size of a label to be displayed by a tree node.
    when i try to display little longer label near the node icon...it shows not the full
    label.at the end shows some dots...anybody knows how to do this ?
    thanks

    Hi Aykut,
    The usual way to control the way components appear is to use a LayoutManager, which will allow you to dictate the overall layout for your content Container.
    Alternatively, if you want to place the JScrollPane at a specific place and a specific size, you can set the LayoutManager to be null, then use scrollPane.setBounds(...) to prescribe exactly where it will sit.
    The problem with the second choice (which appears at first glance to meet your requirements) is that different operating systems, with different native look-and-feels (as you're using) may vary in the exact size of components, borders, etc. and so may look better on one system than on others.
    For this reason, I'd take the time to look at the alternative LayoutManagers (you may find that the relatively simple BorderLayout or BoxLayout meets your needs), the added advantage being automatic resizing of your scrollPane when the main window is resized.
    I hope this is a helpful start though.
    Chris.

  • Logging Swing attributes like size and position from an external app

    Hello,
    I'm currently thinking about how to implement some kind of logging application which will log the JComponent properties like size, position and visibility of another running Java application.
    I want to do this to collect AOI (area of interest) data for eye-tracker based software evaluations.
    This would of course be easily accomplish-able through implementing some kind of logging directly into the application. However, I would like to log positions for gui components for any Java Swing application without having to modify it.
    So what I'm basically looking for is some way to access a running Java Application's instances. In a static way this can be done by generating a heap dump, but I need this dynamically as position, size and visibility can also alter dynamically in most applications.
    I am currently looking at the JDI-API for this purpose and have also read a bit about JMX. But I'm wondering if there is a more simple approach that I'm missing? Is there some way to do a partial heap dump for certain classes for example (programmatically)?
    I'm sorry if this is the wrong category for the posting!
    Cheers
    Dennis

    Thanks for your help on this.
    The MacBook Air is a joy; but the limited drive space is the only caveat. I really should have spent the extra money on the 256 gb flash drive; but at the time I was in the mood to go minimalist. Unfortunately that doesn't work well for me.
    I have already moved all my music to iTunes Match and moved the backups to the external drive. I also keep most of my archive data on the 3 tb external drive. It's mostly those training video programs which are about a gig each that I want to move to the external drive ... ones I would not use that often ... so it's nice to know I can do that.
    THANKS AGAIN.

  • Locking Chart Size and Position

    I have a document that contains multiple workspaces with 2 charts on every page. I can scroll through each chart and the data changes when I do so. I have set width, lenth, and position sizes and once I set them and go through a few more, when I go back, the sizes and positions have changed/adjusted on their own to numbers I didn't set.
    Why is this?
    How can I lock size and position?

    "Workspace" is not a Numbers term that I am familiar with. Do you mean "Sheet"? You say you are using Numbers for OSX, but what you are describing sounds like an iWork for iOS complaint.
    Sorry, but I don't have enough information to go on to make a suggestion.
    Jerry

  • Reset gradient size/position in AI CC

    I'm not sure if I've missed a setting or gradients are behaving differently in AI CC.
    After filling a shape with a gradient fill and then modifying it's angle/position/size with the Gradient Tool (G)... then going to create a new shape, I want to reset the gradient back to the default angle/position/size. Usually I'd just click/double-click on the gradient I was using in the Swatches panel and it would reset. However this isn't working anymore.
    I was wondering if I've missed a setting to make this possible or there is a new way to do this? Any ideas?

    Works same way in CS5 as you described. But to answer your question fill with a non-gradeint swatch (temporarily) to clear the gradient tool positions, then fill with your final gradeint fill.
    This is easier to follow if you view >> show gradient annotator while doing this.

  • Remembering Window Sizes/Positions in Windows 7

    Hi
    I've read this thread regarding windows folder position/size (http://social.technet.microsoft.com/Forums/en-US/w7itproui/thread/5b524d53-df97-405d-835f-f081d106a19b)
    however it doesn't address my issue.
    For me, anytime I open a software, position it, play around in it and then close it, and reopen it again, it never goes back to the size/position I set it to. Same with Outlook. When I open a new email window, set its size and position, the next new email
    window is never where it needs to be.
    Is there a way for windows/outlook to remember where my software windows should be based on a position/size I give it?

    Hi,
    I would like to share the following link with you.
    http://support.microsoft.com/kb/235994
    You can know that how windows remembers the Window size.
    Regarding your outlook issue, you may close outlook then delete the frame key from HKCU\Software\Microsoft\Office\12.0\Outlook\Message\ and restart outlook. This will reset the window to the default size.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”

  • [Macro Crop VS Manual Crop] Crop position out of image Size

    Hi,I have been trying to crop my images using Macro.
    When i do it manually, Upon pressing the crop button, the Crop is positioned in the MIDDLE of the Image size which is alright for me.
    I'm Cropping it into a square. The problem is when I choose to crop it with Macro, It returns an image with larger height creating this blank space in my imageI have attached two images, One is with Macro, the prblem.
    The other without macro which is what i wish macro to do(Crop position Middle, It's like slicing the excessive image on both side off. Without having to increase the image which leads to blank white space
    Trying to get this with Macro

    Jonathan920 wrote:
    Size is different for different image. When i record the Crop, it records that particular image's Crop Position, Size etc. It doesn't automatically detect the image size and not crop perhaps based on % or whatever.
    I don't think you understood me.  Try recording your action again, but before you do, set the rulers to Percentage (by right clicking inside the ruler).
    Select the Crop tool, and in the Options bar add values for width and height of 1 and 1.  Don't try and specify units.  Just type 1 in the first field, tab to the next, and enter another 1.  This will give you a square crop with a pixel dimension of the images shortest side.
    I suspect this might work, so do give it a try.

  • Window Position & Prefs "Gone"

    Every time I start up or restart, any window position, size, view etc info is gone, and I get a view very different than what I had set. I have tried to delete the Finder plist, but it did not help. I did notice something extremely weird as well.
    I noticed that the Finder plist is actually deleting itself about every 30 - 60 seconds when I open the ~user Library prefs, and cannot find anything that might be causing this. Repairing permissions, running utilities such as DiskWarrior etc have not helped. This condition actually exists identically on two Macs I am using. The only thing in common is that I ran an updater for Missing Sync for BlackBerry from Mark/Space Software, and took note of the condition being created on the second Mac immediately after doing this update.
    I don't really want to do a full reinstall of the System, as I suspect I will still end up with this "condition" after reinstalling my working applications.
    Any suggestions would be appreciated.

    A bit of troubleshooting .....
    On a full restart, any windows left open will retain their position, view, etc - but closed windows "forget" when reopened.
    During the safe boots, files were sent to the Trash, which are as follows:
    In a folder called 501.245359984
    and a folder called 501.245361007
    annex_aux
    annex.db
    filetoken.db
    FondResourceCache (only in the first folder above)
    fonts.db
    Local.fcache
    qdfams.db
    System.fcache
    User.fcache
    My startup items under my account are
    iTunesHelper
    Microsoft AU Daemon
    iKey
    MicrosoftMouseHelper
    MicrosoftKeyboardHelper
    Dashboard KickStart
    EEventManager
    iCalAlarmScheduler
    textsoapHelper
    Epson Scanner Monitor
    All of these items were already in place - for a long time - before this problem started.
    I cannot find /private in order to locate /private/var/run/StartupItems
    Nothing unusual (at least that I can see) in either of the other two locations.

  • Box and Size stmt in sapscript

    Hi all
    a very basic question
    can anybody plz tell me whatz the difference between box and size stmt in sapscript
    Thanks in advance

    hi,
       Check this Out.....
       <b>BOX, POSITION, SIZE</b>: Boxes, lines, shading
    The BOX, POSITION and SIZE commands are for drawing boxes, lines and shadows. These commands can be used to specify that within any particular layout set, window or passage of window text can be output in a frame or with shadowing.
    The SAP printer drivers that are based on page-oriented printers (the HP LaserJet PCL-5 driver HPLJ4, the
    Postscript driver POST, the Kyocera Prescribe driver PRES) employ these commands when creating output. Line printers and non-supported page-oriented printers ignore these commands. The resulting output may be viewed in the SAPscript print previewer.
    Syntax:
    1. /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
    2. /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
    3. /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
    <b>BOX</b>
    Syntax:
    /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
    Effect: draws a box of the specified size at the specified position.
    Parameters: For each parameter (XPOS, YPOS, WIDTH, HEIGHT and FRAME), both a measurement and a unit of measure must be specified. The INTENSITY parameter should be entered as a percentage between 0 and 100.
    •&#61472;XPOS, YPOS: Upper left corner of the box, relative to the values of the POSITION command.
    Default: Values specified in the POSITION command.
    The following calculation is performed internally to determine the absolute output position of a box on the page:
    X(abs) = XORIGIN + XPOS
    Y(abs) = YORIGIN + YPOS
    •&#61472;WIDTH: Width of the box.
    Default: WIDTH value of the SIZE command.
    •&#61472;HEIGHT: Height of the box.
    Default: HEIGHT value of the SIZE command.
    •&#61472;FRAME: Thickness of frame.
    Default: 0 (no frame).
    •&#61472;INTENSITY: Grayscale of box contents as %.
    Default: 100 (full black)
    Measurements: Decimal numbers must be specified as literal values (like ABAP/4 numeric constants) by being enclosed in inverted commas. The period should be used as the decimal point character. See also the examples listed below.
    Units of measure: The following units of measure may be used:
    •&#61472;TW (twip)
    •&#61472;PT (point)
    •&#61472;IN (inch)
    •&#61472;MM (millimeter)
    •&#61472;CM (centimeter)
    •&#61472;LN (line)
    •&#61472;CH (character).
    The following conversion factors apply:
    •&#61472;1 TW = 1/20 PT
    •&#61472;1 PT = 1/72 IN
    •&#61472;1 IN = 2.54 CM
    •&#61472;1 CM = 10 MM
    •&#61472;1 CH = height of a character relative to the CPI specification in the layout set header
    •&#61472;1 LN = height of a line relative to the LPI specification in the layout set header
    Examples:
    /: BOX FRAME 10 TW
    Draws a frame around the current window with a frame thickness of 10 TW (= 0.5 PT).
    /: BOX INTENSITY 10
    Fills the window background with shadowing having a gray scale of 10 %.
    /: BOX HEIGHT 0 TW FRAME 10 TW
    Draws a horizontal line across the complete top edge of the window.
    /: BOX WIDTH 0 TW FRAME 10 TW
    Draws a vertical line along the complete height of the left hand edge of the window.
    /: BOX WIDTH '17.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15
    /: BOX WIDTH '17.5' CM HEIGHT '13.5' CM FRAME 10 TW
    /: BOX XPOS '10.0' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
    /: BOX XPOS '13.5' CM WIDTH 0 TW HEIGHT '13.5' CM FRAME 10 TW
    Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section.
    POSITION
    Syntax:
    /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
    Effect: Sets the origin for the coordinate system used by the XPOS and YPOS parameters of the BOX command. When a window is first started the POSITION value is set to refer to the upper left corner of the window (default setting).
    Parameters: If a parameter value does not have a leading sign, then its value is interpreted as an absolute value, in other words as a value which specifies an offset from the upper left corner of the output page. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value. If one of the parameter specifications is missing, then no change is made to this parameter.
    •&#61472;XORIGIN, YORIGIN: Origin of the coordinate system.
    •&#61472;WINDOW: Sets the values for the left and upper edges to be the same of those of the current window (default setting).
    •&#61472;PAGE: Sets the values for the left and upper edges to be the same as those of the current output page (XORIGIN = 0 cm, YORIGIN = 0 cm).
    Examples:
    /: POSITION WINDOW
    Sets the origin for the coordinate system to the upper left corner of the window.
    /: POSITION XORIGIN 2 CM YORIGIN '2.5 CM'
    Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.5 cm from the upper edge of the output page.
    /: POSITION XORIGIN '-1.5' CM YORIGIN -1 CM
    Shifts the origin for the coordinates 1.5 cm to the left and 1 cm up.
    <b>SIZE</b>
    Syntax:
    /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
    Effect: Sets the values of the WIDTH and HEIGHT parameters used in the BOX command. When a window is first started the SIZE value is set to the same values as the window itself (default setting).
    Parameters: If one of the parameter specifications is missing, then no change is made to the current value of this parameter. If a parameter value does not have a leading sign, then its value is interpreted as an absolute value. If a parameter value is specified with a leading sign, then the new value of the parameter is calculated relative to the old value.
    •&#61472;WIDTH, HEIGHT: Dimensions of the rectangle or line.
    •&#61472;WINDOW: Sets the values for the width and height to the values of the current window (default setting).
    •&#61472;PAGE: Sets the values for the width and height to the values of the current output page.
    Examples:
    /: SIZE WINDOW
    Sets WIDTH and HEIGHT to the current window dimensions.
    /: SIZE WIDTH '3.5' CM HEIGHT '7.6' CM
    Sets WIDTH to 3.5 cm and HEIGHT to 7.6 cm.
    /: POSITION WINDOW
    /: POSITION XORIGIN -20 TW YORIGIN -20 TW
    /: SIZE WIDTH +40 TW HEIGHT +40 TW
    /: BOX FRAME 10 TW
    A frame is added to the current window. The edges of the frame extend beyond the edges of the window itself, so as to avoid obscuring the leading and trailing text characters.
    Regards,
    Santosh

Maybe you are looking for

  • RFC issue in Triggering workflow

    Hi, I am trying to trigger a custom workflow from EP in Newly set up ECC 6.0 system. Problem here is, Business object Event is getting triggered in R/3 with custom workflow as reciever, but the workflow is not going to the first stepThe event trace (

  • When I open Adobe Premier I get an Error 400

    It opens a box stating: ERROR Photoshop.com services are currently unavailable. Please try again later or check your network connections. Error 400. How do I fix it so that doesn't Pop-up? Thanks for any help! 

  • Unable to create To Do from Inbox email

    I often use the To Do function to create a reminder based upon e-mails in my Inbox. I select some summary text (a few words) in the email, and then click the "To Do" button in the toolbar. However for some reason, I an now unable to do so with messag

  • Creating user defined table

    how make new table as i need in sap b1 and also tell me how to insert update data in that table thanks and regards Parag

  • One usb port stopped working today

    One of my USB ports stopped working today. I think it may be related to Itunes update today. Has anyone else seen this recently? I restarted my computer - but that didn't help. I have a MacBook Pro - running Lion 10.7.5 Any suggestions? I saw one USB