76 |
import javax.swing.table.TableColumn; |
import javax.swing.table.TableColumn; |
77 |
import javax.swing.table.TableColumnModel; |
import javax.swing.table.TableColumnModel; |
78 |
|
|
79 |
public class BasicTableUI |
public class BasicTableUI extends TableUI |
|
extends TableUI |
|
80 |
{ |
{ |
81 |
public static ComponentUI createUI(JComponent comp) |
public static ComponentUI createUI(JComponent comp) |
82 |
{ |
{ |
98 |
/** The action bound to KeyStrokes. */ |
/** The action bound to KeyStrokes. */ |
99 |
TableAction action; |
TableAction action; |
100 |
|
|
101 |
|
/** |
102 |
|
* Handles key events for the JTable. Key events should be handled through |
103 |
|
* the InputMap/ActionMap mechanism since JDK1.3. This class is only there |
104 |
|
* for backwards compatibility. |
105 |
|
* |
106 |
|
* @author Roman Kennke (kennke@aicas.com) |
107 |
|
*/ |
108 |
|
public class KeyHandler implements KeyListener |
109 |
|
{ |
110 |
|
|
111 |
|
/** |
112 |
|
* Receives notification that a key has been pressed and released. |
113 |
|
* |
114 |
|
* @param event the key event |
115 |
|
*/ |
116 |
|
public void keyTyped(KeyEvent event) |
117 |
|
{ |
118 |
|
// Key events should be handled through the InputMap/ActionMap mechanism |
119 |
|
// since JDK1.3. This class is only there for backwards compatibility. |
120 |
|
} |
121 |
|
|
122 |
|
/** |
123 |
|
* Receives notification that a key has been pressed. |
124 |
|
* |
125 |
|
* @param event the key event |
126 |
|
*/ |
127 |
|
public void keyPressed(KeyEvent event) |
128 |
|
{ |
129 |
|
// Key events should be handled through the InputMap/ActionMap mechanism |
130 |
|
// since JDK1.3. This class is only there for backwards compatibility. |
131 |
|
} |
132 |
|
|
133 |
|
/** |
134 |
|
* Receives notification that a key has been released. |
135 |
|
* |
136 |
|
* @param event the key event |
137 |
|
*/ |
138 |
|
public void keyReleased(KeyEvent event) |
139 |
|
{ |
140 |
|
// Key events should be handled through the InputMap/ActionMap mechanism |
141 |
|
// since JDK1.3. This class is only there for backwards compatibility. |
142 |
|
} |
143 |
|
} |
144 |
|
|
145 |
public class FocusHandler implements FocusListener |
public class FocusHandler implements FocusListener |
146 |
{ |
{ |
147 |
public void focusGained(FocusEvent e) |
public void focusGained(FocusEvent e) |
249 |
return new MouseInputHandler(); |
return new MouseInputHandler(); |
250 |
} |
} |
251 |
|
|
252 |
|
|
253 |
|
/** |
254 |
|
* Creates and returns a key listener for the JTable. |
255 |
|
* |
256 |
|
* @return a key listener for the JTable |
257 |
|
*/ |
258 |
|
protected KeyListener createKeyListener() |
259 |
|
{ |
260 |
|
return new KeyHandler(); |
261 |
|
} |
262 |
|
|
263 |
/** |
/** |
264 |
* Return the maximum size of the table. The maximum height is the row |
* Return the maximum size of the table. The maximum height is the row |
265 |
* height times the number of rows. The maximum width is the sum of |
* height times the number of rows. The maximum width is the sum of |
976 |
|
|
977 |
protected void installListeners() |
protected void installListeners() |
978 |
{ |
{ |
979 |
table.addFocusListener(focusListener); |
if (focusListener == null) |
980 |
|
focusListener = createFocusListener(); |
981 |
|
table.addFocusListener(focusListener); |
982 |
|
if (keyListener == null) |
983 |
|
keyListener = createKeyListener(); |
984 |
table.addKeyListener(keyListener); |
table.addKeyListener(keyListener); |
985 |
|
if (mouseInputListener == null) |
986 |
|
mouseInputListener = createMouseInputListener(); |
987 |
table.addMouseListener(mouseInputListener); |
table.addMouseListener(mouseInputListener); |
988 |
table.addMouseMotionListener(mouseInputListener); |
table.addMouseMotionListener(mouseInputListener); |
989 |
} |
} |
1023 |
public void installUI(JComponent comp) |
public void installUI(JComponent comp) |
1024 |
{ |
{ |
1025 |
table = (JTable)comp; |
table = (JTable)comp; |
|
focusListener = createFocusListener(); |
|
|
mouseInputListener = createMouseInputListener(); |
|
1026 |
installDefaults(); |
installDefaults(); |
1027 |
installKeyboardActions(); |
installKeyboardActions(); |
1028 |
installListeners(); |
installListeners(); |