附上相应代码
import java.awt.*;
import javax.swing.*;
public class Image extends JFrame
{
Button b1;
TextArea text;
Panel p1,p2;
public Image()
{
b1=new Button("图片");
text=new TextArea();
p1=new Panel();
p2=new Panel();
p1.setLayout(new FlowLayout());
p1.add(b1);
p2.add(text);
this.setLayout(new BorderLayout());
this.add(p1,BorderLayout.SOUTH);
this.add(p2,BorderLayout.CENTER);
this.setSize(1024,1024);
this.setBackground(Color.BLUE);
this.setVisible(true);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="Dialog")
{
font=new Font("Dialog",Font.ITALIC,15);
text.setFont(font);
text.setForeground(Color.RED);
}
else
{
}
public static void main(String args[])
{
new Image();
}
}
希望大家帮帮忙