java swing 按钮不显示
按钮迟迟不出现,网上说加了super.paint(g);也没用。555~~~packagegame01;importjavax.swing.*;importjava.aw...
按钮迟迟不出现,网上说加了super.paint(g);也没用。555~~~
package game01;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Test extends JFrame {
public Test()
{
this.setVisible(true);
this.setLocation(0,0);
this.setSize(700,700);
this.setLayout(null);
JPanel p1 = new JPanel();
p1.setLayout(null);
p1.setBounds(0,0,700,700);
JButton b1 = new JButton("b1");
b1.setBounds(0,0,100,100);
p1.add(b1);
this.add(p1);
}
public void paint(Graphics g)
{
super.paint(g);
BufferedImage bi = new BufferedImage(700,700,BufferedImage.TYPE_INT_RGB);
Graphics g2 = bi.createGraphics();
g2.setColor(Color.WHITE);
g2.fillOval(150, 150, 100, 100);
g.drawImage(bi, 0, 0, this);
}
/**
* @param args
*/
public static void main(String[] args)
{
Test test = new Test();
}
} 展开
package game01;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Test extends JFrame {
public Test()
{
this.setVisible(true);
this.setLocation(0,0);
this.setSize(700,700);
this.setLayout(null);
JPanel p1 = new JPanel();
p1.setLayout(null);
p1.setBounds(0,0,700,700);
JButton b1 = new JButton("b1");
b1.setBounds(0,0,100,100);
p1.add(b1);
this.add(p1);
}
public void paint(Graphics g)
{
super.paint(g);
BufferedImage bi = new BufferedImage(700,700,BufferedImage.TYPE_INT_RGB);
Graphics g2 = bi.createGraphics();
g2.setColor(Color.WHITE);
g2.fillOval(150, 150, 100, 100);
g.drawImage(bi, 0, 0, this);
}
/**
* @param args
*/
public static void main(String[] args)
{
Test test = new Test();
}
} 展开
展开全部
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Test extends JFrame
{
public Test()
{
this.setLocation(0, 0);
this.setSize(700, 700);
this.setLayout(null);
JPanel p1 = new JPanel();
p1.setLayout(null);
p1.setBounds(0, 0, 700, 700);
JButton b1 = new JButton("b1");
b1.setBounds(0, 0, 100, 100);
p1.add(b1);
this.add(p1);
this.setVisible(true);
}
public void paint( Graphics g )
{
super.paint(g);
BufferedImage bi =
new BufferedImage(700, 700, BufferedImage.TYPE_INT_RGB);
Graphics g2 = bi.createGraphics();
g2.setColor(Color.WHITE);
g2.fillOval(150, 150, 100, 100);
g.drawImage(bi, 0, 0, this);
}
/**
* @param args
*/
public static void main( String[] args )
{
Test test = new Test();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询