代码如下:
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class Pic extends JFrame
{
private JButton
b1 = new JButton("button1"),
b2 = new JButton("button2"),
b3 = new JButton("button3"),
b4 = new JButton("button4"),
b6 = new JButton("button6"),
b5 = new JButton("button5");
private Panel panel1 = new Panel();
private JPanel panel2 = new JPanel();
public Pic()
{
this.setTitle("图像处理");
this.setSize(900, 700);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1.img = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("meishi.jpg"));
panel2.add(b1);
panel2.add(b2);
panel2.add(b3);
panel2.add(b4);
panel2.add(b5);
panel2.add(b6);
panel1.repaint();
panel1.setBackground(Color.darkGray);
panel2.setBackground(Color.CYAN);
this.add(panel1,BorderLayout.CENTER);
this.add(panel2,BorderLayout.SOUTH);
}
public static void main(String[] args)
{
Pic pic = new Pic();
}
}
class Panel extends JPanel
{
Image img = null;
public void paint(Graphics g)
{
super.paint(g);
g.drawImage(img,0,0,300,200,this);
}
}
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
我给你留过代码了,不能用吗