标签:
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); } }
标签:
原文地址:http://www.cnblogs.com/stono/p/5000494.html