Swing apps doesn't run

前端 未结 2 1193
眼角桃花
眼角桃花 2021-01-23 04:01

I have a problem in using swing. I don\'t know what is the cause of this but i\'m just trying to create a simple frame app using swing at it give me a lot of error.



        
相关标签:
2条回答
  • 2021-01-23 04:36

    I had problem when all java Swing apps crashed silently. After trying to launch from command line got the following exception:

    Caused by: java.lang.IllegalArgumentException: 181193932 incompatible with Text-specific LCD contrast key
    

    As it's said in JDK-6503988, the problem is connected with ClearType registry setting FontSmoothingGamma.

    This can be fixed by running "Adjust ClearType text" from Control panel (cttune.exe) or by changing the registry directly:

    reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /t REG_DWORD /v FontSmoothingGamma /d 1024 /f
    

    A reboot may be needed for changes to take the effect.

    See also a 10-year-old investigation of the same problem at https://www.rarst.net/software/cleartype-install4j-java-bug/.

    0 讨论(0)
  • 2021-01-23 04:36

    This code works for me:

    package test;
    
    import javax.swing.JFrame;
    public class Test {
    
        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setVisible(true);
            frame.setSize(100,200);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
    }
    

    I only see a difference at

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    where I added the frame. However your stacktrace looks like there's another error, so first try this and if it still don't work, give us a bit more code to look at.

    0 讨论(0)
提交回复
热议问题