01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.attachmentspanel;
16:
17: import javax.swing.JTable;
18: import javax.swing.ListSelectionModel;
19: import javax.swing.table.AbstractTableModel;
20: import javax.swing.table.TableColumn;
21:
22: public class AttachmentsTable extends JTable {
23: public AttachmentsTable(AbstractTableModel pModel) {
24: super (pModel);
25:
26: setAutoResizeMode(AUTO_RESIZE_OFF);
27: setCellSelectionEnabled(true);
28: setRowSelectionAllowed(true);
29: setColumnSelectionAllowed(false);
30: setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
31:
32: TableColumn lFirstColumn = getColumnModel().getColumn(0);
33: TableColumn lSecondColumn = getColumnModel().getColumn(1);
34:
35: lFirstColumn.setPreferredWidth(100);
36: int lWidth = getWidth() - lFirstColumn.getPreferredWidth();
37: if (lWidth < 200)
38: lWidth = 200;
39: lSecondColumn.setPreferredWidth(lWidth);
40: }
41:
42: public void resizeColumns(int pWidth) {
43: TableColumn lFirstColumn = getColumnModel().getColumn(0);
44: TableColumn lSecondColumn = getColumnModel().getColumn(1);
45:
46: int lWidth = pWidth - lFirstColumn.getWidth();
47: if (lWidth < 200)
48: lWidth = 200;
49: lSecondColumn.setPreferredWidth(lWidth);
50: }
51: }
|