关于java draw3DRect()方法的问题
importjavax.swing.*;importjava.awt.Graphics;publicclassTestPaintComponentextendsJFram...
import javax.swing.*;
import java.awt.Graphics;
public class TestPaintComponent extends JFrame {
public TestPaintComponent() {
add(new NewLabel("Banner"));
}
public static void main(String[] args) {
TestPaintComponent frame = new TestPaintComponent();
frame.setTitle("TestPaintComponent");
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
class NewLabel extends JLabel {
public NewLabel(String text) {
super(text);
}
protected void paintComponent(Graphics g) {
g.draw3DRect(10, 10, 100, 100, true);
super.paintComponent(g);
}
}
为什么我引用了g.draw3DRect(10, 10, 100, 100, true);但实际效果没有图形没有3d效果.请高手解答一下 展开
import java.awt.Graphics;
public class TestPaintComponent extends JFrame {
public TestPaintComponent() {
add(new NewLabel("Banner"));
}
public static void main(String[] args) {
TestPaintComponent frame = new TestPaintComponent();
frame.setTitle("TestPaintComponent");
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
class NewLabel extends JLabel {
public NewLabel(String text) {
super(text);
}
protected void paintComponent(Graphics g) {
g.draw3DRect(10, 10, 100, 100, true);
super.paintComponent(g);
}
}
为什么我引用了g.draw3DRect(10, 10, 100, 100, true);但实际效果没有图形没有3d效果.请高手解答一下 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询