java swing 之 JScrollPane(滚动面板)的使用
发布日期:2021-06-30 18:39:03
浏览次数:3
分类:技术文章
本文共 1293 字,大约阅读时间需要 4 分钟。
/** * java swing 之JScrollPane面板 * 在设置界面时,可能会遇到在一个较小的容器窗体中显示一个较大部分的内容,这时可以使用 * JScrollPane面板,JscrollPane面板是带滚动条的面板,也是一种容器,但是常用于布置单个 * 控件,并且不可以使用布局管理器。如果需要在JScrollPane面板中放置多个控件,需要将多个 * 控件放置到JPanel 面板上,然后将JPanel面板作为一个整体控件添加到JScrollPane控件上。 * * @author gao */package com.gao;import java.awt.BorderLayout;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.border.EmptyBorder;public class JScrollPaneDemo extends JFrame{ private JPanel contentPane; private JScrollPane scrollPane; private JTextArea textArea; public JScrollPaneDemo(){ contentPane=new JPanel(); contentPane.setBorder(new EmptyBorder(5,5,5,5)); contentPane.setLayout(new BorderLayout(0,0)); this.setContentPane(contentPane); scrollPane=new JScrollPane(); contentPane.add(scrollPane,BorderLayout.CENTER); textArea=new JTextArea(); //scrollPane.add(textArea); scrollPane.setViewportView(textArea); this.setTitle("滚动面板使用"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setBounds(100, 100, 250, 200); this.setVisible(true); } public static void main(String []args){ JScrollPaneDemo example=new JScrollPaneDemo(); }}文章转自:http://www.2cto.com/kf/201405/297419.html
转载地址:https://linqiarui.blog.csdn.net/article/details/51068447 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月20日 14时02分51秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
COMP7404 Machine Learing——KNN
2019-04-30
COMP7404 Machine Learing——SVM
2019-04-30
COMP7404 Machine Learing——ROC
2019-04-30
Python量子计算qiskit
2019-04-30
Python的多线程不是真的多线程(GIL全局解释器锁)
2019-04-30
CPython
2019-04-30
特征融合 & FFM(Feature Fusion Module) 特征融合模块
2019-04-30
Python手动读取MNIST数据集
2019-04-30
Python手动读取CIFAR-10数据集
2019-04-30
Pytorch(十一) —— 分布式(多GPU)训练
2019-04-30
Deeplab v3
2019-04-30
Cityscapes数据集
2019-04-30
Pytorch之经典神经网络CNN(六) —— NiN (Fashion-MNIST)
2019-04-30
NLP 之 Perplexity困惑度
2019-04-30
tensor/矩阵/图片等更换通道,调整size
2019-04-30
本地和colab 中 改变tensorflow的版本
2019-04-30