Professional Documents
Culture Documents
V d vi nt Button
addActionListener(ActionListener)
19
20
Nhn (Label)
Nhn c dng trnh by mt chui vn bn ra mn hnh Mt s phng thc ca Label:
public Label(); // to nhn public Label(String s); // to nhn vi ni dung s public Label(String s, int align); // to v canh l void setText(String s); // t ni dung nhn void setAlignment(int align); // canh l nhn ...
21
Nhn (Label)
import java.applet.Applet; import java.awt.*; public class DemoLabel extends Applet { private Label label; public void init() { Font font = new Font("Courier", Font.BOLD, 20); label = new Label("Thu nghiem voi Label"); label.setFont(font); add(label); } public void paint(Graphics g) { showStatus("Noi dung cua Label la: + label.getText()); }
22
Nhn (Label)
23
Nt nhn (Button)
Mt s phng thc ca Button
Button(); // to nt nhn Button(String s); // to nt nhn c tn s void setLabel(String s); // i tn nt String getLabel(); // ly tn nt nhn
24