java draw3DRect()方法没有显示立体图片 5
importjava.awt.*;importjava.awt.Graphics2D;importjava.awt.event.WindowStateListener;i...
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.event.WindowStateListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
class iPaint{
public static void main(String[]args){
new DrawFrame();
}
}
class DrawFrame extends JFrame {
DrawFrame(){
DrawPanel dp=new DrawPanel();
this.add(dp);
setBounds(100,100,1000,500);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
class DrawPanel extends JPanel{
public void paint(Graphics g){
Color c=g.getColor();
Image a=Toolkit.getDefaultToolkit().getImage(DrawPanel.class.getResource("/Copy of M.jpg"));
g.drawImage(a, 80, 100, 250, 128, this);
g.setColor(Color.green);
g.setFont(new Font("华文彩云",Font.ROMAN_BASELINE,100));
g.drawString("中国万岁!",400,400);
g.fillOval(400,100,200,100);
g.draw3DRect(800, 100, 100, 100,true);
}
} 展开
import java.awt.Graphics2D;
import java.awt.event.WindowStateListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
class iPaint{
public static void main(String[]args){
new DrawFrame();
}
}
class DrawFrame extends JFrame {
DrawFrame(){
DrawPanel dp=new DrawPanel();
this.add(dp);
setBounds(100,100,1000,500);
setResizable(false);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
class DrawPanel extends JPanel{
public void paint(Graphics g){
Color c=g.getColor();
Image a=Toolkit.getDefaultToolkit().getImage(DrawPanel.class.getResource("/Copy of M.jpg"));
g.drawImage(a, 80, 100, 250, 128, this);
g.setColor(Color.green);
g.setFont(new Font("华文彩云",Font.ROMAN_BASELINE,100));
g.drawString("中国万岁!",400,400);
g.fillOval(400,100,200,100);
g.draw3DRect(800, 100, 100, 100,true);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询