您可以在此处使用GridBagLayout而不是使用null布局:

GridBagConstraints gridBagConstraints;

panel = new JPanel();

findLabel = new javax.swing.JLabel();

findField = new javax.swing.JTextField();

replaceLabel = new javax.swing.JLabel();

replaceField = new javax.swing.JTextField();

replaceAllButton = new javax.swing.JButton();

replaceButton = new javax.swing.JButton();

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

panel.setLayout(new GridBagLayout());

findLabel.setText("Find :");

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.ipadx = 94;

gridBagConstraints.ipady = 30;

panel.add(findLabel, gridBagConstraints);

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.ipadx = 149;

panel.add(findField, gridBagConstraints);

replaceLabel.setText("Replace With :");

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.gridx = 0;

gridBagConstraints.gridy = 1;

gridBagConstraints.ipadx = 34;

gridBagConstraints.ipady = 23;

panel.add(replaceLabel, gridBagConstraints);

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.gridx = 1;

gridBagConstraints.gridy = 1;

gridBagConstraints.ipadx = 149;

panel.add(replaceField, gridBagConstraints);

replaceAllButton.setText("Find And Replace All");

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.gridx = 0;

gridBagConstraints.gridy = 2;

gridBagConstraints.ipady = 9;

panel.add(replaceAllButton, gridBagConstraints);

replaceButton.setText("Replace");

gridBagConstraints = new GridBagConstraints();

gridBagConstraints.gridx = 1;

gridBagConstraints.gridy = 2;

gridBagConstraints.ipadx = 99;

gridBagConstraints.ipady = 8;

panel.add(replaceButton, gridBagConstraints);

//adding panel to the jframe

getContentPane().add(panel, BorderLayout.CENTER);

pack();

java中panel显示不出来_为什么我的JPanel中的某些项目没有显示?相关推荐

  1. java获取表主外键_通过 jdbc 分析数据库中的表结构和主键外键

    文章转自:http://ivan4126.blog.163.com/blog/static/20949109220137753214811/ 在某项目中用到了 hibernate ,大家都知道 hib ...

  2. java list去除最后一个元素_如何快速删除list中的最后一个元素?

    (前言: 在项目中,在统计在线用户量及其行为方式的时候,想在项目如"/bob/recode/online",结果发现:把写日志的东西放到了ebin文件下,即:/bob/ebin/r ...

  3. pads中如何设置等长_如何在Windows 10中设置和使用Hyper-V进行OS虚拟化

    信息 Windows 10 Pro,Education和Enterprise版本带有内置的虚拟机管理程序客户端Hyper-V,允许用户在虚拟机上创建和运行其他操作系统.尽管Hyper-V主要是为运行W ...

  4. vue中data定义数字类型_[乐意黎原创] Vue中data定义的三种方式和区别

    在 Vue中,定义data时,经常有好几种写法,一不小心会混淆,这里彻底详述一下,以便记分清 . 一.在vue中,定义data可以有三种写法. 1. 第一种写法,data是一个对象. var app ...

  5. python中构造方法可以被继承吗_构造函数是在python中继承的吗

    我正在研究麻省理工学院6.00开放式课程的一个习题集,我有以下代码...在class Trigger(object): def evaluate(self, story): ""& ...

  6. 中运量71路线路图_浦东临港的中运量呼之欲出:临港地区已经成为上海建设的热土...

    2020年,浦东临港的中运量已经呼之欲出,临港地区也已经成为上海建设的热土. 本文回顾浦东临港的地区的中运量,根据上海市临港地区开发建设管理委员会公布的<临港地区中运量公交专项规划>,临港 ...

  7. 电路中滤波电容和退耦电容_详解电源滤波电路中的高频滤波电容电路

    图2-12所示是电源滤波电路中的高频滤波电路.电路中,一个容量很大的电解电容C1(2200µF)与一个容量很小的电容C2(0.01µF)并联,C2是高频滤波电容,用来进行高频成分的滤波,这种一大一小两 ...

  8. 在struts2中push方法的使用_【干货】网版印刷中水墨使用注意事项及助剂使用方法...

    导LEAD语 在印刷生产中,水性油墨的黏度.干燥速度和PH值等等都会直接影响印刷质量,那么具体到网版印刷中,在使用水性油墨时应该注意哪些问题呢?常用的印刷助剂都有哪些特点和使用方法? 编辑:华印纸箱彩 ...

  9. css中如何实现帧布局_浅谈web前端中的表格布局与CSS盒子布局

    在web前端设计排版时我们可能会用到表格布局和div+CSS布局,但现在主要使用后者,为何?今天我们来谈一谈两者之间的发展和原理. 话不多说下面来干货 发展过程 上个世纪Web开发人员流行使用表格进行 ...

最新文章

  1. MySQL优化篇:IN VS EXISTS
  2. 家用电器用户行为分析与事件识别_用户行为分析系统
  3. Android日志打印类LogUtils,能够定位到类名,方法名以及出现错误的行数并保存日志文件...
  4. Xfire方式开发和解析webservice
  5. Qtcreator快速入门
  6. Vue+ElementUI: 手把手教你做一个audio组件
  7. Eclipse从github上clone项目到开发环境
  8. SSRS: How to Display Checkbox on Report
  9. python 地址_python 解析地址 | 学步园
  10. 开源上网行为管理_做好企业上网行为管理作用大
  11. 本田da屏怎么进wince系统_本田新XR-V首试:配置提升,依然好开
  12. java.lang.InstantiationException:
  13. 0909 对编译原理的想法
  14. 数据库java_(六) Java数据库
  15. DisplayUtils
  16. 计算机vb里代码里的双引号,在VB中使用字符串中的左双引号
  17. c 使用mysql的语句_在 MySQL 数据库中使用C 履行SQL的语句
  18. 计算机财务管理系统基础知识,计算机财务管理实习报告
  19. 用户注册文件register.html的编写
  20. 万由nas风扇速度控制

热门文章

  1. Sketch2Code 前端智能AI-识别草图生成代码
  2. 403 常见原因 java_科普 httpClient 403 Forbidden (JAVA方向分析)
  3. 【Essay】开始研究生小论文的撰写
  4. python cprofile_python 中 cprofile 分析 多进程程序
  5. 使用maven启动web项目报错
  6. Test on 01/19/2019
  7. Python之网络编程(一)
  8. iOS - 视频开发
  9. Docker-创建支持ssh服务的镜像
  10. css-布局1-基本属性