Getting Panel's size

Hi,
I'm displaying an image in my application using JPanels and Jlabesl.
I have a screen which has a main panel which contains 3 more panels.In two of these , I add few buttons and texts.But the 3rd panel which will contain the image later,is empty.Can I get the size of this 3rd panel (remaining size on the screen after I have placed all components on the other two panels) ? So that I can resize my image to fit this panel.
Rightnow I can see the image but it appears bigger than the panel and scrollbars appears.I don't want that.
Also I don't want to set the 3rd panel to any specific size.
Can anyone provide few pointers????

ImageIcon pic = new ImageIcon("yourimage.jpg");
ImageIcon viewpic;
JLabel label;
int width = yourPanel.getWidth();
int height = yourPanel.getHeight();
if(pic.getIconWidth() > width && pic.getIconHeight() > height) {
viewpic = new ImageIcon(tmp.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT));
label = new JLabel(viewpic, "text if any");
viewppic - refitted picture
pic - original picture size
** Add a panel to the place wher you are placing your JLabel.
like this
|/area 1////| area2////| area3/////|
|/area 4 //////////////////////////|
|/|------------------------------|/|
|/| area 5 ////*yourPanel////////|/|
|/-------------------------------- |
------------------------------------

Similar Messages

  • How do I get correct text size in MM

    Hi all
    (Illustrator CS4)
    One thing has been puzzling me while using Illustrator. If I am given a job and it says the text needs to be 2mm high how do I do this? If I type 2mm into the character tool the size of the text when turned into paths is actually 1.444 mm?! Is there any way of getting text in exact mm without guess work!
    Regards
    Matthew

    Hi everyone,
    this topic has already been answered, but I didn't find the method I've come to use mentioned.
    There are two ways I use to do this, both with the same results in sizing.
    #1:
    If I don't need editable type at all, I just create outlines out of everything and change the height.
    This works if you don't need the font-size and want every letter to fit into a rectangle with the same height.
    #2:
    By adding a Live Effect in the Appearance-panel, you can achieve the same results as you do with create outlines, but with the added bonus of getting the font-size and you can even choose just one letter to set the height by.
    I choose Path > Outline Object in the Appearance-panel, followed by typing in whatever mm I want in the transform panel, not the font size. Then I clear the appearance.
    By turning on the bounding box you can also see what's happening. When you create outlines from type, the bounding box
    will "hug" the letters tightly and not use the usual upper/lower-case bounding box.
    If the customer knows what letter he wants to be exactly measured, I use this method first and save the font-size that comes up and write with it.
    Hope this helps someone out there, it works for me.
    -Asbjørn

  • How do you change the capture dimensions in the Get Panel Image VI

    My objective is to capture the front panel image to a JPEG file. I want to be able to alter the dimensions of Front Panel Image so I can exclude certain areas of the front panel. I am using the GET PANEL IMAGE.VI and the WRITE JPEG FILE.VI. I have tried using a Cluster structure from the bounds property of the GET PANEL IMAGE.VI to feed into the "rect" property of the WRITE JPEG FILE.vi however as soon as I alter the dimensions from the original dimensions it fails to save the panel image to file. Is this actually possible, or does LabVIEW restrict users from altering the panel capture dimensions? Or is this a known bug in LabVIEW v6.0?

    Hi,
    Here is a zip file containing two VIs.
    'Change Control Value.vi' when run will load the VI 'Demo.vi'. It will alter its size and the run demo.vi.
    On the front panel or demo.vi, press the Update button and the image will be written to c:\temp.
    All a bit crude but the mechanism works in labview 5.1.1. (Unfortunately I haven't got version 6.0.2 installed yet.)
    Regards
    Ray.
    Regards
    Ray Farmer
    Attachments:
    demo.zip ‏33 KB

  • Accordian Panel content size

    Hi,
    I am using Accordian Panel in several pages. When I go to CSS styles paneland and change Accordion Panel content size/height to 600 for example, it changes all the Accordian panels throughout my site to 600.
    Is there a simple way of changing each panel individually.Am I missing something very obvious. I am learning CSS but not quite there yet. Any help would be appreciated.
    Michael

    To start with, especially when you are a novice at CSS, do not alter the original Spry Style Sheets. You will thank me for this tip once you get into more complicated web sites.
    To have variable panel heights use the following constructor
    <script type="text/javascript">
    var acc1 = new Spry.Widget.Accordion("Acc1", { useFixedPanelHeights: false });
    </script>
    If you want fixed heights per accordion then you have numerous options of which I will show one. Apply a unique ID to your accordion and style accordingly has follows.
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryAccordion.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryAccordion.css" rel="stylesheet" type="text/css">
    <style>
    #Accordion600 .AccordionPanelContent {
        height: 600px;
    </style>
    </head>
    <body>
    <div id="Accordion600" class="Accordion" tabindex="0">
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Label 1</div>
        <div class="AccordionPanelContent">Content 1</div>
      </div>
      <div class="AccordionPanel">
        <div class="AccordionPanelTab">Label 2</div>
        <div class="AccordionPanelContent">Content 2</div>
      </div>
    </div>
    <script type="text/javascript">
    var Accordion1 = new Spry.Widget.Accordion("Accordion600");
    </script>
    </body>
    </html>

  • Help ...how to get the file size on a server

    Hi.I use this code to parse a file that is on a server.
    The question is: how can i get the file size (bytes size)?
    Thanks.
    //Open the file for reading:
    URL u = new URL(entry);
    InputStream inputXML = u.openStream();
    //Build document:
    DocumentBuilder builder = factory.newDocumentBuilder();
    doc = builder.parse(inputXML);

    Try this instead:
    URL u = new URL(entry);
    URLConnection conn = u.openConnection();
    // get the file size
    int size = conn.getContentLength();
    // open the input stream from the URLConnection (which is functionally the same as opening it directly from the URL)
    InputStream inputXML = conn.getInputStream();
    Shaun

  • How do I get the byte size of a server file before sending output via HTTP?

    I need to get the byte size of the file prior to streaming it. I can't seem to find a class/method I need. Basically, I have the path c:\\tomcat\\webapps\\documents\\sample.pdf in the servlet, I was hoping I could just use something from the File class but I couldn't find anything that seems to do the trick?
    thanks, in advance,
    Chuck

    maybe the source of the problem will help...I am trying to stream a PDF to IE and a blank page is being generated although all other file type work.
    I have found a lot of answers in the forum but no specific code examples. Here's what I have so far from picking through threads in here (can someone please show me how to get the byte size of the file so that I can assign it to the method response.setContentLength();?):
    String CONTENT_TYPE = " ";
         String target = " ";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         StringBuffer buf = new StringBuffer();
         HttpSession session = request.getSession();
         String file = request.getParameter("filename");
         target = file;
         int end = file.length();
    int beg = end-2;
         String type = file.substring(beg, end);
         if (type.equals("DOC")){
              CONTENT_TYPE = "application//vnd.msword";
         }else if (type.equals("XLS")){
              CONTENT_TYPE = "application//vnd.x-excel";
         }else if (type.equals("PPT")){
              CONTENT_TYPE = "application//vnd.ms-powerpoint";
         }else if (type.equals("PDF")){
              CONTENT_TYPE = "application//vnd.x-pdf";
         }else if (type.equals("MPP")){
              CONTENT_TYPE = "application//vnd.ms-project";
         }else if (type.equals("ZIP")){
              CONTENT_TYPE = "application//ZIP";
         }else if (type.equals("TXT")){
              CONTENT_TYPE = "text//plain";
         }else {
              CONTENT_TYPE = "text//html";
         //File f = new File(file);
         //int l = f.length();
         response.setContentLength(l); <----- supposedly this fixes my problem but I don't know how to get the byte szie of the file in an integer??
         // reset the response
         response.reset();
         response.setContentType(CONTENT_TYPE);
         try{
         // Get streams
         FileInputStream fileInputStream = new FileInputStream(target);
         ServletOutputStream servletOutputStream = response.getOutputStream();
         // Init byte count and array
         int bytesRead = 0;
         byte byteArray[] = new byte[4096];
         // Read in bytes through file stream, and write out through servlet stream
         while((bytesRead = fileInputStream.read(byteArray)) != -1) {
         servletOutputStream.write(byteArray, 0, bytesRead);
              servletOutputStream.flush();
         // Flush and close streams
         servletOutputStream.flush();
         servletOutputStream.close();
         fileInputStream.close();
         } catch (Exception e) {
         System.out.println(e.toString());

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • How can I get my brush size to appear in Photoshop CC?

    I just upgraded to Photoshop CC and I cannot see my brush size, especially when I make the brush size larger.  A small circle appears when the brush is very small, but at larger sizes it disappears such that I have to guess at my brush size, which does not work when using the healing tool or brush tool.  I especially have problems when I zoom into the photo at 100% or more.  I can only see a crosshair, but I would like to get the circle size back.  I have tried several things, which have not worked, including making sure the caps lock is off and changing my preferences->cursors->normal brush tip.  Any suggestions???  Thanks.

    What OS are you running?
    Per thread on feedback.photoshop.com
    Photoshop: Brush cursor bug on retina iMac running OSX 10.10 Yosemite
    Resetting your prefs might fix this.

  • I want to use Get Panel Image in Labview 5.0.1 and need details on how to save the BMP data generated

    I am trying to generate an application that saves a copy of its front panel on completion. This is easy to do using an invoke node with Print VI to HTML but this does not work in an .exe format. I have seen elsewhere that you have to use the Get Panel Image method, but no details are supplied in LV 5.0.1 documentation of how to use the "image" data (1-D Unsigned Byte array) that is generated. I want to save this in a format that can then be read as a bitmap in any standard graphics package. Any assistance?

    Hi,
    If you'd upgrade to LV5.1 or 6 you could use the 'standard' vi's for this.
    You need a VI called "Write BMP File.vi". It's not shipped with LV5.0.1.
    This vi only uses 3 subVI's, so perhaps someone at NI can convert it and
    send it to you (sorry, I won't, it's copywrited).
    If you cannot get this VI anywhere, you'll need to figure out the BMP file
    format yourself. It's not too complicated, but still could take some days.
    Perhaps someone figured it out before LV5.1 was released.
    Regards,
    Wiebe.
    "RDK" wrote in message
    news:[email protected]..
    > I want to use Get Panel Image in Labview 5.0.1 and need details on how
    > to save the BMP data generated
    >
    > I am trying to generate an application that saves a copy
    of its front
    > panel on completion. This is easy to do using an invoke node with
    > Print VI to HTML but this does not work in an .exe format. I have seen
    > elsewhere that you have to use the Get Panel Image method, but no
    > details are supplied in LV 5.0.1 documentation of how to use the
    > "image" data (1-D Unsigned Byte array) that is generated. I want to
    > save this in a format that can then be read as a bitmap in any
    > standard graphics package. Any assistance?

  • Getting the page size in PDF file

    i want know how do get the page size in PDF file befor placing every page in document
    for example height=297 mm And width=210mm

    This script:
    http://indesignsecrets.com/zanelli-releases-multipageimporter-for-importing-both -pdf-and-indd-files.php
    answers all your questions.
    Peter

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Can't get panels and preferences to save with MacBook Pro

    I can not get panels and preferences to save using Illustrator CS6 on a MacBook Pro. When I close out of AI the settings/preferences don't stay. Please help.
    Thank you
    Dan

    Have you tried rebuilding preferences?
    Working in a new user account?
    Workspaces are saved in your local user folder. If workspaces are not saved, this could be problems with either Illustrators preferences in general or your user account.

  • Getting the page size and knowing how many pages they are in PDF file

    Hi There,
    when i do this script (
    var myPDFFile = File.openDialog(["Choose a PDF File"]); ) 
    with JS via Windows it is used for opening a new PDF file when i import this file i need to
    get the page size and how many pages they are in PDF file. but i dont know how to do it.
    please help me.

    Ask here: http://forums.adobe.com/community/indesign/indesign_scripting

  • [JS CS5]How to get Custom Page size

    I've been searching the answer of this simple question but looking no way around.
    I have an InDesign document with different page size e.g. left page width is 621 pt. and on the same document right page width is 837 pt.
    Now I need to get the width of pages using script but app.documentPreferences.pageWidth return standard document preset size(621 pt.) not the custom page size.
    Does any one have the Idea to get custom page size using script.
    Thanks in advance
    Mac

    Mac,
    as documentation is showing there are some new properties of "page" since InDesign CS5.
    Among those is:
    bounds    Array of Measurement Unit (Number or String)    readonly    The bounds of the Page, in the format [y1, x1, y2, x2].
    So:
    myPage.bounds
    and pageWidth of the documentPreferences might be:
    myPage.bounds[3]-myPage.bounds[1]
    unless  myPage is transformed (e.g. rotated and/or sheared and/or scaled) with:
    myPage.transform()
    void transform (in: CoordinateSpaces, from: varies, withMatrix: varies[, replacingCurrent: varies][, consideringRulerUnits: bool=false])
    Transform the page item.
    var d = app.activeDocument;
    var myPage = d.pages[0];
    var oldPB = myPage.bounds;
    var rAngle = -45;
    var sAngle = 40;
    var myTransformationMatrix1 = app.transformationMatrices.add({counterclockwiseRotationAngle:rAngle});
    myPage.transform(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransformationMatrix1);
    var myTransformationMatrix2 = app.transformationMatrices.add({clockwiseShearAngle:sAngle});
    myPage.transform(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransformationMatrix2);
    var newPB = myPage.bounds;
    $.writeln(oldPB);
    $.writeln(newPB);
    Now oldPB and newPB will differ a lot.
    So, the question remains: what is a reliable way to show if the myPage was or was not transformed against documentPreferences.pageWidth or if  myPage is of rectangular shape at all. See the possibility of adding a sheer angle to the transformation matrix. Also see screen shot:
    Transform_Page_CS5.png
    Uwe

  • How to get Systemstate Backup size using PowerShell command in Windows 2008 R2

    Hi,
    We using WBSummary command to get completed backup status.
    I need to find how much data is backed up  using powerShell command .
    Is there any way to get the details , i can see the GUI but no in command.
    Please advise
    Regards Gopi K

    Hi,
    You mentioned that you can see the system state backup size in the GUI. Does the backup size mean the amount of date transferred?
    It seems that there is no such a PowerShell to get Systemstate Backup size. You may need to you need a PowerShell scripts to do this work.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=ITCG
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • IPod connected, however, it does not function properly

    The iPod I have is the 60gb. I have had problems with my iPod previously since the 2006-3-23 update but fixed it. -Delete all files manually from iPod -Uninstall iTunes, iPod, and all applications associated with the programs within the installation

  • Advance Receipt issue

    Dear Sapgurus, If any customer advance paid 1000 rs i wna t go to customer account 1000 rs and advance royalty 900 and service tax is 100 but in advance roaylty i will give 1000 rs only. Regards Hanuman

  • Transfer Profile

    Hi Everyone, While I was creating activity for transfer profile it gives error saying 'Transfer to R/3 using mixed periodicities is not allowed'. And I am using 9ADP as periodicity. Now I changed the time bucket profile to accomodate days in it. Afte

  • Any way to share my 1520's screen with TV?

    Hello to all. I've just downloaded zumba dance on my L1520. Its awsome however screen is small to put phone somewhere and dance. Do you know anyway to share my screen with TV or Notebook? As far as i know L1520 doesnt have hdmi port unlikely Currentl

  • How to change output precision of DAQ to waveform chart and to spreadsheet

    Refer vi attached, the DAQ connects to a waveform chart to a spreadsheet. I want to change the precision of the DAQ assistant output from 6 decimal places to 2 decimal places, but everywhere i searched on the DAQ assistant i cannot find a precision s