码迷,mamicode.com
首页 > 编程语言 > 详细

JavaSwing JScrollPane的使用

时间:2015-11-27 14:38:13      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

JavaSwing JScrollPane的使用:

参考:http://duyz.blog.ifeng.com/article/340649.html

 

package com.srie.test;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
public class JFrame001 extends JFrame {
    private static final long serialVersionUID = -8298152118685661613L;
    private JPanel contentPane;
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    JFrame001 frame = new JFrame001();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * Create the frame.
     */
    public JFrame001() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(new BorderLayout(0, 0));
        setContentPane(contentPane);
        
        JScrollPane scrollPane = new JScrollPane();
        contentPane.add(scrollPane, BorderLayout.CENTER);
        
        JPanel panel = new JPanel();
        panel.setPreferredSize(new Dimension(800, 600));
        scrollPane.setViewportView(panel);
        JPanel panelColumn= new JPanel();
        scrollPane.setColumnHeaderView(panelColumn);
        
        JLabel lblNewLabel = new JLabel("New label");
        panelColumn.add(lblNewLabel);;
        JPanel panelRow = new JPanel();
        scrollPane.setRowHeaderView(panelRow);
        
        JLabel lblNewLabel_1 = new JLabel("New label");
        panelRow.add(lblNewLabel_1);
    }
}

 

JavaSwing JScrollPane的使用

标签:

原文地址:http://www.cnblogs.com/stono/p/5000494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!