摘要: import java.awt.*;import javax.swing.*; public class GridBagDemo extends JFrame { public static void main(String args[]) { GridBagDemo demo = new Grid 阅读全文
posted @ 2016-05-31 10:59 榆次老城 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 3)CardLayout布局管理器 CardLayout布局管理器以时间而非空间来管理它里面的组件,它将加入容器的所有组件看成一叠卡片,每次只要最上面的那个Component才可见。就好像一副扑克牌,它们叠在一起,每次只有最上面的一张扑克牌可见。CardLayout提供了如下两个构造器: 1)Car 阅读全文
posted @ 2016-05-31 09:42 榆次老城 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 2)、BorderLayout管理器 它将容器中的组件放置在特定的位置,该位置有5个方位:东、南、西、北、中。其中4个位置由方向罗盘方向指定,另外一个由中心区域指定。 与GridLayout类相同,BorderLayout也会将所有可用空间都分配给组件。在周围放置4个边界组件后,余下的空间都分配给中 阅读全文
posted @ 2016-05-31 09:41 榆次老城 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 1)、FlowLayout管理器 它是面板的默认布局管理器类,使用时,想在页面中排列英文单词那样排列组件:从左到右,当前行没有空间后进入下一行。 当框架中添加进组件时,可以使用如下代码示例来调用浮动的布局: FlowLayout layout = new FlowLayout(); setLayou 阅读全文
posted @ 2016-05-31 09:40 榆次老城 阅读(193) 评论(0) 推荐(0) 编辑
摘要: // 本例用于演示线程终止 class E13_1{ public static void main(String args[]) { A a=new A(); Thread thread=new Thread(a); thread.setName("zhang san"); thread.star 阅读全文
posted @ 2016-05-17 11:08 榆次老城 阅读(86) 评论(0) 推荐(0) 编辑
摘要: // 本例用于演示挂起和恢复!class E13{ public static void main(String args[]) { A a=new A(); Thread thread=new Thread(a); thread.setName("zhang san"); thread.start 阅读全文
posted @ 2016-05-17 11:01 榆次老城 阅读(103) 评论(0) 推荐(0) 编辑
摘要: class TicketSeller //负责卖票的类。{ int fiveNumber=1,tenNumber=0,twentyNumber=0; public synchronized void sellTicket(int receiveMoney) { if(receiveMoney==5) 阅读全文
posted @ 2016-05-13 00:52 榆次老城 阅读(121) 评论(0) 推荐(0) 编辑
摘要: A.java class T implements Runnable { int money=10000; int goods=100; Thread t1,t2; T() { t1=new Thread(this); t2=new Thread(this); } // public synchro 阅读全文
posted @ 2016-05-12 22:41 榆次老城 阅读(91) 评论(0) 推荐(0) 编辑
摘要: class T implements Runnable { Thread t1,t2; T() { t1=new Thread(this); t2=new Thread(this); } public void run() { if(Thread.currentThread()==t2) { t1. 阅读全文
posted @ 2016-05-12 22:10 榆次老城 阅读(269) 评论(0) 推荐(0) 编辑
摘要: class Ex5_17_1 { public static void main(String args[]) { try{ int x=1; int y=0; int z=x/y; } catch(Exception e) { System.out.println(e.toString()); } 阅读全文
posted @ 2016-04-28 22:30 榆次老城 阅读(87) 评论(0) 推荐(0) 编辑