mainframe.java

来自「java网络高级编程的配套源码,java网络高级编程为清华出版社出版.」· Java 代码 · 共 159 行

JAVA
159
字号
/*源代码清单11-1*/

package database;

import java.awt.*;
import java.awt.event.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import java.sql.*;
import java.util.*;
import borland.jbcl.model.*;

public class MainFrame extends DecoratedFrame
{
  GridControl gridControl1 = new GridControl();
  Button button1 = new Button();
  Button button2 = new Button();
  Button button3 = new Button();
  Button button4 = new Button();
  PaneLayout paneLayout1 = new PaneLayout();
  
  public MainFrame()
  {
    try {
      jbInit();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception
  {
    this.setTitle("数据库实例");
    gridControl1.setColumnCaptions(new String[] {"姓名", "性别", "年龄", "电话", "备注"});
    button1.setLabel("增加");
    button1.addActionListener(new MainFrame_button1_actionAdapter(this));
    button2.setLabel("修改");
    button2.addActionListener(new MainFrame_button2_actionAdapter(this));
    button3.setLabel("删除");
    button3.addActionListener(new MainFrame_button3_actionAdapter(this));
    button4.setLabel("退出");
    button4.addActionListener(new MainFrame_button4_actionAdapter(this));
    this.setLayout(paneLayout1);
    this.add(gridControl1, new PaneConstraints("gridControl1", "gridControl1", PaneConstraints.ROOT, 0.5f));
    this.add(button1, new PaneConstraints("button1", "gridControl1", PaneConstraints.BOTTOM, 0.11522633f));
    this.add(button2, new PaneConstraints("button2", "button1", PaneConstraints.RIGHT, 0.7428571f));
    this.add(button3, new PaneConstraints("button3", "button2", PaneConstraints.RIGHT, 0.6818182f));
    this.add(button4, new PaneConstraints("button4", "button3", PaneConstraints.RIGHT, 0.5589744f));
    gridControl1.setReadOnly(true);
    gridControl1.addSubfocusListener(new MainFrame_gridControl1_subfocusAdapter(this));
  }

  public static void main(String[] args)
  {
    MainFrame frame=new MainFrame();
    frame.setLocation(150,150);
    frame.setSize(550,400);
    frame.show();
  }

void button1_actionPerformed(ActionEvent e)
  {
  }

  void button2_actionPerformed(ActionEvent e)
  {
  }

  void button3_actionPerformed(ActionEvent e)
  {
  }

  void button4_actionPerformed(ActionEvent e)
  {
  }

  void gridControl1_subfocusChanged(MatrixSubfocusEvent e)
  {
  }
}

class MainFrame_button1_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button1_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

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

class MainFrame_button2_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button2_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

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

class MainFrame_button3_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button3_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

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

class MainFrame_button4_actionAdapter implements java.awt.event.ActionListener
{
  MainFrame adaptee;

  MainFrame_button4_actionAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

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

class MainFrame_gridControl1_subfocusAdapter extends borland.jbcl.model.MatrixSubfocusAdapter
{
  MainFrame adaptee;

  MainFrame_gridControl1_subfocusAdapter(MainFrame adaptee)
  {
    this.adaptee = adaptee;
  }

  public void subfocusChanged(MatrixSubfocusEvent e)
  {
    adaptee.gridControl1_subfocusChanged(e);
  }
}

⌨️ 快捷键说明

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