【问题标题】:How change the border (inside part) color of a JPanel?如何更改 JPanel 的边框(内部)颜色?
【发布时间】:2015-11-14 05:25:32
【问题描述】:

我正在编写一个全屏运行的应用程序。到目前为止,整个屏幕周围都有一个细边框。

这个细边框在屏幕周围形成一条细灰线。 我想删除这条线(见图片上的红色箭头)。

这是我构建全屏窗口的方法:

final JFrame mainFrame = new JFrame("Display Mode");
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
mainFrame.setBackground(Color.BLACK);
mainFrame.setResizable(false);
mainFrame.setUndecorated(true);

JPanel panel = new JPanel(new MigLayout("insets 0, fill"));

GraphicsDevice defaultScreenDevice  = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
JSplitPane spMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftWhiteJPanel, rightBlackJPanel);

spMain.setDividerLocation(defaultScreenDevice.getDisplayMode().getWidth() / 2);

panel.add(spMain, "grow");
mainFrame.add(panel);

mainFrame.pack();
defaultScreenDevice.setFullScreenWindow(mainFrame);

【问题讨论】:

    标签: java swing jpanel border jsplitpane


    【解决方案1】:

    边框来自JSplitPane,例如尝试用setBorder(null) 移除边框...

    spMain.setBorder(null);
    

    【讨论】:

    • 疯狂程序员你是个天才!!现在边界已经出来了。谢谢。
    【解决方案2】:

    Alternative - 为您的面板添加线条边框。 示例:yourPanelName.setBorder(new LineBorder(Color.BLACK));

    【讨论】:

    • XD 我发誓我第一次看的时候没看到!
    • 我什么都没看到 ;)
    猜你喜欢
    • 1970-01-01
    • 2021-01-11
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 2010-09-09
    • 2020-01-12
    • 2013-02-18
    • 1970-01-01
    相关资源
    最近更新 更多