001/* 002 * $Source: /cvsroot2/open/projects/WebARTS/ca/bc/webarts/widgets/PopUpButton.java,v $ 003 * $Name: $ 004 * $Revision: 1236 $ 005 * $Date: 2018-03-02 22:30:44 -0800 (Fri, 02 Mar 2018) $ 006 * $Locker: $ 007 */ 008/* 009 * PopUpButton -- A Widget Class to mimic a drop down box which allows 010 * any JComponent inside its popup. 011 * 012 * Copyright (C) 2001 WebARTS Design, North Vancouver Canada 013 * http://www..webarts.bc.ca 014 * 015 * This program is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU General Public License as published by 017 * the Free Software Foundation; either version 2 of the License, or 018 * (at your option) any later version. 019 * 020 * This program is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU General Public License for more details. 024 * 025 * You should have received a copy of the GNU General Public License 026 * along with this program; if not, write to the Free Software 027 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 028 */ 029package ca.bc.webarts.widgets; 030 031import ca.bc.webarts.tools.Log; 032import ca.bc.webarts.widgets.Util; 033 034import java.awt.BorderLayout; 035import java.awt.Container; 036import java.awt.Dimension; 037import java.awt.Insets; 038import java.awt.Point; 039import java.awt.Toolkit; 040import java.awt.event.ActionEvent; 041import java.awt.event.ActionListener; 042import java.awt.event.MouseAdapter; 043import java.awt.event.MouseEvent; 044import java.awt.event.MouseListener; 045import java.awt.event.WindowAdapter; 046import java.awt.event.WindowEvent; 047import java.beans.PropertyChangeEvent; 048import java.beans.PropertyChangeListener; 049import java.io.File; 050import java.text.Collator; 051import java.net.URL; 052import java.util.Vector; 053 054import javax.swing.event.AncestorEvent; 055import javax.swing.event.AncestorListener; 056import javax.swing.DefaultListModel; 057import javax.swing.ImageIcon; 058import javax.swing.JButton; 059import javax.swing.JCheckBox; 060import javax.swing.JFrame; 061import javax.swing.JLabel; 062import javax.swing.JList; 063import javax.swing.JPanel; 064import javax.swing.JScrollPane; 065import javax.swing.JWindow; 066import javax.swing.ListModel; 067import javax.swing.SwingUtilities; 068 069import kiwi.util.KiwiUtils; 070 071/** 072 * A custom Drop Down box that requires the user to select the button to open and 073 * close the popup list. 074 * 075 * @author Tom Gutwin P.Eng 076 * @created October 15, 2001 077 */ 078public class PopUpButton extends JButton 079{ 080 081 /** 082 * a test JFrame. 083 */ 084 protected static JFrame appFrame_ = null; 085 086 /** 087 * The Log Filename. 088 */ 089 protected static String logFile_ = "." + File.separator + "PopUpLog.txt"; 090 /** 091 * The Log that will get used. 092 */ 093 protected static Log log_ = Log.createLog(Log.DEBUG, logFile_); 094 /** 095 * A Class holder for its name (used in Logging). 096 */ 097 private static String className_ = "PopUpButton"; 098 099 /** 100 * Sample Test Data to put in the JList. 101 */ 102 protected final static String[] SAMPLE_LIST_DATA = 103 {"Item0", "Item1", "Item12", "Item3", "Item8", "Item4", "Item5", "Item6", 104 "Item7", "Item11", "Item11", "Item0"}; 105 /** 106 * The list model used by this class. 107 */ 108 protected DefaultListModel listModel_ = new DefaultListModel(); 109 110 /** 111 * The JFrame that the popUpPanel_/PopUpList will live in. 112 */ 113 protected JWindow popUpWin_ = new JWindow(); 114 115 /** 116 * The JPanel that the popUpScroller_ will live in. 117 */ 118 protected JPanel popUpPanel_ = new JPanel(); 119 120 /** 121 * The JScrollPane that the PopUpList will live in. 122 */ 123 protected JScrollPane popUpScroller_ = new JScrollPane(); 124 125 /** 126 * Flags if the popup list is showing. 127 */ 128 protected boolean popUpIsShowing_ = false; 129 130 /** 131 * The position on the screen to place the popup. 132 */ 133 protected Point popUpPosition_ = new Point(25, 25); 134 135 136 /** 137 * The Property Listener for this class. 138 */ 139 protected PropertyChangeListener PopUpButtonPropListener_ = 140 new PropertyChangeListener() 141 { 142 public void propertyChange(PropertyChangeEvent e) 143 { 144 PopUpButton me = (PopUpButton) e.getSource(); 145 //System.out.println("PropChange Event from: " + e.getPropertyName()); 146 me.showPopUp(false); 147 } 148 }; 149 150 151 /** 152 * The Ancestor Listener for this class. 153 */ 154 protected AncestorListener PopUpButtonAncestorListener_ = 155 new AncestorListener() 156 { 157 public void ancestorAdded(AncestorEvent e) 158 { 159 PopUpButton me = (PopUpButton) e.getSource(); 160 //System.out.println("AncestorAddedEvent from: " + e.getAncestor().getName()); 161 } 162 163 public void ancestorRemoved(AncestorEvent e) 164 { 165 PopUpButton me = (PopUpButton) e.getSource(); 166 //System.out.println("AncestorRemovedEvent from: " + e.getAncestor().getName()); 167 buttonMoved(); 168 } 169 170 public void ancestorMoved(AncestorEvent e) 171 { 172 PopUpButton me = (PopUpButton) e.getSource(); 173 //System.out.println("AncestorMovedEvent from: " + e.getAncestor().getName()); 174 buttonMoved(); 175 } 176 }; 177 178 179 /** 180 * The Action Listener for this class. 181 */ 182 protected ActionListener PopUpButtonActionListener_ = 183 new ActionListener() 184 { 185 public void actionPerformed(ActionEvent e) 186 { 187 PopUpButton me = (PopUpButton) e.getSource(); 188 //System.out.println("PopUpButton Action Event from: " + 189 // e.getActionCommand()); 190 popUpPanel_.setSize(getWidth(),popUpPanel_.getHeight()); 191 me.togglePopUp(); 192 } 193 }; 194 195 196 /** 197 * The List of items that goes in the PopUp. 198 */ 199 JList popUpList_ = null; 200 201 202 203 /** 204 * Basic Constructor that instantiates with an empty popup list using the basic 205 * renderer. Sets the text allignment to LEFT and adds a metal Icon. 206 */ 207 protected PopUpButton() 208 { 209 final String methodName = className_ + ": PopUpButton()"; 210 log_.startMethod(methodName); 211 212 setHorizontalTextPosition(LEFT); 213 setHorizontalAlignment(RIGHT); 214 StringBuffer fileName = new StringBuffer(); 215 fileName.append("ca"); 216 fileName.append(File.separator); 217 fileName.append("bc"); 218 fileName.append(File.separator); 219 fileName.append("webarts"); 220 fileName.append(File.separator); 221 fileName.append("widgets"); 222 fileName.append(File.separator); 223 fileName.append(""); 224 fileName.append("DropDownButtonIcon.jpg"); 225 //URL imgUrl = this.getClass().getResource(fileName.toString(0)); 226 //backgroundTexture_ = Util.loadImage(fileName, "jOggPlayer.jar"); 227 log_.debug("Retrieving "+fileName.toString()); 228 String jarFilename = "";//Util.tokenReplace(codeBase_.getFile(),"/",File.separator)+ 229 // File.separator+"jOggPlayer.jar"; 230 try 231 { 232 //setIcon(new ImageIcon(Util.loadImage(fileName.toString(),jarFilename))); 233 setIcon(new ImageIcon( 234 PopUpButton.class.getResource("/ca/bc/webarts/widgets/DropDownButtonIcon.jpg"))); 235 } 236 catch(Exception crap) 237 { 238 log_.minor("Exception retrieving "+fileName+" from "+jarFilename,crap); 239 } 240 setMargin(new Insets(0,0,0,0)); 241 242 log_.endMethod(); 243 } 244 245 246 /** 247 * Constructor that instantiates the popup list using the passed in JList and 248 * basic renderer. 249 * 250 * @param jl The JList to iunstantiate with. 251 */ 252 public PopUpButton(JList jl) 253 { 254 final String methodName = className_ + ": PopUpButton(JList)"; 255 //log_ = Log.createLog(Log.FULL, logFile_); 256 log_.startMethod(methodName); 257 if (jl != null) 258 { 259 popUpList_ = jl; 260 sortDefaultList((DefaultListModel)popUpList_.getModel()); 261 } 262 else 263 { 264 System.err.println("PopUpButton: The passed in JList is Null, " + 265 "initializing with an empty JList Popup."); 266 popUpList_ = new JList(listModel_); 267 } 268 setHorizontalTextPosition(LEFT); 269 setHorizontalAlignment(RIGHT); 270 setIcon(new ImageIcon(this.getClass().getResource( 271 "DropDownButtonIcon.jpg"))); 272 setMargin(new Insets(1,1,1,1)); 273 popUpList_.addMouseListener(new ListMouseListener()); 274 popUpList_.setVisibleRowCount(6); 275 popUpScroller_.getViewport().setView(popUpList_); 276 popUpPanel_.add(popUpScroller_); 277 //popUpPanel_.setSize(getWidth()); 278 popUpWin_.getContentPane().add(popUpPanel_); 279 280 addPropertyChangeListener(PopUpButtonPropListener_); 281 addActionListener(PopUpButtonActionListener_); 282 addAncestorListener(PopUpButtonAncestorListener_); // listens if parent(s) move or toggle visibility 283 log_.endMethod(); 284 } 285 286 287 /** 288 * Constructor that instantiates the popup list using the passed in Array and 289 * basic renderer. 290 * 291 * @param jl An array of objects to instantiate the popup list with. 292 */ 293 public PopUpButton(Object[] jl) 294 { 295 final String methodName = className_ + ": PopUpButton(Object[])"; 296 //log_ = Log.createLog(Log.FULL, logFile_); 297 log_.startMethod(methodName); 298 if (jl != null && jl.length > 0) 299 { 300 for (int i = 0; i < jl.length; i++) 301 { 302 ((DefaultListModel) listModel_).addElement(jl[i]); 303 } 304 popUpList_ = new JList(listModel_); 305 sortDefaultList((DefaultListModel)popUpList_.getModel()); 306 } 307 else 308 { 309 log_.minor("PopUpButton: The passed in Array is Null" + 310 " (or empty), initializing with an empty JList Popup."); 311 popUpList_ = new JList(listModel_); 312 } 313 setHorizontalTextPosition(LEFT); 314 setHorizontalAlignment(RIGHT); 315 setIcon(new ImageIcon(this.getClass().getResource( 316 "DropDownButtonIcon.jpg"))); 317 setMargin(new Insets(1,1,1,1)); 318 popUpList_.addMouseListener(new ListMouseListener()); 319 popUpList_.setVisibleRowCount(6); 320 popUpList_.setBorder(null); 321 popUpScroller_.getViewport().setView(popUpList_); 322 popUpPanel_.add(popUpScroller_); 323 //popUpPanel_.setWidth(getWidth()); 324 popUpWin_.getContentPane().add(popUpPanel_); 325 326 addPropertyChangeListener(PopUpButtonPropListener_); 327 addActionListener(PopUpButtonActionListener_); 328 addAncestorListener(PopUpButtonAncestorListener_); // listens if parent(s) move or toggle visibility 329 log_.endMethod(); 330 } 331 332 333 /** 334 * Constructor that instantiates the popup list using the passed in Vector and 335 * basic renderer. 336 * 337 * @param jlv A Vector of objects to instantiate the popup list with. 338 */ 339 public PopUpButton(Vector jlv) 340 { 341 final String methodName = className_ + ": PopUpButton(Vector)"; 342 //log_ = Log.createLog(Log.FULL, logFile_); 343 log_.startMethod(methodName); 344 if (jlv != null && jlv.size() > 0) 345 { 346 for (int i = 0; i < jlv.size(); i++) 347 { 348 ((DefaultListModel) listModel_).addElement(jlv.get(i)); 349 } 350 popUpList_ = new JList(listModel_); 351 sortDefaultList((DefaultListModel)popUpList_.getModel()); 352 } 353 else 354 { 355 log_.minor("PopUpButton: The passed in Vector is Null" + 356 " (or empty), initializing with an empty JList Popup."); 357 popUpList_ = new JList(listModel_); 358 } 359 setHorizontalTextPosition(LEFT); 360 setHorizontalAlignment(RIGHT); 361 setIcon(new ImageIcon(this.getClass().getResource( 362 "DropDownButtonIcon.jpg"))); 363 setMargin(new Insets(1,1,1,1)); 364 popUpList_.addMouseListener(new ListMouseListener()); 365 popUpList_.setVisibleRowCount(6); 366 popUpScroller_.getViewport().setView(popUpList_); 367 popUpPanel_.add(popUpScroller_); 368 //popUpPanel_.setWidth(getWidth()); 369 popUpWin_.getContentPane().add(popUpPanel_); 370 371 addPropertyChangeListener(PopUpButtonPropListener_); 372 addActionListener(PopUpButtonActionListener_); 373 addAncestorListener(PopUpButtonAncestorListener_); // listens if parent(s) move or toggle visibility 374 log_.endMethod(); 375 } 376 377 378 /** 379 * The main program for the PopUpButton class 380 * 381 * @param args The command line arguments 382 */ 383 public static void main(String[] args) 384 { 385 appFrame_ = new JFrame(); 386 appFrame_.getContentPane().setLayout(new BorderLayout()); 387 appFrame_.setTitle("PopUpButton TEST Window."); 388 final PopUpButton myTestButton = new PopUpButton(SAMPLE_LIST_DATA); 389 appFrame_.addWindowListener( 390 new WindowAdapter() 391 { 392 public void windowClosing(WindowEvent e) 393 { 394 myTestButton.getLog().close(); 395 System.exit(0); 396 } 397 }); 398 myTestButton.setText("Press Me"); 399 appFrame_.getContentPane().add(myTestButton); 400 appFrame_.pack(); 401 KiwiUtils.centerWindow(appFrame_); 402 appFrame_.toFront(); 403 appFrame_.setVisible(true); 404 appFrame_.repaint(); 405 } 406 407 408 /** 409 * Sets the SelectedIndex attribute of the PopUpButton object. 410 * 411 * @param index The new SelectedIndex value 412 */ 413 public void setSelectedIndex(int index) 414 { 415 if (index < 0) 416 index = ((DefaultListModel)((JList) popUpList_).getModel()).getSize() -1; 417 if (index >= ((DefaultListModel)((JList) popUpList_).getModel()).getSize()) 418 index = 0; 419 final String methodName = className_ + ": setSelectedIndex("+index+")"; 420 log_.startMethod(methodName); 421 422 popUpList_.setSelectedIndex(index); 423 log_.endMethod(); 424 } 425 426 427 /** 428 * Gets the SelectedItem attribute of the PopUpButton object 429 * 430 * @return The SelectedItem value 431 */ 432 public Object getSelectedItem() 433 { 434 final String methodName = className_ + ": getSelectedItem()"; 435 log_.startMethod(methodName); 436 log_.endMethod(); 437 return (Object) ((DefaultListModel)((JList) popUpList_).getModel()). 438 getElementAt(getSelectedIndex()); 439 } 440 441 442 /** 443 * Gets the SelectedIndex attribute of the PopUpButton object 444 * 445 * @return The SelectedIndex value 446 */ 447 public int getSelectedIndex() 448 { 449 final String methodName = className_ + ": getSelectedIndex()"; 450 log_.startMethod(methodName); 451 int num = popUpList_.getSelectedIndex(); 452 log_.debug("\nSelected Item num = "+num); 453 log_.endMethod(); 454 return num; 455 } 456 457 458 /** 459 * Gets the ItemCount attribute of the PopUpButton object 460 * 461 * @return The ItemCount value 462 */ 463 public int getItemCount() 464 { 465 final String methodName = className_ + ": getSelectedIndex()"; 466 log_.startMethod(methodName); 467 int num = ((DefaultListModel)((JList) popUpList_).getModel()).getSize(); 468 log_.debug("ItemCount = " + num); 469 log_.endMethod(); 470 return num; 471 } 472 473 474 /** 475 * Gets the Log object that the PopUpButton is using. 476 * 477 * @return The Log . 478 */ 479 Log getLog() 480 { 481 return log_; 482 } 483 484 485 /** 486 * Sorts the entries using the custom sortArray method. 487 **/ 488 protected void sortDefaultList(DefaultListModel dlm) 489 { 490 final String methodName = className_ + ": sortDefaultList()"; 491 log_.startMethod(methodName); 492 493 if (dlm != null) 494 { 495 try 496 { 497 int numItems = dlm.getSize(); 498 String[] a = new String[numItems]; 499 for (int i=0; i < numItems; i++) 500 { 501 a[i] = (String) dlm.getElementAt(i); 502 } 503 sortArray(Collator.getInstance(),a); 504 // Locale loc = Locale.FRENCH; 505 // sortArray(Collator.getInstance(loc), (String[])a); 506 for (int i=0; i < numItems; i++) 507 { 508 dlm.setElementAt(a[i], i); 509 } 510 } 511 catch (Exception ex) 512 { 513 log_.minor("Threw a:",ex); 514 } 515 } 516 log_.endMethod(); 517 } 518 519 520 /** 521 * the main button moved so deal with it. 522 */ 523 protected void buttonMoved() 524 { 525 final String methodName = className_ + ": buttonMoved"; 526 log_.startMethod(methodName); 527 528 // close the button dropdown. 529 if (popUpIsShowing_) 530 { 531 popUpIsShowing_ = showPopUp(false); 532 } 533 log_.endMethod(); 534 } 535 536 537 /** 538 * Sorts the strArray alphabetically. 539 **/ 540 protected void sortArray(Collator collator, String[] strArray) 541 { 542 final String methodName = className_ + ": sortArray(Collator, String[])"; 543 log_.startMethod(methodName); 544 String tmp; 545 int lengthOfArray = strArray.length; 546 log_.debug("Sorting " + lengthOfArray + " items."); 547 if (lengthOfArray == 1) return; 548 for (int i = 0; i < lengthOfArray; i++) 549 { 550 for (int j = i + 1; j < lengthOfArray; j++) 551 { 552 if( collator.compare(strArray[i], strArray[j] ) > 0 ) 553 { 554 tmp = strArray[i]; 555 strArray[i] = strArray[j]; 556 strArray[j] = tmp; 557 } 558 } 559 } 560 log_.endMethod(); 561 } 562 563 /** 564 * Toggles the popup to show or not show depending on if it is currently shown. 565 */ 566 protected void togglePopUp() 567 { 568 final String methodName = className_ + ": togglePopUp"; 569 log_.startMethod(methodName); 570 if (popUpIsShowing_) 571 { 572 popUpIsShowing_ = showPopUp(false); 573 } 574 else 575 { 576 popUpIsShowing_ = showPopUp(true); 577 } 578 log_.endMethod(); 579 } 580 581 582 /** 583 * Shows or Removes the JList Popup depending on the passed parm. 584 * 585 * @param showIt flag to show or remove the popup. 586 * @return Description of the Returned Value 587 */ 588 boolean showPopUp(boolean showIt) 589 { 590 final String methodName = className_ + ": showPopUp " + showIt; 591 log_.startMethod(methodName); 592 /* 593 * int frameX = appFrame_.getX(); 594 * int frameY = appFrame_.getY(); 595 * int framedX = appFrame_.getHeight(); 596 * int framedY = appFrame_.getWidth(); 597 */ 598 int buttonX = getX(); 599 int buttonY = getY(); 600 int buttondY = getHeight(); 601 int buttondX = getWidth(); 602 /* 603 * int frameBorderWidth = (framedY - buttondY) / 2; 604 * int frameTitleBarHeight = framedX - buttondX - frameBorderWidth; 605 * log_.debug("Window Sizes:"); 606 * log_.debug(" AppFrame X=" + frameX); 607 * log_.debug(" AppFrame Y=" + frameY); 608 * log_.debug(" AppFrame dX=" + framedX); 609 * log_.debug(" AppFrame dY=" + framedY); 610 * log_.debug(" Border dX=" + frameBorderWidth); 611 * log_.debug(" TitleBar dY=" + frameTitleBarHeight); 612 * popUpPosition_.setLocation(frameX+frameBorderWidth, 613 * frameY+buttonY+buttondX+frameTitleBarHeight); 614 */ 615 JFrame jf = ((JFrame) KiwiUtils.getFrameForComponent(this)); 616 Container parent = this.getParent(); 617 Container parent2 = null; 618 Container parent3 = null; 619 int parentX = 0; 620 int parentY = 0; 621 int parent2X = 0; 622 int parent2Y = 0; 623 int parent3X = 0; 624 int parent3Y = 0; 625 int jfX = 0; 626 int jfY = 0; 627 int jfdX = 0; 628 int jfdY = 0; 629 // Test the screen size to see if the pop up will fit below the button 630 // if not put it above the button 631 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 632 int compSize = 0; 633 if (jf != null) 634 { 635 jfX = jf.getX(); 636 jfY = jf.getY(); 637 jfdX = jf.getWidth(); 638 jfdY = jf.getHeight(); 639 compSize += jfY; 640 /* 641 log_.debug(" JFrame X=" + jfX); 642 log_.debug(" JFrame Y=" + jfY); 643 log_.debug(" JFrame dX=" + jfdX); 644 log_.debug(" JFrame dY=" + jfdY);*/ 645 } 646 if (parent != null) 647 { 648 parentX = parent.getX(); 649 parentY = parent.getY(); 650 parent2 = parent.getParent(); 651 compSize += parentY; 652 /* 653 log_.debug(" Parent X=" + parentX); 654 log_.debug(" Parent Y=" + parentY);*/ 655 } 656 if (parent2 != null) 657 { 658 parent2X = parent2.getX(); 659 parent2Y = parent2.getY(); 660 parent3 = parent2.getParent(); 661 compSize += parent2Y; 662 /* 663 log_.debug(" Parent2 X=" + parent2X); 664 log_.debug(" Parent2 Y=" + parent2Y);*/ 665 } 666 if (parent3 != null) 667 { 668 parent3X = parent3.getX(); 669 parent3Y = parent3.getY(); 670 compSize += parent3Y; 671 /* 672 log_.debug(" Parent3 X=" + parent3X); 673 log_.debug(" Parent3 Y=" + parent3Y);*/ 674 } 675 compSize +=157; 676 compSize +=2*buttondY; 677 /* 678 log_.debug(" Button X=" + buttonX); 679 log_.debug(" Button Y=" + buttonY); 680 log_.debug(" Button dX=" + buttondX); 681 log_.debug(" Button dY=" + buttondY); 682 log_.debug(" Screen dY=" + screenSize.height); 683 log_.debug(" PopWinHeight" + popUpWin_.getHeight()); 684 log_.debug("Comparing Screen Height " + screenSize.height + " to " + 685 compSize);*/ 686 if (screenSize.height > compSize ) 687 { 688 //above 689 log_.debug("Placing Popup below button"); 690 popUpPosition_.setLocation(jfX + buttonX + parentX, 691 jfY+parentY+parent2Y+ 2*buttondY);//jfY + buttonY + parentY + 2 * buttondY); 692 } 693 else 694 { 695 //below 696 log_.debug("Placing Popup above button"); 697 popUpPosition_.setLocation(jfX + buttonX + parentX, 698 jfY+parentY+parent2Y+buttondY-157); 699 } 700 701 //popUpWin_.setSize(buttondX,buttondY*4); 702 popUpWin_.pack(); 703 popUpWin_.setLocation(popUpPosition_); 704 int selectIndex = popUpList_.getSelectedIndex(); 705 if (selectIndex >= 0) 706 { 707 popUpList_.ensureIndexIsVisible(selectIndex); 708 } 709 popUpWin_.setVisible(showIt); 710 if (showIt) 711 { 712 popUpWin_.show(); 713 popUpWin_.toFront(); 714 //popUpWin_.setSize(buttondX,buttondY*4); 715 } 716 log_.debug("new PopUp Position = " + popUpPosition_.getX() + ", " + 717 popUpPosition_.getY()); 718 log_.debug("new PopUp Size x,y = " + popUpWin_.getWidth() + ", " + 719 popUpWin_.getHeight()); 720 721 log_.endMethod(); 722 return showIt; 723 } 724 725 726 /** 727 * A private mouse listener for the popup list.NOTHING really implemented yet 728 (other than som terminal output debugging). 729 * 730 * @author Tom Gutwin P.Eng 731 * @created October 15, 2001 732 */ 733 class ListMouseListener extends MouseAdapter 734 { 735 /** 736 * Mouse Clicked Listener method. 737 * 738 * @param e The actual MouseEvent 739 */ 740 public void mouseClicked(MouseEvent e) 741 { 742 int index = popUpList_.locationToIndex(e.getPoint()); 743 //System.out.println(" Mouse Click: " + e.getClickCount() + 744 // " click on Item " + index); 745 } 746 747 748 /** 749 * Mouse Pressed Listener method. 750 * 751 * @param e The actual MouseEvent 752 */ 753 public void mousePressed(MouseEvent e) 754 { 755 int index = popUpList_.locationToIndex(e.getPoint()); 756 //System.out.println(" Mouse Press on Item " + index); 757 } 758 759 760 /** 761 * Mouse Entered Listener method. 762 * 763 * @param e The actual MouseEvent 764 */ 765 public void mouseEntered(MouseEvent e) 766 { 767 int index = popUpList_.locationToIndex(e.getPoint()); 768 //System.out.println(" Mouse Enter Item " + index); 769 } 770 } 771} 772 773 774 775