View Javadoc
1 /*** 2 * Copyright (c) 2003 held jointly by the individual authors. 3 * 4 * This library is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published 6 * by the Free Software Foundation; either version 2.1 of the License, or 7 * (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, but 10 * WITHOUT ANY WARRANTY; with out even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this library; if not, write to the Free Software Foundation, 16 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 17 * 18 * > http://www.gnu.org/copyleft/lesser.html 19 * > http://www.opensource.org/licenses/lgpl-license.php 20 */ 21 package net.mlw.gfw.ext.card.component; 22 23 import java.awt.BorderLayout; 24 import java.awt.Panel; 25 import java.awt.event.AdjustmentEvent; 26 import java.awt.event.AdjustmentListener; 27 28 import javax.swing.BoundedRangeModel; 29 import javax.swing.JDialog; 30 import javax.swing.JFrame; 31 import javax.swing.JScrollBar; 32 33 import net.mlw.gfw.client.ClientContext; 34 import net.mlw.gfw.event.EventHandler; 35 import net.mlw.gfw.ext.card.CardRenderer; 36 import net.mlw.gfw.ext.card.ScrollableTableModel; 37 import net.mlw.gfw.ext.card.TableModel; 38 39 /*** This Component is used to brows the history of a hand. 40 * 41 * @author Matthew L. Wilson 42 * @version $Revision: 1.2 $ $Date: 2004/06/29 20:32:56 $ 43 */ 44 public class ScrollableTablePanel extends Panel 45 { 46 private final InnerScrollableTablePanel tablePanel; 47 private JScrollBar scroller = new JScrollBar(JScrollBar.HORIZONTAL, 1, 1, 1, 2); 48 49 /*** 50 * @param cardRenderer 51 */ 52 public ScrollableTablePanel(CardRenderer cardRenderer, int numberOfPlayers) 53 { 54 tablePanel = new InnerScrollableTablePanel(cardRenderer, numberOfPlayers, scroller.getModel()); 55 } 56 57 /*** 58 * @see net.mlw.gfw.client.ClientEventHandler#addEventHandler(net.mlw.gfw.event.EventHandler) 59 */ 60 public void addEventHandler(EventHandler eventHandler) 61 { 62 } 63 64 /*** 65 * @see net.mlw.gfw.client.ClientEventHandler#init(net.mlw.gfw.client.ClientContext) 66 */ 67 public void init(ClientContext context) 68 { 69 setLayout(new BorderLayout()); 70 71 scroller.addAdjustmentListener(new AdjustmentListener() 72 { 73 public void adjustmentValueChanged(AdjustmentEvent e) 74 { 75 tablePanel.drawTable(); 76 } 77 }); 78 add(scroller, BorderLayout.NORTH); 79 add(tablePanel, BorderLayout.CENTER); 80 } 81 82 /*** 83 * @see net.mlw.gfw.ext.card.component.TablePanel#setLocalView(int) 84 */ 85 public void setLocalView(int seat) 86 { 87 tablePanel.setLocalView(seat); 88 } 89 /*** 90 * @see net.mlw.gfw.ext.card.component.TablePanel#getModel() 91 */ 92 public TableModel getModel() 93 { 94 return tablePanel.getModel(); 95 } 96 97 private class InnerScrollableTablePanel extends TablePanel 98 { 99 /*** 100 * @param cardRenderer 101 */ 102 public InnerScrollableTablePanel(CardRenderer cardRenderer, int numberOfPlayers, BoundedRangeModel rangeModel) 103 { 104 super(cardRenderer, new ScrollableTableModel(rangeModel, numberOfPlayers)); 105 } 106 107 } 108 109 private JDialog dialog; 110 public JDialog toJDialog(JFrame parent) 111 { 112 if (dialog == null) 113 { 114 dialog = new JDialog(parent, "History", false); 115 dialog.getContentPane().add(this); 116 dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); 117 dialog.pack(); 118 } 119 return dialog; 120 } 121 }

This page was automatically generated by Maven