swing中JPanel如何实现分组框的效果以及设置边框颜色
2012-03-20 17:51
661 查看
代码如下:
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class JFrameBackground extends JFrame {
public JFrameBackground(){
this.setTitle("我的swing界面");
this.setLayout(new FlowLayout());
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createTitledBorder("分组框")); //设置面板边框,实现分组框的效果,此句代码为关键代码
buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red));//设置面板边框颜色
JButton button = new JButton("我的按钮");
buttonPanel.add(button);
this.setSize(300, 300);
this.getContentPane().add(buttonPanel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
new JFrameBackground();
}
}
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class JFrameBackground extends JFrame {
public JFrameBackground(){
this.setTitle("我的swing界面");
this.setLayout(new FlowLayout());
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createTitledBorder("分组框")); //设置面板边框,实现分组框的效果,此句代码为关键代码
buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red));//设置面板边框颜色
JButton button = new JButton("我的按钮");
buttonPanel.add(button);
this.setSize(300, 300);
this.getContentPane().add(buttonPanel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
new JFrameBackground();
}
}
相关文章推荐
- swing中JPanel如何实现分组框的效果以及设置边框颜色
- swing中JPanel如何实现分组框的效果以及设置边框颜色
- JAVA swing中JPanel如何实现分组框的效果以及设置边框颜色
- JAVA swing中JPanel如何实现分组框的效果以及设置边框颜色 分类: Java Game 2014-08-16 12:21 198人阅读 评论(0) 收藏
- c# 当窗体设置成无边框后,如何实现拖动效果,简洁实用
- 可拖动拉伸的左右分栏效果,本例子是用Table以及JS来实现的,左右分栏可改变,拖动中间的边框就可实现宽度的调整,点击时可设置为隐藏左侧列表。
- 可拖动拉伸的左右分栏效果,本例子是用Table以及JS来实现的,左右分栏可改变,拖动中间的边框就可实现宽度的调整,点击时可设置为隐藏左侧列表。
- ios之如何让图片显示成圆形的样式/设置控件边框大小以及颜色
- android 里面对图片的不同压缩处理 以及简单拍照功能实现加设置闪光灯效果
- 视频特效制作:如何给视频添加边框、水印、动画以及3D效果
- echart如何设置饼图的颜色以及柱状图颜色
- 如何在iOS 7中设置barTintColor实现类似网易和 Facebook 的 navigationBar 效果
- 使用Drawble文件实现圆角,填充颜色,边框等属性的设置(Android)
- Flex中如何设置进度条(ProgressBar)边框颜色的例子
- C#做窗体应用程序时,对excel涉及的背景色设置,边框设置,数据如何导入等的实现
- HTML: <a> target属性以及如何在JS实现相同效果
- Android实现系统联系人字符分组以及字母表导航效果 .
- 如何实现“多看”设置界面的一个效果
- 视频特效制作:如何给视频添加边框、水印、动画以及3D效果
- 切换导航标签实现当前标签颜色改变以及利用js如何准确获取当前页面url网址信息