JFrame.setMaximumSize() doing nothing?

I know this question has been posted many times, but I just can't find the answer...
So, how I set the max size of a frame?
A little test I made:
import java.awt.*;
import javax.swing.*;
class test
     public static void main(String[] args)
          JFrame test = new JFrame("test");
          test.setMinimumSize(new Dimension(200,300)); // works
          test.setMaximumSize(new Dimension(300,400)); // doesn't work
          test.setDefaultCloseOperation(test.EXIT_ON_CLOSE);
          test.show();
As you see, the result is that I cannot resize the frame under 200x300, but I'm able to resize it as large as I want, which is obviously wrong...
What am I missing?
Thanks in advance for the answers

It's a known bug.
[http://bugs.sun.com/bugdatabase/view_bug.do;?bug_id=6200438]
[http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4744281]
[http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4320050]
db

Similar Messages

  • JScrollPane (added to a JPanel, which paints) is visible but does nothing

    Hi. I am writing a program that reads data from files and does paiting using the info. The top level window is a JFrame, which is divided into two parts - A Box which contains the buttons through which the user interacts and a JPanel on which the painting is done. I have added the JPanel to a JScrollPane, but have run into problems there. The JScrollPane is visible (both policies always visible) but it does nothing. I understand that when the drawing is fitting, the ScrollPane is not used. But even if I make the window small or draw something that is not visible in the normal are, the JScrollPane doesn't work. In fact, no knob is visible on either of the two scrollbars. I am pasting the relevant code below:
    //import
    public class MainWindow extends JFrame {
        public static void Main(String[] args) {
            new MainWindow();
        //Declare all the variables here.
        private Box buttionBox;
        private JScrollPane scroller;
        private HelloPanel drawingPanel;   
        //other variables
        //The constructor for the class MainWindow.
        public MainWindow() {
           initComponents();
            this.setLayout(new BorderLayout());
            this.setPreferredSize(new Dimension(900,670));
            //buttonBox containts the buttons - not very relevant to this problem.
            this.getContentPane().add(buttonBox, BorderLayout.WEST);
            //scroller is the JScrollPane
            this.getContentPane().add(scroller, BorderLayout.CENTER);       
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setTitle("My Title");       
            this.setVisible(true);
            this.pack();       
        public void initComponents() {
            buttonBox = Box.createVerticalBox();
            //instantiate the buttons here and add them to the ButtonBox.
            //The event listeners instantiated. Not relevant.       
            //The various components are assigned their appropriate event listeners here.
             //Not relevant.
    //Now adding all the buttons to the box with proper spacing.
            buttonBox.add(Box.createVerticalStrut(20));
            //This is the drawing panel on which the drawing will be done.
            drawingPanel = new HelloPanel();
            scroller = new JScrollPane(drawingPanel);
                    scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            scroller.getHorizontalScrollBar().setUnitIncrement(10);
            scroller.getVerticalScrollBar().setUnitIncrement(10);
        //This inner class is used to define and implement the event listener for handling the checkboxes.
        private class checkBoxListener implements ItemListener{
            public void itemStateChanged(ItemEvent e){
                 drawingPanel.repaint();
                    //Implement actions. Irrelevant
        //This private class is used to define and implement the event listener for the buttons.
        private class buttonListener implements ActionListener {
            //Do this when the button which has an instance of this class as its listener is clicked.       
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == saveStructureButton){
                  //Implement action. Irrelvant.
        //The panel on which the drawings are done.
        private class HelloPanel extends JPanel {
            //This JPanel is used for drawing the image (for the purpose of saving to disk).
            JComponent c;    //For image. Irrelevant.
            public HelloPanel(){           
                c = this;   //This is necessary for drawing the image to be saved to disk.
                this.setBackground(Color.WHITE);
            //This is the method that actually paints all the drawings whenever a.
            //The shapes theselves can be defined somewhere else, but that paint method must be invoked from here.
            public void paintComponent(Graphics g){
                super.paintComponent(g);    //First of all, clear the panel.
                Graphics2D g2 = (Graphics2D) g;
                g2.fill(new Rectangle2D.Double(40,40,100,100));    //Just for this post.
                g2.drawString("Text", 750, 750);    //To test the scrollpane.
    } I hope this helps you get an idea of what I am trying to do and what the problem might be. Any help would be really appreciated. I have spent hours on this and I have no idea why it doesn't work.
    The actual code is much bigger, so if you need any extra information, please tell me.

    HelloPanel should provide a "public Dimension getPreferredSize()" method.
    With your code you create a simple JPanel and want to draw outside of it, but you never tell the JScrollPane that your HelloPanel is actually bigger than it seems, that's why it does not feel the need to add scroll bars.
    Here's the working code:
    //import
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class MainWindow extends JFrame {
        public static void main(String[] args) {
            new MainWindow();
        //Declare all the variables here.
        private Box buttionBox;
        private JScrollPane scroller;
        private HelloPanel drawingPanel; 
        //other variables
        //The constructor for the class MainWindow.
        public MainWindow() {
           initComponents();
            this.setLayout(new BorderLayout());
            this.setPreferredSize(new Dimension(900,670));
            //buttonBox containts the buttons - not very relevant to this problem.
            //this.getContentPane().add(buttonBox, BorderLayout.WEST);
            //scroller is the JScrollPane
            this.getContentPane().add(scroller, BorderLayout.CENTER);       
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setTitle("My Title");       
            this.setVisible(true);
            this.pack();       
        public void initComponents() {
            //buttonBox = Box.createVerticalBox();
            //instantiate the buttons here and add them to the ButtonBox.
            //The event listeners instantiated. Not relevant.       
            //The various components are assigned their appropriate event listeners here.
             //Not relevant.
    //Now adding all the buttons to the box with proper spacing.
            //buttonBox.add(Box.createVerticalStrut(20));
            //This is the drawing panel on which the drawing will be done.
            drawingPanel = new HelloPanel();
            scroller = new JScrollPane(drawingPanel);
                    scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            scroller.getHorizontalScrollBar().setUnitIncrement(10);
            scroller.getVerticalScrollBar().setUnitIncrement(10);
        //This inner class is used to define and implement the event listener for handling the checkboxes.
        private class checkBoxListener implements ItemListener{
            public void itemStateChanged(ItemEvent e){
                 drawingPanel.repaint();
                    //Implement actions. Irrelevant
        //This private class is used to define and implement the event listener for the buttons.
        private class buttonListener implements ActionListener {
            //Do this when the button which has an instance of this class as its listener is clicked.       
            public void actionPerformed(ActionEvent e) {
                //if (e.getSource() == saveStructureButton){
                  //Implement action. Irrelvant.
        //The panel on which the drawings are done.
        private class HelloPanel extends JPanel {
            //This JPanel is used for drawing the image (for the purpose of saving to disk).
            JComponent c;    //For image. Irrelevant.
            public HelloPanel(){           
                c = this;   //This is necessary for drawing the image to be saved to disk.
                this.setBackground(Color.WHITE);
            //This is the method that actually paints all the drawings whenever a.
            //The shapes theselves can be defined somewhere else, but that paint method must be invoked from here.
            public void paintComponent(Graphics g){
                super.paintComponent(g);    //First of all, clear the panel.
                Graphics2D g2 = (Graphics2D) g;
                g2.fill(new Rectangle2D.Double(40,40,100,100));    //Just for this post.
                g2.drawString("Text", 750, 750);    //To test the scrollpane.
         public Dimension getPreferredSize()
         return new Dimension(750,750);
    }

  • I am trying to install a language disc. I clicked on the installer. It ran for a long time without installing. I click stop installing and it says it is stopping but is doing nothing. I am unable to eject the disc or stop anything.

    I am trying to install a Portugese language disc. I clicked on the installer icon and it said it was installing, but it ran forever without doing anything. I clicked "stop installing" and it says "stopping", but it is doing nothing. I am unable to eject the disc or do anything because it says an operation is in progress.

    Please provide some info on the disc, where it comes from, who made it, etc.  Also tell us what version of OS X you are running.

  • I upgraded from 3.6.13 to Beta 4.0 and now Firefox will not open at all I tried to uninstall to start again but it will not uninstall either it does nothing.

    I uninstalled Beta 4 and re-installed 3.6.13 now Firefox will not open at all I tried to uninstall to start again but it will not uninstall either it does nothing, I have been using Firefox for a long time but cannot resolve this problem can anyone help and give me a solution please. As I use Firefox as my web browser it is very frustrating.
    The fact it will not uninstall appears to be something completely new as nobody I know who uses Firefox has ever encountered this in the past.

    Did you check your security software (firewall)?
    A possible cause is security software (firewall) that blocks or restricts Firefox without informing you about that, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process.
    See [[Server not found]] and [[Firewalls]] and http://kb.mozillazine.org/Firewalls
    If necessary then also see:
    * http://kb.mozillazine.org/Browser_will_not_start_up
    * http://kb.mozillazine.org/Error_loading_websites

  • Trying to do a software update, but my macbook pro does nothing after it prompts me to restart

    I am trying to do a software update on my Macbook Pro so I can update the new iTunes so I can start using my new iPod. Every time I go through the process of the computer searching for updates and confirming there are software updates, then being prompted to restart my computer, it does nothing. After my Macbook Pro turns on again, nothing pops up and I go into my information and it says I still have the old software. Nothing is prompting me to do the update after I restart my computer, or beforehand for that matter. HELP.

    Are you really still running 10.6.2? If Software Update isn't working for you, you may want to try using the 10.6.8 combo update found here -->> http://support.apple.com/kb/DL1399.
    If that doesn't work, call back...
    Clinton

  • Why does my itunes crash after start up with an "APPCRASH" error every time i open it?! I have been trying to fix this for weeks but all i can do it re-install it every other day which does nothing!

    Why does my itunes crash after start up with an "APPCRASH" error every time i open it?! I have been trying to fix this for weeks but all i can do it re-install it every other day which does nothing! I am desperate to get access to my itunes to get music on my phone and all of this just makes me want me to sell my iphone since there is no other way to add music to my phone. If things go get sorted soon you can say goodbye to my support.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • My 4S has stopped ringing. Voicemail's disabled but if you call me, you'll hear it ring your end but it does nothing at mine and freezes if I make a call. Texts are not being delivered or coming through delayed. Ringer is on, tone enabled - help!

    My iPhone 4S has stopped ringing altogether. Voicemail is disabled but if you call me, you'll hear it ringing at your end but it does nothing my end and freezes in the phone app if I make a call (doesn't ring or connect and doesn't freeze the phone, just the calling part). Texts are not being delivered or coming through delayed. Ringer is on, tone enabled - help!
    I've disabled roaming so it only runs on wifi (this after getting a £4k phone bill...) and I can use Skype, Viber and WhatsApp with no problem at all.
    Would really appreciate any help at all!
    Many thanks.

    Hi there - am with Orange and they said nothing wrong with account and service running normally.  They said if they had cut me off I would've received a text (debatable with current message receiving situation!) and when I called out it would say 'calls from this number are barred'.  Also if you called me it would say something similar.  But it doesn't, it will ring and ring until it rings off but nothing happens at all on my handset. Not even a missed call notification.  If I call out, it will display that it is calling the number but that's it.  If I cancel the call it will constantly display 'ending call'.  If I come out of the phone and go to another app then revist phone it will start calling that last dialled number - without ever getting as far as ringing or connecting.

  • When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the o

    When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the original in my work folder. I need to know how to stop this from happeing and get it back to the way it has been working he last 6 months since i purchased this program.

    Hi pissedadobeuser,
    Does this issue occur with any particular web page?
    Are you able to print the webpage to 'Adobe PDF' to convert it to pdf.
    Which Browser version, OS version and Acrobat version are you using?
    Regards,
    Rave

  • How do i close the welcome to iMovie screen? Clicking on red button in upper left does nothing. SOS!  Thanks!

    How do I close the "Welcome to iMovie" screen?  Clicking on the red button in the upper left does nothing. SOS!  Thanks!

    "Continue" was hidden at the bottom of the welcome screen because my display was changed.  Some days I'm smarter than others.  Or.... :-) 

  • After a firefox "upgrade" was installed automatically, Firefox will not start, even in Safe mode. Clicking on the icon does nothing

    after a firefox upgrade was auto-installed, firefox no longer will launch. clicking on the icon does nothing. can't start in safe mode
    == This happened ==
    Not sure how often
    == firefox upgrade auto-installed ==
    == User Agent ==
    Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

    You can try to disable the Java Quick starter and the Java Console extension in the Control Panel > Java.
    Control Panel > Java > Advanced tab > Miscellaneous >Java Quick Starter (disable)
    You can also disable the Java plugin in Firefox: Tools > Add-ons > Plugins
    See [[Troubleshooting extensions and themes]]
    See [[Troubleshooting plugins]]

  • Clicking on link in dynamic document does nothing

    Hello my friends,
    I Add link to my dynamic document but when I press on the link it does
    nothing. I create event handle class and connected it to the link and
    it still did not work.
    Please help me if you can, its urgent.
    Regards,
    Eitan Iluzz.

    Try this: http://helpx.adobe.com/creative-cloud/help/launch-creative-cloud-apps.html

  • Clicking on the bookmark toolbar does nothing

    Clicking on the bookmarks in the bookmark bar does nothing. However, when I right click, I can open the bookmarks, selecting either open, open in new window, or open in new tab.
    I don't know if this is related, but clicking the "Add tab" button does nothing as well.

    hello, one of your addons might be interfering - try if it's working correctly when you launch firefox in safemode.
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]

  • The search function in the itunes store does not work.  It will accept a request and suggest searches but then it locks up and will not search.  Clicking on the magnifying glass or a suggested search does nothing.  Re-installing itunes has not helped.

    The search function in the itunes store does not work.  It will accept a request and suggest searches but then it locks up and will not search.  Clicking on the magnifying glass or a suggested search does nothing.  Re-installing itunes has not helped.

    everything you stated here is exactly what i have done and have got nowhere. i have windows 7 64 bit on a hp 8 g of ram desktop. im also looking for help

  • Clicking on M/S' RUN and/or SAVE does nothing - just sits there

    Have had this problem for a few days. In trying to open again, it always tells me Firefox is still running and to close it first. There is no Firefox running! Have uninstalled FF and in trying to install a new one, I get as far as the Run/Save; clicking on either one does nothing, it just sits there. Thanks for your help. PS - I've been using FF for ages - first time I've had this problem. PPS = tried to cut/paste browser url but went to open a file.

    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from [https://www.mozilla.org mozilla.org] (or choose the download for your operating system and language from [https://www.mozilla.org/firefox/all/ this page]) and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (or open the Firefox menu [[Image:New Fx Menu]] and click the close button [[Image:Close 29]]).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    More information about reinstalling Firefox can be found [[Troubleshoot and diagnose Firefox problems#w_5-reinstall-firefox|here]].
    <b>WARNING:</b> Do not use a third party uninstaller as part of this process. Doing so could permanently delete your [[Profiles|Firefox profile]] data, including but not limited to, extensions, cache, cookies, bookmarks, personal settings and saved passwords. <u>These cannot be easily recovered unless they have been backed up to an external device!</u> See [[Back up and restore information in Firefox profiles]]. <!-- Starting in Firefox 31, the Firefox uninstaller no longer lets you remove user profile data.Ref: Bug 432017 and https://support.mozilla.org/kb/uninstall-firefox-from-your-computer/discuss/5279 [Fx31] Windows uninstaller will no longer offer the option to remove personal data -->
    Please report back to say if this helped you!
    Thank you.

  • Clicking on "order prints" just says "connecting" then does nothing ...

    I fear that I screwed up somewhere in setting up my 1-click setting and now when I select a photo and click on order prints, it just says connecting then does nothing. It doesn't even take me to the 1-click screen to allow me to change account info. Does anyone know of a way to at least get me back to the 1-click page to allow me to associate my mac account to iphoto?

    Hi bplatinum,
    http://docs.info.apple.com/article.html?artnum=303168
    This Apple kb says to reinstall iPhoto 6. Hopefully that will solve it for you.

Maybe you are looking for

  • Why are my ical invites sent to everyone on my network instead of just to those I want to invite?

    Hello everyone! I'm upfronted with the following issue using iCal. We have small buisness with 10 clients all running Lion. Our server is a MacPro with SL. Every single user has its own CalDAV Account within iCal and on the server. Using iCal upbring

  • Active Focal Point Not Shown in Software Using Back Button Focus

    I use Back Button Focus (BBF) and set the focus point (using center spot). In the software (DPP, ZoomBrowser or EOS Utility) the point I selected is not highlighted in the view window. All points are shown, but none highlighted. If I take the same sh

  • Urgent !!! How to change Accounting document using Billing document numb

    Hi experts, I have one requirement where I have to modify the accounting document using report. User will enter billing document no and I have to find out respective accounting document and change header data of it. I am very new to these modules so

  • Issue regarding Ship to party

    1.How can we get 10 shipto party at a time in customer master? what  is the procedure to create 10 ship to party for single customer master. 2. how can we change Account group? Plz send me reply Thanks in Advance Venkata Ramana

  • Photo lost

    I put in the scan disk and an error msft message comes upon the computer. i cannot save any photos on my computer either via computer or from the machine.