1 35 36 39 package demo.swingset; 40 41 import swingwtx.swing.*; 42 import swingwtx.swing.event.*; 43 import swingwtx.swing.text.*; 44 import swingwtx.swing.table.*; 45 import swingwtx.swing.border.*; 46 import swingwtx.swing.colorchooser.*; 47 import swingwtx.swing.filechooser.*; 48 import javax.accessibility.*; 49 50 import swingwt.awt.*; 51 import swingwt.awt.event.*; 52 import java.beans.*; 53 import java.util.*; 54 import java.io.*; 55 import java.applet.*; 56 import java.net.*; 57 58 65 public class TableDemo extends DemoModule { 66 JTable tableView; 67 JScrollPane scrollpane; 68 Dimension origin = new Dimension(0, 0); 69 70 JCheckBox isColumnReorderingAllowedCheckBox; 71 JCheckBox showHorizontalLinesCheckBox; 72 JCheckBox showVerticalLinesCheckBox; 73 74 JCheckBox isColumnSelectionAllowedCheckBox; 75 JCheckBox isRowSelectionAllowedCheckBox; 76 JCheckBox isRowAndColumnSelectionAllowedCheckBox; 77 78 JLabel interCellSpacingLabel; 79 JLabel rowHeightLabel; 80 81 JSlider interCellSpacingSlider; 82 JSlider rowHeightSlider; 83 84 JComboBox selectionModeComboBox = null; 85 JComboBox resizeModeComboBox = null; 86 87 JPanel controlPanel; 88 JScrollPane tableAggregate; 89 90 String path = "ImageClub/food/"; 91 92 final int INITIAL_ROWHEIGHT = 33; 93 94 97 public static void main(String [] args) { 98 TableDemo demo = new TableDemo(null); 99 demo.mainImpl(); 100 } 101 102 105 public TableDemo(SwingSet2 swingset) { 106 super(swingset, "TableDemo", "toolbar/JTable.gif"); 107 108 getDemoPanel().setLayout(new BorderLayout()); 109 controlPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 110 JPanel column1 = new JPanel (new ColumnLayout() ); 111 JPanel column2 = new JPanel (new ColumnLayout() ); 112 JPanel column3 = new JPanel (new ColumnLayout() ); 113 114 getDemoPanel().add(controlPanel, BorderLayout.NORTH); 115 Vector relatedComponents = new Vector(); 116 117 isColumnReorderingAllowedCheckBox = new JCheckBox(getString("TableDemo.reordering_allowed"), true); 119 column1.add(isColumnReorderingAllowedCheckBox); 120 isColumnReorderingAllowedCheckBox.addActionListener(new ActionListener() { 121 public void actionPerformed(ActionEvent e) { 122 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 123 tableView.getTableHeader().setReorderingAllowed(flag); 124 tableView.repaint(); 125 } 126 }); 127 128 129 showHorizontalLinesCheckBox = new JCheckBox(getString("TableDemo.horz_lines"), true); 130 column1.add(showHorizontalLinesCheckBox); 131 showHorizontalLinesCheckBox.addActionListener(new ActionListener() { 132 public void actionPerformed(ActionEvent e) { 133 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 134 tableView.setShowHorizontalLines(flag); ; 135 tableView.repaint(); 136 } 137 }); 138 139 showVerticalLinesCheckBox = new JCheckBox(getString("TableDemo.vert_lines"), true); 140 column1.add(showVerticalLinesCheckBox); 141 showVerticalLinesCheckBox.addActionListener(new ActionListener() { 142 public void actionPerformed(ActionEvent e) { 143 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 144 tableView.setShowVerticalLines(flag); ; 145 tableView.repaint(); 146 } 147 }); 148 149 relatedComponents.removeAllElements(); 151 relatedComponents.add(showHorizontalLinesCheckBox); 152 relatedComponents.add(showVerticalLinesCheckBox); 153 buildAccessibleGroup(relatedComponents); 154 155 interCellSpacingLabel = new JLabel(getString("TableDemo.intercell_spacing_colon")); 156 column1.add(interCellSpacingLabel); 157 158 interCellSpacingSlider = new JSlider(JSlider.HORIZONTAL, 0, 10, 1); 159 interCellSpacingLabel.setLabelFor(interCellSpacingSlider); 161 column1.add(interCellSpacingSlider); 162 interCellSpacingSlider.addChangeListener(new ChangeListener() { 163 public void stateChanged(ChangeEvent e) { 164 int spacing = ((JSlider)e.getSource()).getValue(); 165 tableView.setIntercellSpacing(new Dimension(spacing, spacing)); 166 tableView.repaint(); 167 } 168 }); 169 170 controlPanel.add(column1); 171 172 174 isColumnSelectionAllowedCheckBox = new JCheckBox(getString("TableDemo.column_selection"), false); 175 column2.add(isColumnSelectionAllowedCheckBox); 176 isColumnSelectionAllowedCheckBox.addActionListener(new ActionListener() { 177 public void actionPerformed(ActionEvent e) { 178 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 179 tableView.setColumnSelectionAllowed(flag); ; 180 tableView.repaint(); 181 } 182 }); 183 184 isRowSelectionAllowedCheckBox = new JCheckBox(getString("TableDemo.row_selection"), true); 185 column2.add(isRowSelectionAllowedCheckBox); 186 isRowSelectionAllowedCheckBox.addActionListener(new ActionListener() { 187 public void actionPerformed(ActionEvent e) { 188 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 189 tableView.setRowSelectionAllowed(flag); ; 190 tableView.repaint(); 191 } 192 }); 193 194 relatedComponents.removeAllElements(); 196 relatedComponents.add(isColumnSelectionAllowedCheckBox); 197 relatedComponents.add(isRowSelectionAllowedCheckBox); 198 buildAccessibleGroup(relatedComponents); 199 200 isRowAndColumnSelectionAllowedCheckBox = new JCheckBox(getString("TableDemo.cell_selection"), false); 201 column2.add(isRowAndColumnSelectionAllowedCheckBox); 202 isRowAndColumnSelectionAllowedCheckBox.addActionListener(new ActionListener() { 203 public void actionPerformed(ActionEvent e) { 204 boolean flag = ((JCheckBox)e.getSource()).isSelected(); 205 tableView.setCellSelectionEnabled(flag); ; 206 tableView.repaint(); 207 } 208 }); 209 210 rowHeightLabel = new JLabel(getString("TableDemo.row_height_colon")); 211 column2.add(rowHeightLabel); 212 213 rowHeightSlider = new JSlider(JSlider.HORIZONTAL, 5, 100, INITIAL_ROWHEIGHT); 214 rowHeightLabel.setLabelFor(rowHeightSlider); 216 column2.add(rowHeightSlider); 217 rowHeightSlider.addChangeListener(new ChangeListener() { 218 public void stateChanged(ChangeEvent e) { 219 int height = ((JSlider)e.getSource()).getValue(); 220 tableView.setRowHeight(height); 221 tableView.repaint(); 222 } 223 }); 224 225 controlPanel.add(column2); 226 227 relatedComponents.removeAllElements(); 229 relatedComponents.add(interCellSpacingSlider); 230 relatedComponents.add(rowHeightSlider); 231 buildAccessibleGroup(relatedComponents); 232 233 tableAggregate = createTable(); 235 getDemoPanel().add(tableAggregate, BorderLayout.CENTER); 236 237 238 JPanel selectMode = new JPanel(); 240 column3.setLayout(new ColumnLayout()); 241 selectMode.setBorder(new TitledBorder(getString("TableDemo.selection_mode"))); 242 243 244 selectionModeComboBox = new JComboBox(); 245 selectionModeComboBox.addItem(getString("TableDemo.single")); 246 selectionModeComboBox.addItem(getString("TableDemo.one_range")); 247 selectionModeComboBox.addItem(getString("TableDemo.multiple_ranges")); 248 249 selectionModeComboBox.addItemListener(new ItemListener() { 250 public void itemStateChanged(ItemEvent e) { 251 JComboBox source = (JComboBox)e.getSource(); 252 tableView.setSelectionMode(source.getSelectedIndex()); 253 } 254 }); 255 256 selectMode.add(selectionModeComboBox); 257 column3.add(selectMode); 258 259 261 JPanel resizeMode = new JPanel(); 262 263 resizeMode.setBorder(new TitledBorder(getString("TableDemo.autoresize_mode"))); 264 265 266 resizeModeComboBox = new JComboBox(); 267 resizeModeComboBox.addItem(getString("TableDemo.off")); 268 resizeModeComboBox.addItem(getString("TableDemo.column_boundries")); 269 resizeModeComboBox.addItem(getString("TableDemo.subsequent_columns")); 270 resizeModeComboBox.addItem(getString("TableDemo.last_column")); 271 resizeModeComboBox.addItem(getString("TableDemo.all_columns")); 272 resizeModeComboBox.setSelectedIndex(tableView.getAutoResizeMode()); 273 resizeModeComboBox.addItemListener(new ItemListener() { 274 public void itemStateChanged(ItemEvent e) { 275 JComboBox source = (JComboBox)e.getSource(); 276 tableView.setAutoResizeMode(source.getSelectedIndex()); 277 } 278 }); 279 280 resizeMode.add(resizeModeComboBox); 281 column3.add(resizeMode); 282 283 controlPanel.add(column3); 284 285 setTableControllers(); 287 } 289 297 void buildAccessibleGroup(Vector components) { 298 299 AccessibleContext context = null; 300 int numComponents = components.size(); 301 Object [] group = components.toArray(); 302 Object object = null; 303 for (int i = 0; i < numComponents; ++i) { 304 object = components.elementAt(i); 305 getAccessibleContext(); 308 } 313 } 315 320 private void setTableControllers() { 321 322 setAccessibleController(isColumnReorderingAllowedCheckBox, 324 tableAggregate); 325 setAccessibleController(showHorizontalLinesCheckBox, 326 tableAggregate); 327 setAccessibleController(showVerticalLinesCheckBox, 328 tableAggregate); 329 setAccessibleController(isColumnSelectionAllowedCheckBox, 330 tableAggregate); 331 setAccessibleController(isRowSelectionAllowedCheckBox, 332 tableAggregate); 333 setAccessibleController(interCellSpacingSlider, 334 tableAggregate); 335 setAccessibleController(rowHeightSlider, 336 tableAggregate); 337 setAccessibleController(selectionModeComboBox, 338 tableAggregate); 339 setAccessibleController(resizeModeComboBox, 340 tableAggregate); 341 } 343 349 private void setAccessibleController(JComponent controller, 350 JComponent target) { 351 356 } 364 public JScrollPane createTable() { 365 366 final String [] names = { 368 getString("TableDemo.first_name"), 369 getString("TableDemo.last_name"), 370 getString("TableDemo.favorite_color"), 371 getString("TableDemo.favorite_movie"), 372 getString("TableDemo.favorite_number"), 373 getString("TableDemo.favorite_food") 374 }; 375 376 ImageIcon apple = createImageIcon("ImageClub/food/apple.jpg", getString("TableDemo.apple")); 377 ImageIcon asparagus = createImageIcon("ImageClub/food/asparagus.jpg", getString("TableDemo.asparagus")); 378 ImageIcon banana = createImageIcon("ImageClub/food/banana.jpg", getString("TableDemo.banana")); 379 ImageIcon broccoli = createImageIcon("ImageClub/food/broccoli.jpg", getString("TableDemo.broccoli")); 380 ImageIcon cantaloupe = createImageIcon("ImageClub/food/cantaloupe.jpg", getString("TableDemo.cantaloupe")); 381 ImageIcon carrot = createImageIcon("ImageClub/food/carrot.jpg", getString("TableDemo.carrot")); 382 ImageIcon corn = createImageIcon("ImageClub/food/corn.jpg", getString("TableDemo.corn")); 383 ImageIcon grapes = createImageIcon("ImageClub/food/grapes.jpg", getString("TableDemo.grapes")); 384 ImageIcon grapefruit = createImageIcon("ImageClub/food/grapefruit.jpg", getString("TableDemo.grapefruit")); 385 ImageIcon kiwi = createImageIcon("ImageClub/food/kiwi.jpg", getString("TableDemo.kiwi")); 386 ImageIcon onion = createImageIcon("ImageClub/food/onion.jpg", getString("TableDemo.onion")); 387 ImageIcon pear = createImageIcon("ImageClub/food/pear.jpg", getString("TableDemo.pear")); 388 ImageIcon peach = createImageIcon("ImageClub/food/peach.jpg", getString("TableDemo.peach")); 389 ImageIcon pepper = createImageIcon("ImageClub/food/pepper.jpg", getString("TableDemo.pepper")); 390 ImageIcon pickle = createImageIcon("ImageClub/food/pickle.jpg", getString("TableDemo.pickle")); 391 ImageIcon pineapple = createImageIcon("ImageClub/food/pineapple.jpg", getString("TableDemo.pineapple")); 392 ImageIcon raspberry = createImageIcon("ImageClub/food/raspberry.jpg", getString("TableDemo.raspberry")); 393 ImageIcon sparegrass = createImageIcon("ImageClub/food/asparagus.jpg", getString("TableDemo.sparegrass")); 394 ImageIcon strawberry = createImageIcon("ImageClub/food/strawberry.jpg", getString("TableDemo.strawberry")); 395 ImageIcon tomato = createImageIcon("ImageClub/food/tomato.jpg", getString("TableDemo.tomato")); 396 ImageIcon watermelon = createImageIcon("ImageClub/food/watermelon.jpg", getString("TableDemo.watermelon")); 397 398 NamedColor aqua = new NamedColor(new Color(127, 255, 212), getString("TableDemo.aqua")); 399 NamedColor beige = new NamedColor(new Color(245, 245, 220), getString("TableDemo.beige")); 400 NamedColor black = new NamedColor(Color.black, getString("TableDemo.black")); 401 NamedColor blue = new NamedColor(new Color(0, 0, 222), getString("TableDemo.blue")); 402 NamedColor eblue = new NamedColor(Color.blue, getString("TableDemo.eblue")); 403 NamedColor jfcblue = new NamedColor(new Color(204, 204, 255), getString("TableDemo.jfcblue")); 404 NamedColor jfcblue2 = new NamedColor(new Color(153, 153, 204), getString("TableDemo.jfcblue2")); 405 NamedColor cybergreen = new NamedColor(Color.green.darker().brighter(), getString("TableDemo.cybergreen")); 406 NamedColor darkgreen = new NamedColor(new Color(0, 100, 75), getString("TableDemo.darkgreen")); 407 NamedColor forestgreen = new NamedColor(Color.green.darker(), getString("TableDemo.forestgreen")); 408 NamedColor gray = new NamedColor(Color.gray, getString("TableDemo.gray")); 409 NamedColor green = new NamedColor(Color.green, getString("TableDemo.green")); 410 NamedColor orange = new NamedColor(new Color(255, 165, 0), getString("TableDemo.orange")); 411 NamedColor purple = new NamedColor(new Color(160, 32, 240), getString("TableDemo.purple")); 412 NamedColor red = new NamedColor(Color.red, getString("TableDemo.red")); 413 NamedColor rustred = new NamedColor(Color.red.darker(), getString("TableDemo.rustred")); 414 NamedColor sunpurple = new NamedColor(new Color(100, 100, 255), getString("TableDemo.sunpurple")); 415 NamedColor suspectpink = new NamedColor(new Color(255, 105, 180), getString("TableDemo.suspectpink")); 416 NamedColor turquoise = new NamedColor(new Color(0, 255, 255), getString("TableDemo.turquoise")); 417 NamedColor violet = new NamedColor(new Color(238, 130, 238), getString("TableDemo.violet")); 418 NamedColor yellow = new NamedColor(Color.yellow, getString("TableDemo.yellow")); 419 420 final Object [][] data = { 422 {"Mike", "Albers", green, getString("TableDemo.brazil"), new Double (44.0), strawberry}, 423 {"Mark", "Andrews", blue, getString("TableDemo.curse"), new Double (3), grapes}, 424 {"Brian", "Beck", black, getString("TableDemo.bluesbros"), new Double (2.7182818285), raspberry}, 425 {"Lara", "Bunni", red, getString("TableDemo.airplane"), new Double (15), strawberry}, 426 {"Roger", "Brinkley", blue, getString("TableDemo.man"), new Double (13), peach}, 427 {"Brent", "Christian", black, getString("TableDemo.bladerunner"), new Double (23), broccoli}, 428 {"Mark", "Davidson", darkgreen, getString("TableDemo.brazil"), new Double (27), asparagus}, 429 {"Jeff", "Dinkins", blue, getString("TableDemo.ladyvanishes"), new Double (8), kiwi}, 430 {"Ewan", "Dinkins", yellow, getString("TableDemo.bugs"), new Double (2), strawberry}, 431 {"Amy", "Fowler", violet, getString("TableDemo.reservoir"), new Double (3), raspberry}, 432 {"Hania", "Gajewska", purple, getString("TableDemo.jules"), new Double (5), raspberry}, 433 {"David", "Geary", blue, getString("TableDemo.pulpfiction"), new Double (3), watermelon}, 434 {"Eric", "Hawkes", blue, getString("TableDemo.bladerunner"), new Double (.693), pickle}, 436 {"Shannon", "Hickey", green, getString("TableDemo.shawshank"), new Integer (2), grapes}, 437 {"Earl", "Johnson", green, getString("TableDemo.pulpfiction"), new Double (8), carrot}, 438 {"Robi", "Kahn", green, getString("TableDemo.goodfellas"), new Double (89), apple}, 439 {"Robert", "Kim", blue, getString("TableDemo.mohicans"), new Double (655321), strawberry}, 440 {"Janet", "Koenig", turquoise, getString("TableDemo.lonestar"), new Double (7), peach}, 441 {"Jeff", "Kesselman", blue, getString("TableDemo.stuntman"), new Double (17), pineapple}, 442 {"Onno", "Kluyt", orange, getString("TableDemo.oncewest"), new Double (8), broccoli}, 443 {"Peter", "Korn", sunpurple, getString("TableDemo.musicman"), new Double (12), sparegrass}, 444 445 {"Rick", "Levenson", black, getString("TableDemo.harold"), new Double (1327), raspberry}, 446 {"Brian", "Lichtenwalter", jfcblue, getString("TableDemo.fifthelement"), new Double (22), pear}, 447 {"Malini", "Minasandram", beige, getString("TableDemo.joyluck"), new Double (9), corn}, 448 {"Michael", "Martak", green, getString("TableDemo.city"), new Double (3), strawberry}, 449 {"David", "Mendenhall", forestgreen, getString("TableDemo.schindlerslist"), new Double (7), peach}, 450 {"Phil", "Milne", suspectpink, getString("TableDemo.withnail"), new Double (3), banana}, 451 {"Lynn", "Monsanto", cybergreen, getString("TableDemo.dasboot"), new Double (52), peach}, 452 {"Hans", "Muller", rustred, getString("TableDemo.eraserhead"), new Double (0), pineapple}, 453 {"Joshua", "Outwater", blue, getString("TableDemo.labyrinth"), new Integer (3), pineapple}, 454 {"Tim", "Prinzing", blue, getString("TableDemo.firstsight"), new Double (69), pepper}, 455 {"Raj", "Premkumar", jfcblue2, getString("TableDemo.none"), new Double (7), broccoli}, 456 {"Howard", "Rosen", green, getString("TableDemo.defending"), new Double (7), strawberry}, 457 {"Ray", "Ryan", black, getString("TableDemo.buckaroo"), 458 new Double (3.141592653589793238462643383279502884197169399375105820974944), banana}, 459 {"Georges", "Saab", aqua, getString("TableDemo.bicycle"), new Double (290), cantaloupe}, 460 {"Tom", "Santos", blue, getString("TableDemo.spinaltap"), new Double (241), pepper}, 461 {"Rich", "Schiavi", blue, getString("TableDemo.repoman"), new Double (0xFF), pepper}, 462 {"Nancy", "Schorr", green, getString("TableDemo.fifthelement"), new Double (47), watermelon}, 463 {"Keith", "Sprochi", darkgreen, getString("TableDemo.2001"), new Integer (13), watermelon}, 464 {"Matt", "Tucker", eblue, getString("TableDemo.starwars"), new Integer (2), broccoli}, 465 {"Dimitri", "Trembovetsky", red, getString("TableDemo.aliens"), new Integer (222), tomato}, 466 {"Scott", "Violet", violet, getString("TableDemo.raiders"), new Integer (-97), banana}, 467 {"Kathy", "Walrath", blue, getString("TableDemo.thinman"), new Integer (8), pear}, 468 {"Nathan", "Walrath", black, getString("TableDemo.chusingura"), new Integer (3), grapefruit}, 469 {"Steve", "Wilson", green, getString("TableDemo.raiders"), new Integer (7), onion}, 470 {"Kathleen", "Zelony", gray, getString("TableDemo.dog"), new Integer (13), grapes} 471 }; 472 473 TableModel dataModel = new AbstractTableModel() { 475 public int getColumnCount() { return names.length; } 476 public int getRowCount() { return data.length;} 477 public Object getValueAt(int row, int col) {return data[row][col];} 478 public String getColumnName(int column) {return names[column];} 479 public Class getColumnClass(int c) {return getValueAt(0, c).getClass();} 480 public boolean isCellEditable(int row, int col) {return col != 5;} 481 public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; } 482 }; 483 484 485 tableView = new JTable(dataModel); 487 488 DefaultTableCellRenderer colorRenderer = new DefaultTableCellRenderer() { 490 public void setValue(Object value) { 491 if (value instanceof NamedColor) { 492 NamedColor c = (NamedColor) value; 493 setBackground(c); 494 setForeground(c.getTextColor()); 495 setText(c.toString()); 496 } else { 497 super.setValue(value); 498 } 499 } 500 }; 501 502 JComboBox comboBox = new JComboBox(); 504 comboBox.addItem(aqua); 505 comboBox.addItem(beige); 506 comboBox.addItem(black); 507 comboBox.addItem(blue); 508 comboBox.addItem(eblue); 509 comboBox.addItem(jfcblue); 510 comboBox.addItem(jfcblue2); 511 comboBox.addItem(cybergreen); 512 comboBox.addItem(darkgreen); 513 comboBox.addItem(forestgreen); 514 comboBox.addItem(gray); 515 comboBox.addItem(green); 516 comboBox.addItem(orange); 517 comboBox.addItem(purple); 518 comboBox.addItem(red); 519 comboBox.addItem(rustred); 520 comboBox.addItem(sunpurple); 521 comboBox.addItem(suspectpink); 522 comboBox.addItem(turquoise); 523 comboBox.addItem(violet); 524 comboBox.addItem(yellow); 525 526 TableColumn colorColumn = tableView.getColumn(2); 527 colorColumn.setCellEditor(new DefaultCellEditor(comboBox)); 529 530 colorRenderer.setHorizontalAlignment(JLabel.CENTER); 531 colorColumn.setCellRenderer(colorRenderer); 532 533 tableView.setRowHeight(INITIAL_ROWHEIGHT); 534 535 scrollpane = new JScrollPane(tableView); 536 return scrollpane; 537 } 538 539 class NamedColor extends Color { 540 String name; 541 public NamedColor(Color color, String name) { 542 super(color.getRed(), color.getGreen(), color.getBlue()); 543 this.name = name; 544 } 545 546 public Color getTextColor() { 547 int r = getRed(); 548 int g = getGreen(); 549 int b = getBlue(); 550 if(r > 240 || g > 240) { 551 return Color.black; 552 } else { 553 return Color.white; 554 } 555 } 556 557 public String toString() { 558 return name; 559 } 560 } 561 562 class ColumnLayout implements LayoutManager { 563 int xInset = 5; 564 int yInset = 5; 565 int yGap = 2; 566 567 public void addLayoutComponent(String s, Component c) {} 568 569 public void layoutContainer(Container c) { 570 Insets insets = c.getInsets(); 571 int height = yInset + insets.top; 572 573 Component[] children = c.getComponents(); 574 Dimension compSize = null; 575 for (int i = 0; i < children.length; i++) { 576 compSize = children[i].getPreferredSize(); 577 children[i].setBounds(xInset + insets.left, height, compSize.width, compSize.height); 580 height += compSize.height + yGap; 581 } 582 583 } 584 585 public Dimension minimumLayoutSize(Container c) { 586 Insets insets = c.getInsets(); 587 int height = yInset + insets.top; 588 int width = 0 + insets.left + insets.right; 589 590 Component[] children = c.getComponents(); 591 Dimension compSize = null; 592 for (int i = 0; i < children.length; i++) { 593 compSize = children[i].getPreferredSize(); 594 height += compSize.height + yGap; 595 width = Math.max(width, compSize.width + insets.left + insets.right + xInset*2); 596 } 597 height += insets.bottom; 598 return new Dimension( width, height); 599 } 600 601 public Dimension preferredLayoutSize(Container c) { 602 return minimumLayoutSize(c); 603 } 604 605 public void removeLayoutComponent(Component c) {} 606 } 607 608 609 } 610 | Popular Tags |