Bootstrap

java界面添加组件_Java 图形用户界面-向JApplet添加组件

1334480460_1146.jpg/**

作者:wwj

日期:2012/4/15

功能:实现在JApplet中添加组件

**/

import javax.swing.*;

import java.awt.*;

import java.awt.Color;

public class JAp extends JApplet

{

Container c;

JPanel p1,p2;

JButton button1,button2,button3;

JLabel label;

public void init()

{

c=getContentPane();

p1=new JPanel(new FlowLayout());

p2=new JPanel(new FlowLayout());

ImageIcon icon=new ImageIcon("image/first_16x16.gif"," ");

button1=new JButton(icon);

button2=new JButton(new ImageIcon("image/ok_16x16.gif"));

button3=new JButton(new ImageIcon("image/down_16x16.gif"));

label=new JLabel("图像标签",

new ImageIcon("image/100.jpg"),SwingConstants.CENTER);

c.setBackground(new Color(255,255,204));

p1.setBackground(new Color(255,255,204));

p2.setBackground(new Color(255,255,204));

button1.setToolTipText("向上翻页按钮");

button2.setToolTipText("跳转按钮");

button3.setToolTipText("向下翻页按钮");

c.add(p1,BorderLayout.NORTH);

c.add(p2,BorderLayout.SOUTH);

p1.add(button1);

p1.add(button2);

p1.add(button3);

p2.add(label);

}

}

;