How can I resize a JFrame ,to fit into the screen size

I have a Jframe which has JPanel and JPanel contains lot of other components.JPanel size is 980,1400. when i use JFrame.show method jpanel goes beyond the screen size in length and I am not able to see the portion below the screen.How can I resize the JFrame so that JFrame and JPanel shrinks to fit into the screen size.I need this because I have a PRINT button at bottom of the JPanel.Thanks.

Thank you for your reply.I tried with the following code as you have told.But the frame is still going beyond the screen.Can you please look into it and tell me whats wrong ?
//public class PlayerRegForm extends javax.swing.JFrame implements Printable
public static void main(String args[]) {
PlayerRegForm prf = new PlayerRegForm();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = prf.getSize();
if (frameSize.height > screenSize.height)
frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width)
frameSize.width = screenSize.width;
System.out.println("Screen Size ----------------- " + screenSize);
System.out.println(" Frame Size ----------------- " + frameSize);
prf.setSize(frameSize.width, frameSize.height);
prf.pack();
prf.show();
=============================================================================
Screen Size ----------------- java.awt.Dimension[width=1024,height=768]
Frame Size ----------------- java.awt.Dimension[width=112,height=28]

Similar Messages

  • HT1386 After syncing with itunes(windows), messages for one of the contact(I have saved the contact name as 'Unknown') are lost. I can see only few messages which fits to the screen. I don't see option to load earlier messages.

    After syncing with itunes(windows), messages for one of the contact(I have saved the contact name as 'Unknown') are lost. I can see only few messages which fits to the screen. I don't see option to load earlier messages.
    Can anyone help.

    Can anyone help on this?

  • How can i open a pdf in safari without the screen turning black?

    How can I open a PDF in Safari without the screen turning black?

    Welcome to Apple Support Communities. We're all users here.
    Depending upon your version of OS X and your version of Safari, as detailed in the Adobe help document links below, Adobe pdf documents created with the latest releases may require an (updated free) Adobe plug-in for Safari, or (free) Adobe Reader in order to display properly.
    http://helpx.adobe.com/x-productkb/multi/safari-5-1-incompatible-reader.html
    http://www.adobe.com/support/downloads/product.jsp?platform=macintosh&product=10
    I encountered the problem recently when attempting to view documents from a financial institution.

  • Can a pcie-1x sound card fit into the third pcie-8x slot of P7N Platinium ?

    can a pcie-x1 sound card fit into the third pcie-x8 slot of P7N Platinium (indicated by the green arrow in the pic below) ?
    what is the intended usage or practical usage for that 3rd slot?
    Also, kindly enquire if 3 ways SLI really feasible and any driver is released and tested to support it?
    My rig specification are as follow: 1)msi p7n sli platinium, 2)intel e8400 stock cooler, 3) 2x 2GB Crucial Ballistix  DDR2 800, 4)2x msi 8800gt oc 512mb  5) acbel M8 750 6) Samsung 160gb hdd 7) Asus DRW.
    thank you. i do like this motherboard, very nice layout and the circu-pipe in particular. lack of sata ports has been compensated by purchasing a 4 sata ports controller card. if the third pcie x8 is a pcie x1 slot, that will be even better.

    Quote from: BOSSKILLER on 22-April-08, 17:31:47
    Yes you can
    great to hear that. like that, i can consider buying the Asustek Xonar D2X Audio Card PCI-E as the green indicated pcie x8 is my only unoccupied slot after using 2  gfxs (2 slots) and 1 sata controller pci card.
    thank for your prompt reply.
    cheers.

  • How can I import Photoshop-Shortcuts from CC into the CC 2014 update?

    How can I import Photoshop-Shortcuts from CC into the CC 2014 update? Migration and Sync didn't help. What am I doing wrong? The .kys is also in the same folder as in the previous version of PS CC.
    Kindly
    Nico

    If you had Illustrator you could take advantage of smart objects.
    Has been awhile since I worked in Corel (so do not remeber if Corel had clipboard settings whcih need adjusuting), but do remember copying a path, getting that into Phothshop as shape layer for part of the artowrk in a trade show poster.

  • How can i make my phone die faster if the screen is black

    how can i make my phone die faster if the screen is black?

    There are some misconceptions that open apps consume battery power.  This is generally incorrect.  Read: http://speirs.org/blog/2012/1/2/misconceptions-about-ios-multitasking.html

  • I am trying to send a file for a contest and my image is 2.7MB and they only want it 2MB how can I resize my image to fit ?????

    i am trying to send a picture on a pastel site for a contest and my image is 2.7MB........ they want it 2MB...how can I resize my photo to 2MB???? Pat....

    select the photo and export it (file menu ==> export) - there are several options for reducing the size including quality and maximum pixel dimension
    LN

  • How can I get my desktop to fit in my screen?, How can I get my desktop to fit in my screen?

    My windows and desktop (everything I see) is too big to fit in the screen.  I have to touch my mouse arrow to one side to see an entire window or to access my desktop.  I can't figure how to make it all back to normal size.  Any suggestions? 

    Turn off Zoom from the Universal Access and Keyboard & Mouse panes of System Preferences.
    (73801)

  • How can to resize an image uploaded in to the smart image

    Hi
        I have an image uploaded into the smartimage from the local file system. How can i resize this file or create a rendition for this image?
    Thanks
    Veena

    Hi
       I got a reference for the same question from Stack Overflow http://stackoverflow.com/questions/14726485/resize-an-image-resource-in-cq5/16728970#16728 970
    I tried the same method
    Resource resourceNew = resource.getResourceResolver().getResource(img.getFileReference());
        Asset asset = resourceNew.adaptTo(Asset.class);
        log.error("asset ****" + asset);
        Layer layer = new Layer(asset.getOriginal().getStream());
        layer.resize(200, 200);
        log.error("layer ****" + layer);
                            Image image = new Image(resource);
        String mimeType = image.getMimeType();
        ByteArrayOutputStream bout = null;
        ByteArrayInputStream bin = null;
        try {
            bout = new ByteArrayOutputStream(2048);
            layer.write(mimeType, 1, bout);
            bin = new ByteArrayInputStream(bout.toByteArray());
            asset.addRendition("resizedImage", bin, mimeType);
    log.error("asset Bin" + asset);
        } finally {
            // close streams ...              
    Where img is my Image object and I was able to create a rendition in the dam.
    But the rendition I am getting is in File format. Is there a way by which i can change it to png format??? any Help will be appreciable..
    Thanks
    Veena

  • When i press the green button, it goes to full screen. How can i just go back to it making the screen just a little bigger and not fullscreen?

    I recently upgraded to Mavericks and i hate that every time i press the +/green button on the top left, the page goes fullscreen. How can i go back to it just making the window bigger instead of fullscreen.

    Hold down Option key and click the Green button. It will change from the Full Screen button back to a Zoom button.
    You can also double-click the empty area in the window frame (title bar) if you don’t have it set to minimize when double-clicking.

  • How can I Resize Two or More Shapes At The Same Time?

    I've got text over a rectangle over another rectangle. When I change my text, the size of the boxes needs to change and it's a drag ot have to do each one separately and constantly realign. Is there a way I can resize both of them at the same time tokeep the proportions the same?
    Or is there a way I can enter #s to resize, so I could just enter the same #s for each shape?
    Thanks,
    Amanda

    Here's an example of what Wyodor is referring to: text in shapes within another shape.. It goes one step further and adds the first shape+text into another shape but the concept is the same.
    OT

  • How can I make a JFrame pop up in the middle of the screen?

    On my application I have a help button. The button is used to trigger a pop up JFrame containing my help messages. This JFrame keeps popping up at the top left corner of my screen. Is there a way to make it pop up in the middle of the screen? Anyone?

    hi, try this:
    public static void centerWindow(Window win){
    Dimension screenSizeWithSpeedBar = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension screenSize = new Dimension(screenSizeWithSpeedBar.width,screenSizeWithSpeedBar.height-25);
    Dimension frameSize = win.getSize();
    if (frameSize.height > screenSize.height)
    frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width)
    frameSize.width = screenSize.width;
    win.setSize(frameSize);
    win.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    It works with following arguments: JWindow, JFrame and JDialog

  • Firefox crashes for unknown reason lately, so I removed it and reinstalled it. How can I put my Favorites (bookmarks) back into the newly installed FireFox???

    Firefox crashes a few times when I was on Facebook and with email, also watching dramas online. Most of the time due to Adobe Flash and I did submit crash report. Later it crashes for unknown reason while I have email and Facebook on different tabs -- when I was on the tab of email, it looks system hang and not responding. This happened to my laptop that uses Windows Vista as I noticed. I don't remember it ever happens to my desktop that uses Windows XP.
    It's pretty annoying of such known crash, but before removing Firefox, I did try to update all add-ons or plugins and it looks like doesn't work out. After updating for couple times and it still crashed like that, I removed Firefox and reinstall it.
    '''Now I want to know how to put the shortcuts from my Favorite folder into the newly installed FireFox's bookmarks.''' I didn't backup the bookmarks by using Firefox. I even went to Firefox help for instructions, but it only mentions how to merge/input the bookmarks from other browsers. Please note the version I've removed and inrestalled is the same -- 3.6.13.

    It is possible that there is a problem with the files sessionstore.js and sessionstore.bak in the Firefox Profile Folder.
    Delete the sessionstore.js file and possible sessionstore-##.js files with a number and sessionstore.bak in the Firefox Profile Folder.
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    *http://kb.mozillazine.org/Multiple_profile_files_created
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder

  • How can I view more than one result on the screen when I search for apps? eg I search for my hobby and there are over 1500 results - one result per screen - do I have to swipe 1500 times to see them all?

    I search for apps about my hobby. There are over 1500 results. Each single result takes up the whole screen. I will have to swipe the screen 1500 times to see all the results. How can I see 8 or 10 results and scroll through fast? Thanks very much for any suggestions!

    Bump:)
    But I've found some online reviews of this and I think we
    are stuck with this amazingly awful search system until
    they realize people like me won't bother searching for or buying
    Apps.
    Does a novel display one sentence per page?
    Do you listen to a radio documentary that transmits one word a minute?
    Or how about a song that is broken into four parts because the singers ran out of breath?
    Searching app products has never been easy or a pleasure, and now it's tougher than ever. Who has the time to swipe 1,600 times? It HURTS - and hurts my brain just thinking about it.
    Woe is me!
    Woe are we!

  • How can I put a stl::vector string into the DB and then get it out?

    Hello,
    As the title, here's a test case with problems,but anyway you can still run it. ( VC6/XP-32/BDB 4.7 )
    I know this may be wrong,and I'd like to know how can I do this.
    Can someone help me please? I would appreciate it very much.
    ************ Copy,Compile and Run ***************
    #include <iostream>
    #include <vector>
    #include "db_cxx.h"
    int main()
         std::string dbName("database.db");
         u_int32_t db_flags=DB_CREATE;
         Db* db=NULL;
         // Prepare key(int)/data(vector<string>) pair.
         int int_key=2;
         std::vector<std::string> rec_data;
         rec_data.push_back("apple");
         rec_data.push_back("Bob");
         rec_data.push_back("Me");
         // Prepare Dbt for receiving.
         std::vector<std::string> rec_readData;
         Dbt readData;
         readData.set_data(&rec_readData);
         readData.set_ulen(sizeof(rec_readData));
         readData.set_flags(DB_DBT_USERMEM);
         try
              // Open database.
              db = new Db(NULL,0);
              db->open(NULL,dbName.c_str(),NULL,DB_BTREE,db_flags,0);
              // Put
              int ret;
              if(ret=db->put(NULL,new Dbt(&int_key,sizeof(int_key)),new Dbt(&rec_data,sizeof(rec_data)),DB_NOOVERWRITE)==0)
                   std::cout<<"put successful!"<<std::endl;
              else { db->err(ret,"Db->put"); }
              // Get
              if(ret=db->get(NULL,new Dbt(&int_key,sizeof(int_key)),&readData,0)==0)
                   std::cout<<"get successful!"<<std::endl;
              else { db->err(ret,"Db->get"); }
         catch(DbException &e)
              std::cerr<<"Error: ";
              std::cerr<<e.what()<<std::endl;
         // Close the database
         try
              if(db!=NULL)
                   db->close(0);
         catch(DbException &e)
              std::cerr<<"Error closing database: ";
              std::cerr<<e.what()<<std::endl;
         // Display the results.
         // Index out of bounds. <-----
         std::cout << rec_readData[0].c_str();
         std::cout << rec_readData[1].c_str();
         std::cout << rec_readData[2].c_str();
         system("pause");
         // Press any key to go wrong. :(
         return 0;
    Regards,
    legendsino

    You need to convert the std::vector<std::string> into a sequence of bytes. For example, if all strings are shorter than 256 characters, you could create a fresh output string, iterator through the vector, and for each element, append the string length to the output string, followed by the string contents.
    Note that ordering in the database will be different from lexicographic order, and you have to keep that in mind when performing range queries.

Maybe you are looking for