JAVA学习

事件处理
Lowlevel Event 指一些低阶底层的事件
Semantic Event 指一些有意义的动作
一些事件Listener对应的Adapter类
WindowListener – WindowAdapter
MouseListener – MouseAdapter
MouseMotionListener – MouseMotionAdapter
KeyListener – KeyAdapter
ContainerListener – ContainerAdapter
FocusListener – FocusAdapter
ComponentListener – ComponentAdapter

容器和版面配置
Frame f=new Frame([窗口标题]);
f.setSize(高,宽);
f.setVisible(true/false);是否可见

Panel p = new Panel();
p.setBackground(Color red);设置背景颜色
p.setSize(,);

BorderLayout
Button b=new Button(“按钮标题”);
f.add(b,BorderLayout.EAST/SOUTH/WEST/NORTH/CENTER);
f.pack();
设置之间距离
BorderLayout b = new BorderLayout(水平,垂直);
f.setLayout(b);

BorderLayout b = new BorderLayout();
b.setHgap(10);
b.setVgap(10);
f.setLayout(b);

FlowLayout
f.setLayout(new FlowLayout());
f.add(按钮);

f.setLayout(new FlowLayout(FlowLayout.RIGHT/LEFT/CENTER));设定对齐方式

FlowLayout f= new FlowLayout();
f.setAlignment(FlowLayout.LEFT);

FlowLayout f=new FlowLayout(FlowLayout.RIGHT,10,20);设定间距

CardLayout
CardLayout card=new CardLayout();
f.setLayout(card);
card.next(f);next/previous/first/last/show

GridLayout
f.setLayout(new GridLayout(2,3));2*3的表格
f.setRows
f.setColumns

GridBagLayout
GridBagConstraints cons = new GridBagConstraints();
cons.gridx = att[0];
cons.gridy = att[1];
cons.gridwidth = att[2];
cons.gridheight = att[3];
cons.fill = att[4];
cons.anchor = att[5];
cons.weightx = att[6];
cons.weighty = att[7];
cons.insets = new Insets(att[8], att[9], att[10], att[11]);
cons.ipadx = att[12];
cons.ipady = att[13];
con.add(com, cons);

*java.util.Arrays API应用
*toString打印数组
*deepToString打印对象数组
*equals比较数组
*deepEquals比较对象数组
*sort排序
*binarySearch查找位置

类与对象,类成语与实例成员,成员(属性,方法),继承,构造函数,多态与封装,重载,遮蔽,改写
抽象类 abstract,接口 interface implements,
public protected (default/package) private final static super this
类的声明 [<修饰符>s] class <类名称> [extends<类名称>] [implements<接口名称>s]
{[<程序代码>]}
方法的声明 [<修饰符>s] <返回值类型> <方法名称> ([<参数>s])
{[<程序代码>]}
构造函数声明 <修饰符> <类名称> ([<参数>s])
{<初始化用的程序代码>}
对象的声明 [<修饰符>s] <对象类型> <对象名称> [=产生对象];
对象的使用 <对象/类名称>.<方法名称> ([参数]s)/<属性名称> [([<参数>s)];
类成员的调用 <类名称>.<类成员名称>
接口声明 <修饰符> interface <接口名称> [extends <接口名称>s]

变量英文单词之间用下划线,或者每个单词第一个字母大写
包:英文单词全部小写
类:第一个英文单词第一个字母大写
接口:和类一样
属性:第一个英文单词第一个字母小写,其他单词的第一个字母大写
方法:和属性一样
常量:英文单词全部大写,且两两之间用下划线隔开
设定属性值:以set开头
取得属性值:以get开头
boolean类型取得:以is开头

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部