⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infoframe.java

📁 一个窗口程序
💻 JAVA
字号:
package com.jetart.ovw;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.JTableHeader;
import javax.swing.JScrollPane;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class InfoFrame
    extends JFrame
{
    String[] columnNames =
        {
        "ID", "属性名", "值"};
    String[][] info = null;

    BorderLayout borderLayout1 = new BorderLayout();
    JLabel jLabel1 = new JLabel();
    JTable jTable1 = new JTable();
    JButton jButton1 = new JButton();
    JScrollPane scrollPane = new JScrollPane();

    public InfoFrame()
    {
        try
        {
            jbInit();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }

    public InfoFrame(String[][] info)
    {
        try
        {
            this.info = info;
            jbInit();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }

    void jbInit()
        throws Exception
    {
        jLabel1.setText("对象属性列表");
//        this.getContentPane().setLayout(borderLayout1);
        jTable1.setBorder(BorderFactory.createLoweredBevelBorder());
        jTable1.setColumnSelectionAllowed(true);
        jTable1.setGridColor(SystemColor.desktop);
//        jTable1.setTableHeader(new JTableHeader());
        this.setTitle("属性查看窗口");
        jTable1 = new JTable(info, columnNames);
        jTable1.setAutoscrolls(true);
        jTable1.setEnabled(false);
        jButton1.setText("关   闭");
        jButton1.addActionListener(new InfoFrame_jButton1_actionAdapter(this));
        scrollPane.setAutoscrolls(true);
        scrollPane.setOpaque(false);
        scrollPane.setEnabled(true);
        scrollPane.getViewport().add(jTable1);
        this.getContentPane().add(jLabel1, BorderLayout.NORTH);
//        this.getContentPane().add(jTable1.getTableHeader(),BorderLayout.NORTH);
//        this.getContentPane().add(jTable1, BorderLayout.CENTER);
        this.getContentPane().add(scrollPane, BorderLayout.CENTER);
        this.getContentPane().add(jButton1, BorderLayout.SOUTH);
        this.setBounds(50, 50, 400, 380);
    }

    void jButton1_actionPerformed(ActionEvent e)
    {
        this.dispose();
//        this.hide();
    }

    public void main(String[] args)
    {
        InfoFrame f = new InfoFrame();
    }
}

class InfoFrame_jButton1_actionAdapter
    implements java.awt.event.ActionListener
{
    InfoFrame adaptee;

    InfoFrame_jButton1_actionAdapter(InfoFrame adaptee)
    {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e)
    {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -