?? psearchcombo.java
字號:
/*
* PSwing Utilities -- Nifty Swing Widgets
* Copyright (C) 2002 Pallas Technology
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Pallas Technology
* 1170 HOWELL MILL RD NW
* SUITE 306
* ATLANTA GEORGIA 30318
*
* PHONE 404.983.0623
* EMAIL info@pallastechnology.com
*
* www.pallastechnology.com
**************************************************************************
* $Archive: SwingTools$
* $FileName: PSearchCombo.java$
* $FileID: 25$
*
* Last change:
* $AuthorName: Rob MacGrogan$
* $Date: 2/19/03 8:43 PM$
* $VerID: 73$
* $Comment: $
**************************************************************************/
package com.pallas.swing.psearchcombo;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import java.util.Enumeration;
import java.util.Vector;
import javax.accessibility.AccessibleContext;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ComboBoxEditor;
import javax.swing.ComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.JComboBox.KeySelectionManager;
import javax.swing.event.ListDataEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComboBoxUI;
import com.pallas.swing.pcombobox.PCombo;
import com.pallas.swing.pcombobox.PComboBox;
/**
* Title: $FileName: PSearchCombo.java$
* @version $VerNum: 2$
* @author $AuthorName: Rob MacGrogan$<br><br>
*
* $Description: $<br>
* $KeyWordsOff: $<br><br>
*/
public class PSearchCombo extends JPanel implements PCombo{
private PSearchPopupWindow popup = null;
private PComboBox pcombo = null;
private JButton searchButton = null;
/**
* Constructor for PSearchCombo.
* @param aModel
*/
public PSearchCombo(ComboBoxModel aModel) {
pcombo = new PComboBox(aModel);
initializePSearchCombo();
}
/**
* Constructor for PSearchCombo.
* @param items
*/
public PSearchCombo(Object[] items) {
pcombo = new PComboBox(items);
initializePSearchCombo();
}
/**
* Constructor for PSearchCombo.
* @param items
*/
public PSearchCombo(Vector items) {
pcombo = new PComboBox(items);
initializePSearchCombo();
}
/**
* Constructor for PSearchCombo.
*/
public PSearchCombo() {
pcombo = new PComboBox();
initializePSearchCombo();
}
public Object setSelectedItemByValue(Object item){
return pcombo.setSelectedItemByValue(item);
}
protected void initializeComponent(){
}
private Component findUltimateParent(){
Component parent = getParent();
Component testParent = null;
while((testParent = parent.getParent()) != null){
parent = testParent;
}
return parent;
}
public void addNotify(){
Component cParent = findUltimateParent();
if (cParent instanceof Window){
Window winParent = (Window)cParent;
popup = new PSearchPopupWindow(this, winParent);
}
else if (cParent instanceof Dialog){
Dialog dParent = (Dialog)cParent;
popup = new PSearchPopupWindow(this, dParent);
}
else{
throw new IllegalArgumentException("Component not in a window or dialog.");
}
searchButton.addActionListener(
new ActionListener(){
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent ev) {
popup.showPopup();
}
}
);
super.addNotify();
}
public JComboBox getComboBox(){
return pcombo;
}
protected void initializePSearchCombo(){
searchButton = buildSerachButton();
setLayout(new BorderLayout());
add(searchButton, BorderLayout.EAST);
add(pcombo, BorderLayout.CENTER);
}
private JButton buildSerachButton(){
JButton btn = new JButton("...");
return btn;
}
public Enumeration getUpperCaseContents(){
return pcombo.getUpperCaseContents();
}
/**
* @see com.pallas.swing.pcombobox.PComboBox#buildIndex()
*/
public synchronized void buildIndex() {
pcombo.buildIndex();
}
/**
* @see com.pallas.swing.pcombobox.PComboBox#getTextField()
*/
public JTextField getTextField() {
return pcombo.getTextField();
}
/**
* @see com.pallas.swing.pcombobox.PComboBox#search(String)
*/
public int search(String search) {
return pcombo.search(search);
}
/**
* @see javax.swing.JComboBox#setEditable(boolean)
*/
public void setEditable(boolean arg0) {
pcombo.setEditable(arg0);
}
/**
* @see javax.swing.JComboBox#setKeySelectionManager(KeySelectionManager)
*/
public void setKeySelectionManager(KeySelectionManager arg0) {
pcombo.setKeySelectionManager(arg0);
}
/**
* @see com.pallas.swing.pcombobox.PComboBox#setSelectionByDisplay(String)
*/
public void setSelectionByDisplay(String display) {
pcombo.setSelectionByDisplay(display);
}
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent arg0) {
pcombo.actionPerformed(arg0);
}
/**
* @see javax.swing.JComboBox#addActionListener(ActionListener)
*/
public void addActionListener(ActionListener arg0) {
pcombo.addActionListener(arg0);
}
/**
* @see javax.swing.JComboBox#addItem(Object)
*/
public void addItem(Object arg0) {
pcombo.addItem(arg0);
}
/**
* @see java.awt.ItemSelectable#addItemListener(ItemListener)
*/
public void addItemListener(ItemListener arg0) {
pcombo.addItemListener(arg0);
}
/**
* @see javax.swing.JComboBox#addPopupMenuListener(PopupMenuListener)
*/
public void addPopupMenuListener(PopupMenuListener arg0) {
pcombo.addPopupMenuListener(arg0);
}
/**
* @see javax.swing.JComboBox#configureEditor(ComboBoxEditor, Object)
*/
public void configureEditor(ComboBoxEditor arg0, Object arg1) {
pcombo.configureEditor(arg0, arg1);
}
/**
* @see javax.swing.event.ListDataListener#contentsChanged(ListDataEvent)
*/
public void contentsChanged(ListDataEvent arg0) {
pcombo.contentsChanged(arg0);
}
/**
* @see javax.swing.JComboBox#firePopupMenuCanceled()
*/
public void firePopupMenuCanceled() {
pcombo.firePopupMenuCanceled();
}
/**
* @see javax.swing.JComboBox#firePopupMenuWillBecomeInvisible()
*/
public void firePopupMenuWillBecomeInvisible() {
pcombo.firePopupMenuWillBecomeInvisible();
}
/**
* @see javax.swing.JComboBox#firePopupMenuWillBecomeVisible()
*/
public void firePopupMenuWillBecomeVisible() {
pcombo.firePopupMenuWillBecomeVisible();
}
/**
* @see java.awt.Component#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return pcombo.getAccessibleContext();
}
/**
* @see javax.swing.JComboBox#getAction()
*/
public Action getAction() {
return pcombo.getAction();
}
/**
* @see javax.swing.JComboBox#getActionCommand()
*/
public String getActionCommand() {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -