Titled border issue for JPanel

这一生的挚爱 提交于 2019-12-11 03:09:00

问题


I developed an application using netbeans. But the title of the titled border of JPanel has some alignment issue. In the 'show preview' the title is displaying as expected, but while running the code, the title goes up above the panel. Can any one help me to resolve this issue.

Expected panel

Actual panel while running the project

Panel properties

I know this is some property issue with panel. I googled by couldn't find a valid solution. Stack experts please help to resolve this issue. I am using netbeans 7.2.1


回答1:


Take a look at Netbeans look and feel:

http://wiki.netbeans.org/NBLookAndFeels

Default is set to Nimbus, you probably want Windows.




回答2:


By editing Look and feel setting of the application you can get the expected result.

    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }

You have to change nimbus look and feel to windows..

    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
            javax.swing.UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }


来源:https://stackoverflow.com/questions/15994569/titled-border-issue-for-jpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!