GroupLayout 是一个 LayoutManager,它将组件按层次分组,以决定它们在 Container 中的位置。GroupLayout 主要供生成器使用,但也可以手工编码。分组由 Group 类的实例来完成。GroupLayout 支持两种组。串行组 (sequential group) 按顺序一个接一个地放置其子元素。并行组 (parallel group) 能够以四种方式对齐其子元素。
每个组可以包含任意数量的元素,其中元素有 Group、Component 或间隙 (gap)。间隙可被视为一个具有最小大小、首选大小和最大大小的不可见组件。此外,GroupLayout 还支持其值取自 LayoutStyle 的首选间隙。
GroupLayout是一个很重要的是额布局管理器,在jdk 1.6才加入,配合其它的管理器可以实现很好的界面。
。。
GroupLayout必须要设置它的GroupLayout.setHorizontalGroup和GroupLayout.setVerticalGroup。
GroupLayout.setHorizontalGroup是指按照水平来确定,下面例子“账号”和“密码”是一个级别的,其它的组件也是一个级别的。详情请看代码
GroupLayout.setVerticalGroup。是按照垂直来确定的。他们的级别是按照Group去设置组件的优先级别,级别越高就显示越上面。
GroupLayout.setHorizontalGroup(SequentialGroup(ParallelGroup(component)));
大概就是按照这个顺序去添加,当然不是就这么简单设置,多个component添加到ParallelGroup,然后多个ParallelGroup添加到SequentialGroup里面,
然后就设置到GroupLayout
下面的实例,设置GroupLayout.setHorizontalGroup,就是把2和4添加到一个ParallelGroup.addComponent(component),其它1,3,5,6,7,8添加到另一个ParallelGroup,然后把这两个ParallelGroup按照顺序添加到SequentialGroup.addGrou(ParallelGroup);
/**
* @author :陶伟基 ,微博:http://weibo.com/taoandtao
* @date :2012/12/10
* @place:广州大学华软软件学院
*/
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class MyFrame extends javax.swing.JFrame {
public static void main(String[] args) {
MyFrame f = new MyFrame();
}
JLabel label1;
JLabel label2;
JLabel label3;
JTextField tf;
JPasswordField psf;
JRadioButton rb1;
JRadioButton rb2;
JButton bt1;
JButton bt2;
public MyFrame() {
this.setVisible(true);
this.setSize(250, 220);
this.setVisible(true);
this.setLocation(400, 200);
label1 = new JLabel("华软BBS快捷登陆");
label2 = new JLabel("账号:");
label3 = new JLabel("密码:");
tf = new JTextField();
psf = new JPasswordField();
rb1 = new JRadioButton("记住密码");
rb2 = new JRadioButton("自动登陆");
bt1 = new JButton("登陆");
// 为指定的 Container 创建 GroupLayout
GroupLayout layout = new GroupLayout(this.getContentPane());
this.getContentPane().setLayout(layout);
//创建GroupLayout的水平连续组,,越先加入的ParallelGroup,优先级级别越高。
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
hGroup.addGap(5);//添加间隔
hGroup.addGroup(layout.createParallelGroup().addComponent(label2)
.addComponent(label3));
hGroup.addGap(5);
hGroup.addGroup(layout.createParallelGroup().addComponent(label1)
.addComponent(psf).addComponent(rb1).addComponent(rb2)
.addComponent(tf).addComponent(bt1));
hGroup.addGap(5);
layout.setHorizontalGroup(hGroup);
//创建GroupLayout的垂直连续组,,越先加入的ParallelGroup,优先级级别越高。
GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(label1));
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(label2)
.addComponent(tf));
vGroup.addGap(5);
vGroup.addGroup(layout.createParallelGroup().addComponent(label3)
.addComponent(psf));
vGroup.addGroup(layout.createParallelGroup().addComponent(rb1));
vGroup.addGroup(layout.createParallelGroup().addComponent(rb2));
vGroup.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addComponent(bt1));
vGroup.addGap(10);
//设置垂直组
layout.setVerticalGroup(vGroup);
}
}
移动浏览器内核
Android和iOS上使用的浏览器内核都是WebKit内核,UC 的U3内核和QQ的X5内核都是在开源的WebKit基础上修改的,或者说是WebKit内核的分支版本。浏览器使用的WebKit版本可以在UserAgent中查看。
如:
Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; MI-ONE Plus Build/GINGERBREAD) UC AppleWebKit/534.31 (KHTML, like Gecko) Mobile Safari/534.31
Webkit包含WebCore和JavascriptCore
以下为android4.0 WebKit模块框架图(android4使用的jsCore为V8)
<!--[endif]-->
webkit内核版本
iOS6 536
iOS5 534
iOS4 533
Android2.3 533
Android4.x 534
其他更多系统webkit版本情况可查阅:
http://www.quirksmode.org/webkit_mobile.html
浏览器连接
每host最大连接数:
iOS5 6
iOS4 4
iOS3 6
Android2-4 4
HTTP Pipelining(管线化)
iOS5开始默认打开Pipelining
Android浏览器一直都是打开的,默认最大同时发送3个请求
*以上请求和连接数Android系统在不同机型上会由厂商调整
Html5及CSS3等各系统版本移动浏览器支持情况
http://mobilehtml5.org/
已有 0 人发表留言,猛击->>这里<<-参与讨论
ITeye推荐
- —软件人才免语言低担保 赴美带薪读研!—
oyhk 学习笔记
好了费话不多说了,介绍下spring 结合redis是怎么操作数据的 这里我用了maven管理,由于简单嘛,依赖下包就行了..不用单独去依赖包,成了我的习惯
好了,下面是pom的代码
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>redis</groupId>
<artifactId>redis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
</dependencies>
</project>
在pom里添加了redis spring客户端的依赖,那么所有的jar包都会帮你自动下载下来,是不是很方便啊,哈
下面是spring-context.xml代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!--注解说明 -->
<context:annotation-config />
<!-- 把标记了@Controller注解的类转换为bean -->
<context:component-scan base-package="com.mkfree.**" />
<!-- redis工厂 -->
<bean id="jedisConnectionFactory"
p:host-name="192.168.9.140" p:port="6379" p:password="87980879" />
<!-- redis服务封装 -->
<bean id="redisService" >
</bean>
这里配置了一个跟spring 集成的redis客户端,ip port password自己定哦,这里我在redis配置文件了定义了需求密码认证,你们先不要用吧,为了简单起见
下面是RedisService,里面包含了对redis的方法,还有更多的方法没有去使用,这里当一个入门的小例子吧
package com.mkfree.redis.test;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import redis.clients.jedis.Jedis;
/**
* 封装redis 缓存服务器服务接口
* @author hk
*
* 2012-12-16 上午3:09:18
*/
public class RedisService {
/**
* 通过key删除(字节)
* @param key
*/
public void del(byte [] key){
this.getJedis().del(key);
}
/**
* 通过key删除
* @param key
*/
public void del(String key){
this.getJedis().del(key);
}
/**
* 添加key value 并且设置存活时间(byte)
* @param key
* @param value
* @param liveTime
*/
public void set(byte [] key,byte [] value,int liveTime){
this.set(key, value);
this.getJedis().expire(key, liveTime);
}
/**
* 添加key value 并且设置存活时间
* @param key
* @param value
* @param liveTime
*/
public void set(String key,String value,int liveTime){
this.set(key, value);
this.getJedis().expire(key, liveTime);
}
/**
* 添加key value
* @param key
* @param value
*/
public void set(String key,String value){
this.getJedis().set(key, value);
}
/**添加key value (字节)(序列化)
* @param key
* @param value
*/
public void set(byte [] key,byte [] value){
this.getJedis().set(key, value);
}
/**
* 获取redis value (String)
* @param key
* @return
*/
public String get(String key){
String value = this.getJedis().get(key);
return value;
}
/**
* 获取redis value (byte [] )(反序列化)
* @param key
* @return
*/
public byte[] get(byte [] key){
return this.getJedis().get(key);
}
/**
* 通过正则匹配keys
* @param pattern
* @return
*/
public Set<String> keys(String pattern){
return this.getJedis().keys(pattern);
}
/**
* 检查key是否已经存在
* @param key
* @return
*/
public boolean exists(String key){
return this.getJedis().exists(key);
}
/**
* 清空redis 所有数据
* @return
*/
public String flushDB(){
return this.getJedis().flushDB();
}
/**
* 查看redis里有多少数据
*/
public long dbSize(){
return this.getJedis().dbSize();
}
/**
* 检查是否连接成功
* @return
*/
public String ping(){
return this.getJedis().ping();
}
/**
* 获取一个jedis 客户端
* @return
*/
private Jedis getJedis(){
if(jedis == null){
return jedisConnectionFactory.getShardInfo().createResource();
}
return jedis;
}
private RedisService (){
}
//操作redis客户端
private static Jedis jedis;
@Autowired
@Qualifier("jedisConnectionFactory")
private JedisConnectionFactory jedisConnectionFactory;
}
下面是测试代码TestRedis.java
package com.mkfree.redis.test;
import java.util.Set;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* redis spring 简单例子
* @author hk
*
* 2012-12-22 上午10:40:15
*/
public class TestRedis {
public static void main(String[] args) throws InterruptedException {
ApplicationContext app = new ClassPathXmlApplicationContext("classpath:spring-context.xml");
//这里已经配置好,属于一个redis的服务接口
RedisService redisService = (RedisService) app.getBean("redisService");
String ping = redisService.ping();//测试是否连接成功,连接成功输出PONG
System.out.println(ping);
//首先,我们看下redis服务里是否有数据
long dbSizeStart = redisService.dbSize();
System.out.println(dbSizeStart);
redisService.set("username", "oyhk");//设值(查看了源代码,默认存活时间30分钟)
String username = redisService.get("username");//取值
System.out.println(username);
redisService.set("username1", "oyhk1", 1);//设值,并且设置数据的存活时间(这里以秒为单位)
String username1 = redisService.get("username1");
System.out.println(username1);
Thread.sleep(2000);//我睡眠一会,再去取,这个时间超过了,他的存活时间
String liveUsername1 = redisService.get("username1");
System.out.println(liveUsername1);//输出null
//是否存在
boolean exist = redisService.exists("username");
System.out.println(exist);