summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing3807.java
blob: 78ee67e6bb7342a037c479ca63abd948d2adf88e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Listing3807.java */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Listing3807
extends JFrame
implements ActionListener
{
  JTable table;
  SparseTableModel tableModel;

  public Listing3807()
  {
    super("JTable 2");
    addWindowListener(new WindowClosingAdapter(true));
    tableModel = new SparseTableModel(1000);
    table = new JTable(tableModel, null);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    table.setCellSelectionEnabled(true);
    Container cp = getContentPane();
    cp.add(new JScrollPane(table), BorderLayout.CENTER);
    JButton button = new JButton("Drucken");
    button.addActionListener(this);
    cp.add(button, BorderLayout.SOUTH);
  }

  public void actionPerformed(ActionEvent event)
  {
    tableModel.printData();
  }

  public static void main(String[] args)
  {
    Listing3807 frame = new Listing3807();
    frame.setLocation(100, 100);
    frame.setSize(320, 200);
    frame.setVisible(true);
  }
}