- 浏览: 2719664 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (1313)
- JS (65)
- CSS (6)
- html (30)
- dweamweaver工具相关 (2)
- Spry (1)
- DB (103)
- p2p (1)
- java (405)
- .net (3)
- oracle (24)
- struts (18)
- myeclipse (15)
- linux (49)
- SQL SERVER2008 (101)
- jsp (21)
- resume (1)
- other (1)
- ajax (3)
- 云计算 (2)
- excel (32)
- vss (1)
- 警戒 (1)
- eclipse (21)
- c (1)
- dialog designer (7)
- axis1.4 (4)
- webservice (11)
- CTI (1)
- svn (8)
- spring (27)
- tomcat (13)
- log4j (14)
- 网络应用 (7)
- mysql (59)
- bat (4)
- jdbc (1)
- 正式表达式 (1)
- hibernate (27)
- iphone (2)
- 系统应用 (107)
- servlet (3)
- vmware (2)
- php (12)
- JQuery (30)
- avaya (5)
- postgresql (19)
- java面试 (1)
- rose (1)
- Socket (1)
- xml (2)
- PowerDesign (3)
- visio (1)
- jstl (4)
- informix (2)
- assemble (2)
- English Study (2)
- IOS (9)
- CMMI (1)
- outlook (4)
- poi (1)
- hadoop (5)
- SAE (3)
- jor (1)
- jquery mobile (1)
- git (11)
- mina (1)
- ibatis (2)
- wordpress (2)
- 支付宝 (1)
- struts2 (14)
- apns (1)
- html5 (1)
- xampp (2)
- uml (2)
- 项目管理 (1)
- 敏捷开发 (1)
- 设计模式 (2)
- spark (1)
- maven (9)
- 微信公众平台 (1)
- json (2)
- junit (1)
- quartz (2)
- redis (2)
- memcache (1)
- android (3)
- 红杏 (1)
- postman (1)
- mybatis (5)
- iplat4j (1)
- windows (1)
- logback (1)
- Netty (1)
- wiki (1)
- dubbo (1)
- sonar (2)
- jenkins (2)
- mac (10)
- office (4)
- groovy (1)
- intellij (6)
- zookeeper (2)
- 诛仙 (1)
- MQ (2)
- docker (1)
- 2222 (0)
最新评论
-
代码改变生活:
虽然代码敲的头疼的要命,但是依然要感谢你,感谢您共享!!!!开 ...
jxl读取excel日期相差8小时 -
www3837:
org.slf4j.Logger 下载 -
hyztty:
wait_timeout = 86400 interacti ...
druid连接池 -
niaodanwangzi:
连接池可不是给你检测连接状态用的。是为了连接复用,减少连接数。 ...
druid连接池 -
supermine0903:
学习了 啦啦啦
多个路由器同时上网
GridBagLayout比较难懂。
写了个简单示例 ,如下,有时间再来解释:
把它放入ECLIPSE里,运行一下,自己感受感受,用到的图片自己随便找个,10*10的的就行。
package sh.xjh.invoke; import javax.swing.*; import java.awt.*; public class TwoColTwoRowPanel extends JFrame { private JPanel jContentPane = null; private JButton jb1; private JButton jb2; private JButton jb3; private JButton jb4; GridBagConstraints c; GridBagLayout gridBagLayout; //sub panel private JPanel jpUpHeadImg; private JPanel jpDownHeadImg; //subScrollPane private JScrollPane jspHistory; private JScrollPane jspSendMsg; //jtextArea private JTextArea jtaHistory; private JTextArea jtaSendMsg; //jlabel private JLabel jlUpHeadImg; private JLabel jlDownHeadImg; //jb JButton jbSendMsg; public TwoColTwoRowPanel(){ initilize(); //set size this.setSize(800,600); //set location this.setLocation(200, 100); //set visible this.setVisible(true); //set default close operation this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub TwoColTwoRowPanel mgbl=new TwoColTwoRowPanel(); } private void initilize(){ this.setContentPane(this.getContentPane()); } @Override public JPanel getContentPane() { // TODO Auto-generated method stub if(jContentPane==null){ jContentPane=new JPanel(); //set layout gridBagLayout=new GridBagLayout(); jContentPane.setLayout(gridBagLayout); c=new GridBagConstraints(); //add jspHistory c.fill=GridBagConstraints.BOTH; c.gridx=0; // c.gridy=0; c.gridwidth=1; c.gridheight=1; c.weightx=0.9; c.weighty=0.8; // makeButton(jContentPane,this.getJb1(),c,gridBagLayout); this.createSubComp(jContentPane, this.getJspHistory(), c, gridBagLayout); //add jpUpHeadImg // c.fill=GridBagConstraints.BOTH; c.gridx=1; // c.gridy=0; c.gridwidth=1; c.weightx=0.1; c.weighty=0.2; // makeButton(jContentPane,this.getJb2(),c,gridBagLayout); this.createSubComp(jContentPane, this.getJpUpHeadImg(), c, gridBagLayout); //add JspSendMsg // c.fill=GridBagConstraints.BOTH; c.gridx=0; c.gridy=1; c.gridwidth=1; c.gridheight=1; c.weightx=0.9; c.weighty=0.8; // makeButton(jContentPane,this.getJb3(),c,gridBagLayout); this.createSubComp(jContentPane, this.getJspSendMsg(), c, gridBagLayout); //add jpDownHeadImg c.gridx=1; c.gridy=1; // c.fill=GridBagConstraints.NONE; c.gridwidth=1; c.weightx=0.1; c.weighty=0.2; // makeButton(jContentPane,this.getJb4(),c,gridBagLayout); this.createSubComp(jContentPane, this.getJpDownHeadImg(), c, gridBagLayout); //add jbSendMsg c.gridx=1; c.gridy=2; c.gridwidth=1; this.createSubComp(jContentPane, this.getJbSendMsg(), c, gridBagLayout); } return jContentPane; } public JButton getJb1() { if(jb1==null){ jb1=new JButton("Button1"); } return jb1; } public JButton getJb2() { if(jb2==null){ jb2=new JButton("Button2"); } return jb2; } public JButton getJb3() { if(jb3==null){ jb3=new JButton("Button3"); } return jb3; } public JButton getJb4() { if(jb4==null){ jb4=new JButton("Button4"); } return jb4; } /** * makeButton with constraints * @param jpanel * @param jb * @param c */ private void makeButton(JPanel jpanel ,JButton jb ,GridBagConstraints c ,GridBagLayout gridBagLayout){ gridBagLayout.setConstraints(jb,c); jpanel.add(jb); } /** * createSubPanel * @param jpanel * @param subJpanel * @param c * @param gridBagLayout */ private void createSubComp(JPanel jpanel ,JComponent subPanel ,GridBagConstraints c ,GridBagLayout gridBagLayout){ gridBagLayout.setConstraints(subPanel,c); jpanel.add(subPanel); } public JScrollPane getJspHistory() { if(jspHistory==null){ jspHistory=new JScrollPane(this.getJtaHistory()); } return jspHistory; } public JScrollPane getJspSendMsg() { if(jspSendMsg==null){ jspSendMsg=new JScrollPane(this.getJtaSendMsg()); } return jspSendMsg; } public JTextArea getJtaHistory() { if(jtaHistory==null){ jtaHistory=new JTextArea("History:"); jtaHistory.setEditable(false); } return jtaHistory; } public JTextArea getJtaSendMsg() { if(jtaSendMsg==null){ jtaSendMsg=new JTextArea(); } return jtaSendMsg; } public JPanel getJpUpHeadImg() { if(jpUpHeadImg==null){ jpUpHeadImg=new JPanel(); jpUpHeadImg.setLayout(new BorderLayout()); jpUpHeadImg.add(this.getJlUpHeadImg()); // jpUpHeadImg.setBackground(new Color(125,125,125)); } return jpUpHeadImg; } public JPanel getJpDownHeadImg() { if(jpDownHeadImg==null){ jpDownHeadImg=new JPanel(); jpDownHeadImg.setLayout(new BorderLayout()); jpDownHeadImg.add(this.getJlDownHeadImg()); // jpDownHeadImg.setBackground(Color.blue); } return jpDownHeadImg; } public JLabel getJlUpHeadImg() { jlUpHeadImg=new JLabel(new ImageIcon("image/djwanHead.jpg")); return jlUpHeadImg; } public JLabel getJlDownHeadImg() { jlDownHeadImg=new JLabel(new ImageIcon("image/xiaoXinXinHead2.jpg")); return jlDownHeadImg; } public JButton getJbSendMsg() { if(jbSendMsg==null){ jbSendMsg=new JButton("send"); } return jbSendMsg; } }
发表评论
-
普通类和线程类的区别
2017-02-18 21:44 1224假设一个类是SubThread,它的init( ... -
最近一些心得
2017-02-08 16:01 8771、Mac starUML在导出png图片时,不要用s ... -
druid连接池
2016-09-14 16:00 5160环境:Ubuntu+Mysql5.5 近期一直报 ... -
罕见问题记录
2016-08-24 17:56 9071、如果提示对catalina.out无权限。 此时 ... -
Java Security
2016-08-24 17:50 944背景: 公司有某些场景需要向第三方提供服务, ... -
kafka java demo
2016-07-10 20:51 6741环境:ubuntu10 2台(32位)+JDK1.8(32 ... -
autowired resource component
2016-05-11 15:23 933背景:同样的bean类型有2个。 尝试用autowire ... -
eclipse 部署spring源码经验之谈
2016-05-08 23:41 16931、junit加载applicationCont ... -
main函数中如何实例化内部类
2016-04-30 22:50 1191需要先new一个父类的对象,然后用父类对象.new 内 ... -
java synchronized 串行
2016-04-30 22:42 1180背景:大家都知道用synchronized来实现加锁 ... -
观察者 Listener是什么意思
2016-02-26 10:40 932从观察者设计模式来看,Listener翻译成中文就是 ... -
UTF-8和Unicode的关系
2016-02-25 16:34 970utf-8只实际了unicode的第一个plane ... -
dubbo
2016-02-18 15:48 7621、配置dubbo.xml,主要是连接到dubbo服务 ... -
datetime格式化
2016-02-18 11:25 832org.joda.DateTime格式化成特定的Str ... -
Java接口中的成员变量为什么必须是public static final?
2016-01-10 16:20 1360必须是final的,否则多个类全继承他后,每个人都改, ... -
抽象类能不能有构造函数
2016-01-10 16:06 1021可以有,但是不能用,即不能new。 refur ... -
workspace workset设置
2016-01-10 15:51 1202背景:当eclipse里面的项目太多时,看上去非常凌 ... -
eclipse一直building workspace
2015-12-10 19:37 794我这里的原因很特殊,是因为在配置spring d ... -
序列化和反序列化
2015-12-10 19:19 915说白了,序列化后 ... -
java.net.bindexception cannot assign requested address jvm_bind
2015-12-10 19:14 1387我的原因是hosts文件中关于127.0.0.1有2个 ...
相关推荐
### Java中GridBagLayout的用法详解 #### 一、GridBagLayout简介 GridBagLayout是一种高度灵活且功能强大的布局管理器,在Java Swing图形用户界面编程中被广泛使用。相较于其他布局管理器如FlowLayout或...
Java Swing GridBagLayout,很详细的Demo,对GridBagLayout如何使用做全面的讲解
在Java Swing中,`GridBagLayout`是一种非常灵活的布局管理器,允许开发者精确控制组件在容器中的位置和大小。由于其灵活性,`GridBagLayout`成为创建复杂、自定义布局的理想选择,但它的确比其他布局管理器更复杂。...
GridBagLayout 布局详解 GridBagLayout 是 Java Swing 编程中的一种强大且灵活的布局管理器,它可以实现几乎所有你想要的布局。通过设置 GridBagConstraints 对象的参数,可以控制组件在显示区域中的位置、大小和...
在Java Swing中,`GridBagLayout`是一种灵活的布局管理器,它允许开发者精确地控制组件在容器中的位置和大小。而`JTable`是Swing提供的一种用于展示表格数据的组件,通常用于数据的显示、编辑和排序。这篇博客文章...
Java中的GridBagLayout布局管理器是Java Swing中用于组织组件的一种高级布局策略,它提供了最大的灵活性,能够处理不同大小的组件并允许它们跨多个网格单元,甚至部分重叠。GridBagLayout通过GridBagConstraints对象...
本文通过代码示例的方式介绍了Swing的GridBagLayout布局样式的应用,不拘泥于JDK文档教条方式的陈述,图形效果图与文字相结合,讲解直观而浅显易懂,另外,示例代码中还包含了BorderLayout、FlowLayout等布局的应用...
这是为初初学者提供练习的代码,具有很强的指导效果哈~~~
在Java GUI编程中,`GridBagLayout`是一个强大的布局管理器,它允许开发者精确地控制组件在容器中的位置和大小。与其他布局管理器不同,`GridBagLayout`提供了更大的灵活性,使得开发者能够创建复杂的界面布局。以下...
在MATLAB编程环境中,`GridBagLayout`是一个用于组织和管理图形用户界面(GUI)组件的强大工具。这个布局管理器允许开发者以灵活的方式排列和调整`uicontrols`(如按钮、文本框等)、`uipanels`和`uicontainers`的...
GridBagLayout是Java Swing布局管理器之一,但MATLAB的 GUIDE工具(GUI Development Environment)同样支持它,使得我们可以利用GridBagLayout来创建复杂且灵活的布局。GridBagLayout允许在GUI窗口中动态地排列组件...
Java中的GridBagLayout布局管理器是Java Swing中最复杂但也是最灵活的布局管理工具,它允许容器中的组件具有不同的大小,可以跨越多个网格,并且组件之间可以部分重叠。理解GridBagLayout的关键在于掌握它的网格单元...
在这个例子中,`j4`的`weightx`被设置为非零值,意味着它会在水平方向上拉伸。如果`j4`的`gridwidth`设置为1,而`j6`的`weightx`设置为1,则`j6`所在的列也会拉伸,导致`j4`不会拉伸。因此,要让`j4`跟随`j6`拉伸,...
在 Swing 中,容器(如JFrame)用于承载组件,你可以使用不同的布局管理器(如FlowLayout、BorderLayout、GridLayout、CardLayout和GridBagLayout)来控制组件的排列方式。这些例子会展示如何根据需要选择和使用不同...
Java中的GridBagLayout布局管理器是Java Swing中最复杂但也是最灵活的布局管理工具,它允许组件在容器中以不同的大小存在,甚至可以跨多个网格并部分重叠。这种布局管理器将容器划分为一系列网格单元,每个组件可以...
Java 网格包 GridBagLayout 布局管理器专题 Java 网格包 GridBagLayout 布局管理器是 Java 语言中最复杂和灵活的布局管理器之一。与网格布局管理器不同的是,网格包布局管理器允许容器中各个组件的大小各不相同,还...
Java Swing GridBagLayout网格袋布局的实现 Java Swing GridBagLayout网格袋布局是Java Swing中一种常用的布局管理器,能够灵活地管理组件的布局。GridBagLayout通过将组件安排在网格单元格中来管理布局,每个组件...
以下是一个简单的例子,展示了如何使用`GridBagLayout`创建一个左右选择框: ```java import javax.swing.*; import java.awt.*; public class GridBagLayoutExample { public static void main(String[] args) {...
### Java中GridBagLayout布局管理器的详细讲解 #### 一、引言 在Java图形用户界面(GUI)设计中,界面布局是非常重要的一个环节。合理的布局不仅能够提高应用程序的美观性,还能够提升用户体验。Java提供了多种...