Swing的布局方式当选择使用JPanel和顶层容器的contentpane时,需要考虑布局管理。JPanel缺省是初始化一个FlowLayout,而contentpane缺省是初始化一个BorderLayout。下面将分别介绍几种最常用的布局管理器:FlowLayout、BorderLayout、BoxLayout、CardLayout、GridLayout和GridB..
参考链接: http://blog.csdn.net/x_iya/article/details/12677215 http://blog.csdn.net/lyxaiclr/article/details/7366145/ ...
分类:
编程语言 时间:
2016-09-03 12:06:19
阅读次数:
259
这个程序演示了几种不同的绘图等方法 import javax.swing.*;import java.awt.event.*;import java.awt.*;class MyPanel_0 extends JPanel { public void paintComponent( Graphics ...
分类:
编程语言 时间:
2016-08-28 22:22:46
阅读次数:
208
添加面板容器将窗体分块:JPanel 北,南,东,西,中 5块 北:JPanel northJP=new JPanel(); northJP.setPreferredSize(new Dimension(0,50)); northJP.setBackground(Color.gray); //添加图 ...
分类:
其他好文 时间:
2016-08-27 19:24:59
阅读次数:
217
exercise15-01
package chapter15;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class exercise15_01 exten...
分类:
编程语言 时间:
2016-08-13 18:19:48
阅读次数:
414
1.显示任意时间时钟
2.设置三个可见性属性 分别表示时针,分针,秒针的可见性
3.一个精细的时钟
主类:StillClock
@SuppressWarnings("serial")
class DetailedClock extends JPanel {
private int hour;
private int minute;
private int secon...
分类:
编程语言 时间:
2016-08-12 23:57:36
阅读次数:
510
把图片文件放入当前文件
package chapter15;
import java.awt.Graphics;
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public c...
分类:
系统相关 时间:
2016-08-12 18:27:37
阅读次数:
215
exercise12_1 练习FLowLayout
package chapter12;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public cla...
分类:
编程语言 时间:
2016-08-04 21:42:12
阅读次数:
360
package chapter12;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFra...
分类:
编程语言 时间:
2016-08-03 13:43:37
阅读次数:
177
第一个实例是动态时钟,其中StillClock是静态时钟的类。 第二个实例是一个可以横向移动的字符串。 两个实例都是采用了Timer类。 不同的地方在于,一个TimerListener定义在JFrame也就是外层框架中,一个TimerListener定义在内层,JPanel中。目前还分不清楚这两种情 ...
分类:
其他好文 时间:
2016-08-01 22:37:46
阅读次数:
176