如果你想给窗口内部加上一个边框,可以在窗口内加一个Panel,设置Panel的边框就行。
如果你想修改操作系统提供的边框颜色,是做不到的,但是可以去掉系统提供的边框,重写paint方法自己模拟一个:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
public class MyFrame {
public static void main(String[] args) {
JFrame frame1 = new JFrame();
frame1.setBounds(400, 300, 200, 200);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setBorder(new LineBorder(Color.red));
frame1.add(panel);
frame1.setVisible(true);
JFrame frame2 = new JFrame() {
public void paint(Graphics g) {
super.paint(g);
Rectangle rect = this.getBounds();
int width = (int) rect.getWidth() - 1;
int height = (int) rect.getHeight() - 1;
g.setColor(Color.red);
g.drawRect(0, 0, width, height);
}
};
frame2.setBounds(650, 300, 200, 200);
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setUndecorated(true);
frame2.setVisible(true);
}
}
这个算不
貌似没有办法.调用的是系统的.