我希望我的布局在JPanel的底部有双重边框,其中一个应该略微暗一些,另一个应该略微亮一些。
目前我只有1个边框:
JPanel pnlTop = new JPanel(new BorderLayout()) {
protected void paintComponent(Graphics grphcs) {
super.paintComponent(grphcs);
Graphics2D g2d = (Graphics2D) grphcs;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
GradientPaint gp = new GradientPaint(0, 0,
new java.awt.Color(237, 237, 237), 0, getHeight(),
new java.awt.Color(222, 222, 222));
g2d.setPaint(gp);
g2d.fillRect(0, 0, getWidth(), getHeight());
}
};
pnlTop.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new java.awt.Color(173, 173, 166)));
pnlTop.setPreferredSize(new Dimension(2000, 90));
add(pnlTop, BorderLayout.PAGE_START);
我已经有一个边框了,如何在其下方添加另一个边框?这可行吗?
CompoundBorder
内使用CompoundBorder
。 - MadProgrammer