📄 flow.java
字号:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Flow extends Applet implements ItemListener,ActionListener
{
Frame window=new Frame("This is the frame Title Bar!");
Button btn=new Button("Destroy the frame");
CheckboxGroup align=new CheckboxGroup();
Checkbox Center=new Checkbox("flow center arrangement",align,false);
Checkbox Right=new Checkbox("Flow right Arrangement",align,false);
Checkbox Left=new Checkbox("Flow Left Arrangement",align,false);
Checkbox Grid=new Checkbox("Grid(or Grid Bag) Arrangement",align,false);
Checkbox Card=new Checkbox("card(Hypepr card)Arrangement",align,false);
public void init()
{
add(new Label("the frame created by this applet has a Border layout"));
add(new Label("Resize the frame to see now the components"));
add(new Label("automatically adjust click on an option below "));
add(new Label("the lalyout of the frame will change"));
add(new Label("You must use the applets button to delete the frame"));
add(Center);
add(Right);
add(Left);
add(Grid);
add(Card);
add(new Label("Hit this button to"));
add(btn);
btn.addActionListener(this);
Center.addItemListener(this);
Right.addItemListener(this);
Left.addItemListener(this);
Grid.addItemListener(this);
Card.addItemListener(this);
add(new Label("."));
window.setLayout(new BorderLayout(10,15));
window.add("North",new Button("one"));
window.add("South",new Button("Two"));
window.add("East",new Button("Three"));
window.add("West",new Button("Four"));
window.add("Center",new Button("Five"));
window.setSize(300,200);
window.show();
}
public void itemStateChanged(ItemEvent e)
{
Object f1=e.getItem();
if(Center.getState())
{
window.hide();
window.dispose();
window.setLayout(new FlowLayout(FlowLayout.CENTER,2,2));
window.setSize(300,200);
window.show();
}
if(Left.getState())
{
window.hide();
window.dispose();
window.setLayout(new FlowLayout(FlowLayout.LEFT,2,2));
window.setSize(300,200);
window.show();
}
if(Right.getState())
{
window.hide();
window.dispose();
window.setLayout(new FlowLayout(FlowLayout.RIGHT,2,2));
window.setSize(300,200);
window.show();
}
if(Grid.getState())
{
window.hide();
window.dispose();
window.setLayout(new GridLayout(2,3,5,10));
window.setSize(300,200);
window.show();
}
if(Card.getState())
{
window.hide();
window.dispose();
window.setLayout(new CardLayout());
window.setSize(300,200);
window.show();
}
}
public void actionPerformed(ActionEvent e)
{
window.hide();
window.dispose();
}
public Insets getInsets()
{
return new Insets(10,20,30,40);
}
}
//<applet code="Flow.class" height=500 width=500> </applet >
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -