1: #! /usr/bin/env python
2: # coding: utf-8
3: ## ----------------------------------------
4: ##
5: ## (C) Copyright 2000-2010, 小粒ちゃん《監修》小泉ひよ子とタマゴ倶楽部
6: ##
7: ## ----------------------------------------
8: #...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
9: """
10: >>> tips()
11:
12: >>> ## ----------------------------------------
13: >>> None
14: version: #1.0.01
15: """
16: ## ---------------------------------------- demo: jython
17: """
18: _jython=/Users/sketch/book/java_useBetter_1/_jython
19:
20: cd /Users/sketch/book/java_useBetter_1/swing/JTable/simpleTableDemo/jython
21:
22: JYTHONPATH=$_jython jython -i SimpleTableDemo.py
23:
24: ============================================================
25: Version: 2.5.0 (Release_2_5_0:6476, Jun 16 2009, 13:33:26)
26: Module : SimpleTableDemo.py
27: Date : Wed Sep 22 10:16:25 2010
28: ============================================================
29: """
30: from __init__ import *
31:
32: ## ----------------------------------------
33: ##package components;
34:
35: from java.awt import GridLayout
36: from javax.swing import JFrame
37: from javax.swing import JPanel
38: from javax.swing import JScrollPane
39: from javax.swing import JTable
40:
41: ## ----------------------------------------
42: class SimpleTableDemo(JPanel):
43:
44: def __init__(self):
45: super(JPanel,self).__init__(GridLayout(1,0))
46:
47: columnNames = [
48: "First Name",
49: "Last Name",
50: "Sport",
51: "# of Years",
52: "Vegetarian",
53: ]
54:
55: data = [
56: ["Kathy", "Smith", "Snowboarding", 5, False],
57: ["John", "Doe", "Rowing", 3, True],
58: ["Sue", "Black", "Knitting", 2, False],
59: ["Jane", "White", "Speed reading", 20, True],
60: ["Joe", "Brown", "Pool", 10, False],
61: ]
62:
63: table = JTable(
64: data,
65: columnNames,
66: preferredScrollableViewportSize = (500, 70),
67: )
68:
69: scrollPane = JScrollPane(table)
70:
71: self.add(scrollPane)
72:
73: ## ----------------------------------------
74: @staticmethod
75: def createAndShowGUI():
76: frame = JFrame(
77: title = "SimpleTableDemo",
78: defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
79: locationRelativeTo = None,
80: )
81: newContentPane = SimpleTableDemo()
82: newContentPane.opaque = True
83: frame.contentPane = newContentPane
84:
85: frame.pack()
86: frame.visible = True
87:
88: ## ----------------------------------------
89: from __init__ import *
90: tips = SimpleTableDemo.createAndShowGUI
91:
92: if __name__=='__main__':
93: inform()
94: testmod()
95:
96: ## ========================================