How do i find the visible area...

Hi everyone.
I'm trying to get the size of the visible area of a JFrame, but it keeps returning 0. I use this.contantpane().getsize() . Its because I need a drawing area which occupies a certain area of the contentpane. How can I find the visible area without the toolbar and border around the frame?
Here is my code:
public class CgraphForm extends JFrame implements Runnable {
    private int h = 600; // Height of JFrame
    private int w = 800; // Width of JFrame
    private double pad; // Padding edges size [%]
    private JButton btClose = new JButton();
    private CGUI gui;
    private boolean running = true;
    public CgraphForm(CGUI _gui) {
        // Name of frame send to parent (super) which is the JFrame
        super("Temperature");
        gui = _gui; // Used to enable the applet again
        pad = 0.05 * h;
        System.out.println("GraphForm thread started");
       try {
           jbInit();
       } catch (Exception ex) {
           ex.printStackTrace();
    public void run() {
        // Interrupt makes the thread terminate proberly by ending its run method
        while (running) {
            try {
                Thread.currentThread().sleep(100);
            } catch (InterruptedException ex) {
                running = false;
    private void jbInit() throws Exception {
        setDefaultCloseOperation(DISPOSE_ON_CLOSE); // Disposes the JFrame when its closed
        this.setSize(w,h);
        this.setLocationRelativeTo(null); // Location af JFrame on screen
        this.addWindowListener(new CgraphForm_this_windowAdapter(this));
        Container contentPane = this.getContentPane();
        Dimension size = contentPane.getSize();
        System.out.println(size);
        contentPane.setLayout(new XYLayout());
        // PENDING graphSize mangler et offset paa bredden, sandsynligvis kanten af framen
        Dimension graphSize = new Dimension( (int) (w - 2 * pad),
                                             (int) (h - 0.45 * h));
        JPanel panel = new JPanel;
        contentPane.add(panel, new XYConstraints((int)pad,(int)pad,(int)graphSize.getWidth(),(int)graphSize.getHeight()));
        this.setVisible(true);
        btClose.setText("Close window");
        btClose.addActionListener(new CgraphForm_btClose_actionAdapter(this));
        contentPane.add(btClose, new XYConstraints((int)pad, 500, -1, -1));
}/lars

I need the size to draw my panel.
You shouldn't do. Your panel should be able to draw itself without knowing its size. Assuming your panel is just a plain space which you draw on, that means one of two things: either you make its rendering logic sensitive to its own size (which you can detect in the paint() method) or you can assign it a preferred size and then place it in a JScrollPane to ensure that it can always be viewed. Both of these are fairly straightforward solutions.

Similar Messages

  • HT1918 I don't remember the answers to my security questions. I just got a new iPad and I'm trying to purchase an app and it is asking me these questions. How do I find the answers are reset them.

    How can I find the answers to my security questions or change the answers?

    Welcome to the Apple Community.
    Start here, and reset your security questions, you will receive an email to your rescue address, use the link in the email and reset your security questions.
    If that doesn't help or you don't have a rescue address, you might try contacting Apple through iTunes Store Support

  • How can I find the location of an i-pod shuffle, nano and touch that i have synced to my account? I have had each one stolen and would be so relieved if i could track there location as I know they are still in the county I live.

    How can I find the location of an i-pod shuffle, nano and touch that i have synced to my account? I have had each one stolen and would be so relieved if i could track there location as I know they are still in the county I live.
    Also if i cant locate them can i at least remotely delete the libraries, and lock them so they are unusable to the thiefs, and i had a sony laptop worth £2000 stolen which I had used my apple account for a year is there anyway i can track that or retrieve the contents and delete them?
    Please if anybody knows reply or contact me!!!! =-)
    many thanks

    You or Apple can do nothing to prevent use of the devices.
    For the iPod touch if you turned on the FindMyiPod feature and wifi is on and connected yu may be ablt ot locate it and wipe it by going to iCloud, signing in and going to FindMyiPhone. However, if the iPOd is rectored that feature is deleted.
    Report to police and change the passwords for all accounts used on the iPod.

  • TS1424 there are 43 available apps' update  which couldn't be made with my current account. How i can find the account with which i bought them in order to update them

    there are 43 available apps' update  which couldn't be made with my current account. How i can find the account with which i bought them in order to update them

    Use get info in iTunes on your Mac.

  • I cannot click on the menu, the beachball is rotating on my desktop, none of the files appear, and when I click on the Finder, the files are there but inaccessible. All applications open. How do I fix this?

    I cannot click on the menu, the beachball is rotating on my desktop, none of the files appear, and when I click on the Finder, the files are there but inaccessible. All applications open. How do I fix this?

    hi there,
    try booting into safe mode, by pressing the Shift button once you hear the startup sound.
    Hope this helps,
    Chris

  • I have imported from Microsoft Internet Explorer favorites, cookies, history and they are not available after importing under the Bookmarks tab. How do I find the import of favorites in firefox?

    When importing from Microsoft Internet Explorer I have successfully completed and clicked on finish. I am not finding my favorites under the Bookmarks tab. I have shut down Firefox and and restarted the browser and still not finding favorites. I also restarted the computer still not finding favorites imported from Microsoft Internet Explorer. How can I find the data imported from Microsoft Internet Explorer?

    You can usually find the imported IE Favorites in a folder ("From Internet Explorer") at the bottom of the Bookmarks Menu folder (Bookmarks > Show All Bookmarks).
    If you can't find them in the "From Internet Explorer" folder then try this:
    * Export the favorites in IE to an HTML file (bookmarks.html): File > Import and Export
    * Import the HTML file in Firefox: Bookmarks > Show All Bookmarks > Import & Backup > Import HTML: From File
    See also:
    * http://kb.mozillazine.org/Import_bookmarks ("Import from another browser" and "Import from file")

  • How do I find the cookies I want to keep

    Recently I asked for some help but I think my request has got lost.
    I had beenadvised to save the cookies I want to keep but this is beyond me.
    My question is how do I find the cookie I want to keep? It is a cookie for an ebook and I have no idea what it is.
    Will deleting all other cookies mean that it will also delete my passwords and log ins on several sites? I don't want this to happen.
    Which brings me to the last point - You say that if I list exceptions to cookies I want to keep (at least I think that is what you mean), how do I find all those cookies?
    Again, sorry for troubling you but until I can find out more about the cookies, I don't want to delete these in case I delete the wrong ones, such as the ebook.
    Thank you cor-el. I do appreciate your advice...enormously.
    Anthony

    Dear Sir,
    Thank you so much for the above. It will be of great help in telling me where to go. But my problem is that if I can find cookies, I don't know which ones I want to keep. Are they labelled with the sites they refer to? If so that will help me. Apart from one which is the cookie I need to get to my online ebook, I guess there are cookies for the various passwords I have saved?
    Forgive me but I am an old man and not real great with computers.
    Thanks,
    Anthony

  • How can I find the URL for an iCal calendar in iCloud so I can make a link to it on a web page.

    I have a single iCal calendar that I want people to access through my webpage.  How can I find the URL so that they can view the calendar without having to subscribe to it.  I converted to iCloud from .Mac and I can see that changes to this calendar are not showing up.

    Mmmh.. i see... I don't know wether it is possible for people just check calendars without subscribing to them... I have been sharing some calendars in my website (maybe you can have a look at it in order to check wether it could be a possible solution for you)
      http://web.me.com/andreabruschi/englishplanet/English_Courses.html
    Cheers
    Andrea

  • How can I find the location of an app on my iPad 2?

    How can I find the location of an app on my iPad 2? The app comes up with a search, but that seems to be the only way to find it. I just installed the app today, but I can't figure out where it is. It has a pretty distinctive icon, and I've looked through all of my apps and even in folders (even though I don't know how it would have gotten there). I want to put it in an appropriate folder under the right subject, but I can't find it to do this. I can use the app, since I can find it through a search though. I have a lot of apps, but I looked very carefully and can't find it. Is there a way to ask my iPad to locate it for me? It's a $25 app and one I plan to use regularly, so I want it located in the folder of my choice.This problem makes we wonder if I have other "missing" apps, apps that I could  find if I happened to think to search for them, but that don't appear to be on my iPad (even though they actually  are).

    You were right about the homescreens. I had turned my iPad off for the night with less than three full homescreens of loose apps, those not in folders. When I turned the iPad on this morning to try your suggestions, I had five full pages of loose apps. They just appeared when I restarted, and there was the app I was looking for, easy to find. Last night I was deleting apps I decided I wouldn't use, organizing useful apps into folders, and making sure I had as few pages as needed by making sure the gaps made by the moved/deleted apps were closed. The missing apps didn't show up at that point; I was just left with fewer than 11 pages. The apps only showed up when I restarted this morning. There were almost three extra pages of apps that weren't there last night. I know there must be other things missing, since all of the pages are full. So I tried your suggestion in iTunes. I connected my iPad, found an app in the alphabetical list on the left, and double clicked it. This brought me to the app's homescreen (and its home folder when applicable), the place where it was located. In order to identify which page that was, I had to scroll through the screen shots of the homescreens that was below the homescreen that was showing until I found the homescreen whose number was in white. Then I could count the pages on my iPad until I got to that page. I'll have to delete more apps and organize more into folders to see what else might show up. There are just too many apps available for special education, and I'm in the process of figuring out which are the best for my needs. Thanks so much!

  • Hello! I have one iTunes library on my iPod and one iTunes library on my computer. When I connect my iPod touch to my PC, however, I cannot find any files in my iPod except for pictures. How can I find the music files so I can add them to my iTunes?

    Hello! I have one iTunes library on my iPod and one iTunes library on my computer. When I connect my iPod touch to my PC, however, I cannot find any files in my iPod except for pictures. How can I find the music files so I can add them to my iTunes?

    You can't do that.
    And before you decide to store any music that you own on a computer at work, talk to your IT department. Many organizations do not permit it for legal reasons. Standard policies are that anything stored on company owned computers is the property of the company. It could not be legally stored on their machines unless you transfer the licenses and all copies, physical and digital, to the company, meaning you no longer own the music. If they were to be audited and could not prove that they own the music, they would be subject to copyright violation penalties. Just use your iPod when you're at the office if you want to listen to music.

  • How do I find the FTP info for my site?

    I created a site with Wix.com. Since then I've been exploring Dreamweaver, and the author of "Dreamweaver for Dummies" suggets that the best way to make changes to my existing site is to use Dreamweaver's FTP capabailities to download the existing pages. But Wix doesn't support FTP -- so they tell me, and simpleurl.com (where I regeistered my domain name) and which is somehow involved in the posting of my site) can't help either. Here's the Dreamweaver page that I need to fill in.
    How do I get this information?

    Yup, it's basically free, altho you can upgrade a little, as I've done. 
    And I took
    a careful look at the "source" for the pages I've created. That code will 
    show
    nothing of what I've written -- text-wise. It's all stored on the Wix 
    servers
    and accessed with various scripts. You can re-locate your Wix-created site
    after 60 days -- not before. So the suggestion I got from the "...Dummies"
    book doesn't apply here.
    Nonetheless, I'm going to continue to learn how to use Dreamweaver. Maybe
    after my 60 days are up I'll wanna move it. Don't know.
    MurraySummers http://forums.adobe.com/people/MurraySummers created the 
    discussion
    "Re: How do I find the FTP info for my site?"
    To view the discussion, visit: 
    http://forums.adobe.com/message/5993566#5993566

  • How can i find the option to delete a recent print job from the "View Job History

    1. Photosmart 5510 e-ALL-IN-ONE SERIES
    2. Window 7 64 bit
    How can i find the option to delete a recent print job from the "View Job History

    Hello alfmswongg,
    Currently there is no option to delete print jobs from the "View Job History" section of ePrintCenter.  
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • How can I find photos that are not assigned to any collection?

    Hi !
    I'm using LR 5.7.1 on a Mac.
    When I've retouched raw pictures with PS CC (and do not need the PSD file any longer) I export the PSD (that is in my catalog) as JPG and let it add to my catalog automatically. After that I delete the PSD file. That works fine.
    But .... the new JPG file is not assigned to any collection. That's no problem unless I forget to do it manually after that export (and import).
    That brings me to my question.
    How can I find photos that are not assigned to any collection?
    I tried it with a smart collection after I found nothing suitable in library filter. The search criteria I tried are Source -> Collection with any of the conditions. One with an empty value field, then with just a space and so on.
    Has anybody a good hint for me?
    Thomas

    You can also add numbers if you have collections that don't use alphabet characters.

  • How do I find the Serial number of a locked iphone?

    How do I find the Serial number of a locked iphone?

    Thanks but unfortunately I don't have any of those items to do that. Just have the phone. We are a third party support provider for Pharma companies and they send in their HW when users leave the company or are let go. This particular client deployed this device outside of our company at some point so we did not have the luxury of recording that info when deployed. We also cannot reach the original user to obtain the passcode. All we need is the serial number but need a way to access that on the phone without the passcode and without resetting or restoring the phones IOS.

  • How do i find the IP address of my printer?

    I have an HP 7130 all-in-one printer connected to a windows computer that is connected to a wireless router and modem. im using my macbook, which is also wireless to the same modem, and i am trying to set up a printer which requires the IP address of the printer it cannot find on its own. How do i find the IP address of the printer?
    Thanks!

    Hi Gavin,
    Actually it was a typo fault on my behalf. Unfortunately the 7130 will not have an IP address as it doesn't have an Ethernet connection - just USB.
    So, you are either going to have to connect the printer to the Windows computer and print from the Mac via the share or get some other hardware to share the printer. There are a number of wireless print servers on the market which allow you to connect your printer to its USB socket and then print wirelessly from your Windows and Mac computers. Or you could look at replacing the router with an Airport Extreme, which has a USB port for a printer.
    If you want use what you have then connect the printer to the Windows computer and share it. Then on your Mac, open the Printer Setup Utility and click Add. Click More Printers and then Windows Printing > Network Neighborhood. You should see the Workgroup name set in the Windows computer appear. If it doesn't then wait several minutes and try again (sometimes it can take a while before Windows computers appear in this list). Once the workgroup name appears double click it and select the computer from the new menu. At this stage you may be prompted for a user name and password for the Windows computer. Input this information and then the printer share should appear. Select it and then browse for your printer model. Now there is a good chance that your model is not listed under the HP menu so you will have to use one of the provided drivers in the list and see which one works best for your printer. Once you have selected an appropriate model click Add. Now you should be able to print via wireless..
    Regards,
    Paul

Maybe you are looking for

  • Best Practice - Bounded Task Flows, Regions and Nested Application Modules

    Using JDev 11.1.1.3; understand that it's generally considered good practice to just have 1 root application module servicing model content / services for each page. In our application, we've used a number of bounded task flows and page fragments dep

  • Convert file encoding from ASMO-708 to Unicode

    Hi, I have txt files from a dos application. the files in ASMO-708/ISO-8859-6 encoding i did a test program to see if i will be able to see the characters in Unicod(eclips-debug) i read the file using Reader r = new BufferedReader(new InputStreamRead

  • Permissions error when trying to recover a package

    The error: The operation can't be completed because you don't have permission to access [file] I have been using a writing program called Scrivener which has a package with many files. That I kept open nearly all the time (including when Time Machine

  • Photoshop display a little too wide

    I haven't been able to figure out a solution to this annoying problem. I'm running Windows Vista on an HP with a 24" LCD monitor, an NVidea 8800# series video card and when I bring up Photoshop the display is a little too wide for the screen. Not a l

  • Role Based Risk Analysis Report

    Hello All, When I executed the Risk Analysis report for a role with SOD Risk Level = ALL and Report type = SOD at Authorization Object level, the results come back as "NO CONFLICT FOUND".  this is the correct response. However, I executed the Risk An