How to find JFrame border width?

Hi, I need to find out the left & right border widths of a JFrame. This is easy if I have an existing object (assuming it's been painted at least once).
The border width may vary depending on the current look & feel, whether running on windows or the MAC, etc.
I want to find out this value without creating an instance of JFrame. So I thought I'd try the UIManager, and I thought I'd need something like this:
javax.swing.border.Border b = javax.swing.UIManager.getBorder("InternalFrame.border");But of course that's for InternalFrames, not JFrames.
I can't figure this out - any ideas?
Thanks, TL
PS. Plse don't ask why I need to know this width ;-)

So why do you need to know those widths?
sigh
Ok, like I said in my original post I really want to be able to do this. I'm disappointed that there's mostly questions 'why do you want to know' rather than workable solutions to the problem.
What say I wanted to have a console application to give me all these values, for the current platform and look & feel? Pretty ugly momentarily popping up a JFrame so I can get these widths.
But anyway here's the reason and I'm bracing for the inevitable 'you should not do that'.
I want to choose the size of some components to go on a panel (and if you draw it with some initial defaults and repaint immediately after the first draw, it looks pretty ugly).
We have a JList with a custom row renderer - each row has a number of columns in it, each to be defined as a percentage of the total width, so the renderer is a JPanel with all these things on it. (For several reasons a JTable was not appropriate, not the least of which the data needs to be displayed and manipulated as a list... although the underlying data IS in a TableModel.)
I literally spent days trying to make the custom row renderer work as we needed it, using standard layouts - tried gridbaglayouts, but this doesn't support percentage widths (the weighting factors are a hindrance if there's no text in one column but lots in another, etc); other layout managers such as a box layout nicely give me a number of columns, but they are all equally spaced (no good if you want one to be 10% of the total width, and the next to be 50%...). And so the issues go on with the other standard layouts.
Anyway, none of the standard java layout managers would do what we wanted and I didn't find one on the 'net to fit the job (at least not one under LGPL) - unless I missed one. So we resorted to absolute positioning. This works perfectly, and we also listen for window resize events - that works very well also. The trouble is, when INITIALLY sizing a column, we need to make it a percentage of the width. What is the 'useable width'? When we initially construct the window we know how big we're making the it, and if the frame is maximised then that's easy, the left & right borders are zero width. However that's under XP and with the current look & feel, so it isn't guaranteed. Similarly it the initial window size is not full-screen, there are most likely some borders, so how wide are they?
Right, the best suggestion so far is for the use of pack(). We generally don't need to do this as we have a set of core frame classes which manage their sizes (and do it consistently throughout the application), and don't use pack(). However in this case, calling pack() before adding all the components of the JPanel will populate the border widths if applicable. However some changes I've just made to accomodate some MAC quirks means that a resize event occurs on startup anyway, and this seems to have largely solved the problem.
However, I'd still like to know the answer to my original question. And I thought the answer may lie in asking the UIManager, but haven't found a setting in there for this purpose...

Similar Messages

  • How to Find the band width of a Network

    Hi All
       I have placed my WAS in the External network.I have communication with that server.Now i want to find the Band  width of that network.

    Hi Sunil,
    You can use several online and offline(of course) tools to test the network bandwidth that you are in.
    Please go through the following web sites for various such tools,
    http://compnetworking.about.com/od/speedtweaks/l/aa021902a.htm
    http://reviews.cnet.com/7004-7254_7-0.html
    http://www.pmasoft.net/englisch/oe/now%20to%20test%20network%20bandwidth.htm
    http://www.testmy.net/
    Hope these help,
    Guru.
    PS: Reward points for replies.

  • How we can change JFrame Border Color Not Background.

    How we change jframe border color not background
    if any body know about that then plz tell me
    at this [email protected]
    i m thanksfull to ..... .

    hi Shafr
    beleive it or not, i got it using trial and error. i keep
    trying words in the function setStyle until the color changed. i
    dont know why it is not documented.
    var periodBarColor:SolidColor = new
    SolidColor(taskSchedColorChooser.selectedColor, 1);
    periodBar.setStyle("fill",periodBarColor);
    //where taskSchedColorChooser is colorPicker component. you
    can replace it by any color you want

  • How do you change/adjust border width for all the cells in a table created in Pages?

    How do you change/adjust border width for all the cells in a table created in Pages?
    Note- I am trying to figure out how to create and format tables in the latest version of the Pages app on an iPad air (iOS 8.1.1.1) . Creating tables, adding or removing borders for individual/all cells in a table seems straight forward. However the default border style seems to be a heavy black line. How do I change this?
    I found the option add or remove borders for all/ individual cells in a table, however I can't find any option within style/format dialogue screens for changing colour or line thickness for table cells. Likewise I can't find any clear instructions on how to do this in apple help pages or support website
    Btw- I'm assuming  it is possible to customize/adjust the colour & thickness of selected lines in a table created in this app (it's fairly easy to do this word processing apps like MS Word) please let me  know if this is not actually possible in Pages

    They know perfectly well what they took out of Pages '09.
    Well over 90 features.
    Do you think you posting feedback is going to remind them of what they did?
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5 and rate/review it in the App Store, then get back to work.
    Peter

  • Can I find the -fx-border-width applied to my component programatically?

    I want to render some content outside of the border, but directly adjacent to it, and I want the border to by styled independently of the code that lays out that content. (In a CSS file done by a graphic designer)
    If I could find the value of the -fx-border-width or -fx-backround-insets I coudl use it to adjust the translation of the Node that I wish to butt up against the side of the Pane with the border.
    Is there a way?
    I notice that all of the getters for things like insets, padding, margins, etc. do not return anything other than 0's or null

    I would rather avoid 3rd-party layouts. StakePane has issues with eating all the MouseEvents, and I don' tree how it would relate to this problem anyway.
    A border style on the Text node to simulate the border of the containing box won't work. The containing box has rounded corners on it's border.
    How would a GridPane solve the problem? I would still need to position the Arc (which is filled) against the border.. the alignment of the Arc with the Text is so far not a problem.
    These filled arcs with text are points where connections between blocks can be made, in a diagram not unlike a UML diagram. The blocks have labelled connection points (the text with arc) on each side of the block (the container with the border). The connections are drawn as paths from an arc on one block to an arc on another block. I want the look to be described as much as possible in the CSS style sheet. If the Text is made larger, the filled arcs remain aligned. If the border is made thicker, the arcs remain adjacent to it. etc.
    I may be able to compute the correct offset by comparing BoundsInLocal coordinates to see how the Text node is inset, but it is tricky.

  • How to change border width for a table in pages app

    I am using latest version of the Pages app on an iPad air (iOS 8.1.1.1) . How do you change/adjust border width for all the cells in a table created in this app?
    I found the option add or remove borders for all/ individual cells in a table.
    I can't find any option in style/format dialogue screens for changing colour or line thickness for table cells.
    How do you change/adjust border width for all the cells in a table I can't find any option to adjust colour or default w
    The built in help doesn't explains

    Unfortunately, once you make the copy, the only way to remap the items that it references is to do it manually.
    However, in the extended copy wizard, you do get a chance to keep this from happening at the time the copy is made. By default, as you've learned, the new copy wants to continue to reference the items that the old copy referenced.
    But there are two other options, which are selectable for each of the referenced items. The checkmark will be on "Leave" - i.e. leave the references as is. You can check "Copy", which will make a copy of the referenced item and point the reference at the copy. Or you can check "Remap", which will re-map the reference to a different existing item. Remap will lead you to another screen, where you can choose what existing item each remapped item will now reference.

  • How to find out which plugin is missing ( embed width="100%" height="100%" messagecallback="parent.frames.MANIPULATIONS.AppendMessage" spinfps="15" spiny="30")?

    How to find out which plugin is missing fro mthe website: http://web.it.nctu.edu.tw/~twli/interactive/scr_tutf.htm?
    After looking at one similar question found in mozilla support and answered by jscher2000 (https://support.mozilla.org/en-US/questions/957655), I have found out I have to look for either <object or <embed. What I found is : <embed width="100%" height="100%" messagecallback="parent.frames.MANIPULATIONS.AppendMessage" spinfps="15" spiny="30"
    What do I have to do now?

    This big1.mol (and possibly big2.mol) file is loaded in the embed plugin object that is opened in a iframe, so you can right-click the plugin area to check the embed code.
    *http://web.it.nctu.edu.tw/%7Etwli/interactive/big1.mol
    *http://web.it.nctu.edu.tw/%7Etwli/interactive/big2.mol

  • How do I change the border width of a table column?

    Hi I am using Studio Edition Version 11.1.1.3.0.
    I want to set the border width of columns inside an af:table to something different than the default still haven´t found a way to do this. I have tried setting Border Width property in Style tab of the column but it has no effect. I would apprciate if someone could tell me how to do this or point to some tutorial or blog where I can see how this is done.

    I tested it a little more and it seems like what I did is working on normal columns and the reason it isn´t working in my case is because I have two grouping columns (that is two columns containing other columns) and on those columns code like
    <af:column sortProperty="BillRef" sortable="true" headerText="#{bindings.Bill.hints.BillRef.label}"
    id="tblBillC1" width="85" inlineStyle="border-width:2.0px; border-color:Red;">
    has no effect for some reason.
    It is the group columns borders that I want to make a little wider so that it is easyer for the user of the table to see the where the table is split into groups.
    I will make an example to better descibe what I want to achieve.
    If you look at the code below and observe what is achieved when it is run you will see that the borders of the inner columns become green and 10px while the outer columns don´t get blue and 20px and it is the outer columns border that I want to change.
    <af:table >
    <af:column headerText="Sosial eyðmerking" id="sosCol" align="center"
    inlineStyle="border-color:Blue; border-width:20.0px;">
    <af:column sortProperty="something"
    headerText="something" id="c5"
    inlineStyle="border-color:Green; border-width:10.0px;">
    <af:outputText value="something" id="ot2"/>
    </af:column>
    <af:column headerText="#something" id="c7">
    <af:outputText value="something" id="ot3"/>
    </af:column>
    </af:column>
    <af:column headerText="Rokn eyðmerking" id="roknCol" align="center"
    inlineStyle="border-color:Blue; border-width:20.0px;">
    <af:column sortProperty="something"
    headerText="something" id="c8" filterable="true"
    inlineStyle="border-color:Green; border-width:10.0px;">
    <af:outputText value="something" id="ot4"/>
    </af:column>
    <af:column headerText="#something" id="c9">
    <af:outputText value="something" id="ot5"/>
    </af:column>
    </af:column>
    /af:table>

  • How to change the combobox's border width

    Hi all,
    I am using JDeveloper 11.1.1.1.0 and ADF Faces.I want to change the border width of combo box.I tried to apply " border-width:0.0px; " in content style and inLine style.But no hope.
    <af:selectOneChoice label="Label 1" id="soc2"
    contentStyle="border-width:0.0px;">
    <f:selectItems value="#{Temp.superintendent}" id="si2"/>
    </af:selectOneChoice>
    Edited by: Dinil Mithra on Oct 16, 2009 2:44 AM

    Hi,
    a skin for this is
    af|inputComboboxListOfValues{
    border-style: solid;
    border-width: 0px;
    If you want to get rid of the inner border, you use
    af|inputComboboxListOfValues::container,
    af|inputComboboxListOfValues::content,
    af|inputComboboxListOfValues::dropdown-cell{
    border-width: 0px;
    Frank

  • How can I find the full width at half-maximum?

    Hello,
    I have run into a problem that I hope you can help me with: I need to find the Full Width at Half-Maximum.
    I have an array of pixel intensities and have found the peaks and valleys using Peak Detector.vi, but I can not figure out a way to find the full width at half-maximum (the width of the 'hill' at one-half of its maximum point).
    Any help you may provide would be greatly appreciated.
    Jared Leisner
    - Using LabVIEW 6.1/Vision 6.0

    Jared,
    I had the same problem. One of the solutions I used was to use the was to
    use "threshold 1D array.vi" from the array palette. You can use this to
    iteratively get the uphill edge of the peak. To get the down hill edge, you
    have to invert the array and then use the same VI. Then subract the uphil
    position from the down hill position and your done.
    You do however need to be careful depending on your image content. If the
    image is noisy, then the "Peak Detector.vi" will have problems finding the
    "real peak".
    Steven Bloomberg
    CISTech
    "Jared Leisner" wrote in message
    news:[email protected]..
    > Hello,
    >
    > I have run into a problem that I hope you can help me with: I need
    > to find the Full Width at
    Half-Maximum.
    > I have an array of pixel intensities and have found the peaks and
    > valleys using Peak Detector.vi, but I can not figure out a way to find
    > the full width at half-maximum (the width of the 'hill' at one-half of
    > its maximum point).
    > Any help you may provide would be greatly appreciated.
    >
    > Jared Leisner
    > - Using LabVIEW 6.1/Vision 6.0

  • How to find JPanel viewable or drawing area size

    hi,
    I have a two small question. First one is, I have a JPanel what I need is to find the viewable area size or the drawing size of the Panel. I don't want to get the size of the Title bar. All I need is how to find the actual drawing area not including the title bar. I know how to get the total size of the JPanel, I just needs to know how to get the drawing area size where you put your components. e.g. if the size of my Panel is (300,300) then it also includes the title bar and the border too. But I need to find or get only the area size where we actually put our components.
    Another question is how can I get the size of my Title bar means the width and height.
    I'll really appreciate for any help
    Thanks

    Er... what's wrong with panel.getSize()?

  • Image Processing - How to find a pixel cordinates in iOS ?

    Hi,
    I want to know how to find the cordinates of the pixel which i am chaging.
    Here is what i am doing.
    CGImageRef imgSource = self.ImageView.image.CGImage;
        CFDataRef m_DataRed1 = CGDataProviderCopyData(CGImageGetDataProvider(imgSource));
        CGFloat myheight;
        CGFloat mywidth;
        myheight= CGImageGetHeight(imgSource);
        mywidth = CGImageGetWidth(imgSource);
        UInt8 *dataOrignal = (UInt8 *)CFDataGetBytePtr(m_DataRed1);
        double lenghtSource = CFDataGetLength(m_DataRed1);
        NSLog(@"lenght : %f",lenghtSource);
        int bytesPerPixel_ = CGImageGetBitsPerPixel(imgSource)/8;
        size_t bytesPerRow = CGImageGetBytesPerRow(imgSource);
        NSLog(@"height = %f, width = %f, bytesperPixel = %d",myheight,mywidth,bytesPerPixel_);
        for(int x = 0; x < myheight; x++)
            for(int y = 0; y < mywidth; y++)
                int pixelStartIndex = bytesPerPixel_*((bytesPerRow*x)+y);
    //            if (pixelStartIndex <= lenghtSource) {
                    UInt8 alphaVal = dataOrignal[pixelStartIndex];
                    UInt8 redVal = dataOrignal[pixelStartIndex + 1];
                    UInt8 greenVal = dataOrignal[pixelStartIndex + 2];
                    UInt8 blueVal = dataOrignal[pixelStartIndex + 3];
                    if(redVal == 236 || alphaVal == 236 || greenVal == 236)
                        dataOrignal[pixelStartIndex] = 255;
                        dataOrignal[pixelStartIndex +1] = 0;
                        dataOrignal[pixelStartIndex +2] = 0;
                        dataOrignal[pixelStartIndex+3]= 255;
                        NSLog(@"x %d, y = %d, index = %d", x, y,pixelStartIndex);
        NSUInteger width = CGImageGetWidth(imgSource); //202
        NSUInteger height = CGImageGetHeight(imgSource);//173
        size_t bitsPerComponent = CGImageGetBitsPerComponent(imgSource);
        size_t bitsPerPixel = CGImageGetBitsPerPixel(imgSource);
        NSLog(@"the width = %u and height=%u of the image is ",width,height );
        NSLog(@"the bits per component is %zd", bitsPerComponent);
        NSLog(@"the bits per pixel is %zd", bitsPerPixel);
        NSLog(@"the bytes per row is %zd" , bytesPerRow);
        CGColorSpaceRef colorspace = CGImageGetColorSpace(imgSource);
        CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imgSource);
        CFDataRef newData = CFDataCreate(NULL, dataOrignal, lenghtSource);
        CGDataProviderRef provider = CGDataProviderCreateWithCFData(newData);
        CGContextRef context = CGBitmapContextCreate(newData, width, height, bitsPerComponent, bytesPerRow, colorspace, bitmapInfo);
        CGPoint point = CGContextGetTextPosition(context);
        NSInteger xx =  point.x;
    //    point.y;
        NSLog(@"this is the value of x axis %d",xx);
        CGImageRef newImg = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorspace, bitmapInfo, provider, NULL, true, kCGRenderingIntentDefault);
        UIImage *newImage1 = [UIImage imageWithCGImage:newImg];
        self.ImageView.image = newImage1;
    is this the right way to parse the image using x & y ?
    I dont know if the pixelstartIndex is correct or not, but it does change the pixels.
    I want to make sure if the x & y i am NSLogging is correct or not.
    Thanks in Advance

    BufferedImage img = null;
    DataBufferByte imgRasterBuffer = null;
    int imgColors[][];
    URL url = BumpMap1.class.getResource("bumpmap1/img.png");
    try
    img = ImageIO.read(url);
    catch(java.io.IOException x)
    System.out.println(x.getMessage());
    imgWidth = img.getWidth();
    imgHeight = img.getHeight();
    imgRasterBuffer = (DataBufferByte)(img.getRaster().getDataBuffer());
    imgColors = new int[imgWidth * imgHeight][3];
    // Store RGB values into array
    for (int x = 0; x < imgWidth; x++)
    for (int y = 0; y < imgHeight; y++)
    int c = img.getRGB(x, y);
    int loc = y * imgWidth + x;
    imgColors[loc][0] = (c&(255<<16))>>16;
    imgColors[loc][1] = (c&(255<<8))>>8;
    imgColors[loc][2] = c&255;
    if(imgColors[pixX+(pixY*imgWidth)][0] == 0 &&
    imgColors[pixX+(pixY*imgWidth)][1] == 0 &&
    imgColors[pixX+(pixY*imgWidth)][2] == 0)
    // it's black

  • How do I set Page Width to Multiple Pages?

    How do I set Page Width to Multiple Pages?
    I notice when Cross Tabs are used, the report spans over several pages in width. Can I set this option without using a cross-tab? Since I am having trouble finding a paper width that is 100 inches wide, I was thinking of just using multiple pages.
    Thanks,
    Linda

    Hi Linda,
    Try inserting an OLEDB object and select a bitmap and insert a blank bitmap in report header. Now go to preview and right click on OLEDB Object go to format graphic>picture>change the width of the picture
    If the width exceeds more than the width of the page then it create virtual pages.
    Hope this helps!
    Raghavendra

  • How to find out the image size?

    How to find out the image size values(Width and height) in illustrator CS3 using any script. I tried but i got only the document height and width. I need to find out the image BoundingBox value of width and height. Kindly advice me.

    Try this.
    tell application "Adobe Illustrator"
    set heightImage to get height of raster item 1 of current layer of current document
    set widthImage to get width of raster item 1 of current layer of current document
    display dialog (heightImage & " X " & widthImage) as string
    end tell
    JaiMS

  • How do you define the width of a JPanel?

    How do you define the width of a JPanel?

    it may not be perfect but this is what i have tried:
    import javax.swing.*;
    import java.awt.event.*;
    public class myPane extends JFrame {
         public myPane() {
              super("myPane");
              setDefaultCloseOperation.(JFrame.EXIT_ON_CLOSE);
              JButton myButt = new JButton("press");
              JPanel pane = new JPanel();
              pane.add(myButt);
              setContentPane(pane);
         public static void main(String args[]) {
              myPane p1 = new myPane();
              p1.setBounds(20, 20, 600, 400);
              p1.setVisible(true);
    }

Maybe you are looking for

  • Do Not Buy HP Notebooks

    I want to vent my disgust with HP notebook product line. I want to state that I am not the generic user, I have been working in the personal computer industry since 1986.  And, in the mid-90's... I was arepair center supervisor for AST Computer Noteb

  • Disk Utility asked me to Format my MBP!! What to do and HOW!

    Hi guys, I've recently noticed that my Mac takes a bit of time to start anymore, I looked around and I saw that checking my Hard Disk should help by "Verifying" the disk and "Repairing" it if needed. I did it today and I was asked to Repair the disk

  • Importer Process Server

    This is so frustrating. I have done a search for this but none of the posts were helpful as per this: The issue is that there is not even an event log for this crash. Yes I have restarted the computer to no avail. The only solution I have found to to

  • Conversion of Planned Order to Purchase Requisition thro MD04 for Quota Arr

    While converting Planned Order to Purchase Requisition  thro' MD04 for a Quota Arrangement  material, on the screen in the Reference section Purchase org automatically does not default  while for a non Quota Arrangement material it defaults. Need P.O

  • How can I get a cd to eject?  nothing seems to work

    How can I get a cd to eject?  Nothing seems to work