本文整理匯總了Java中javax.swing.JTextField.setAction方法的典型用法代碼示例。如果您正苦於以下問題:Java JTextField.setAction方法的具體用法?Java JTextField.setAction怎麽用?Java JTextField.setAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.setAction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupGui
import javax.swing.JTextField; //導入方法依賴的package包/類
private void setupGui()
{
JLabel label = new JLabel(CurrentLocale.get("com.tle.admin.security.tree.itemsearcher.search"));
query = new JTextField();
query.setAction(searchAction);
JButton search = new JButton(searchAction);
model = new MyTableModel();
table = new JTable(model)
{
private static final long serialVersionUID = 1L;
@Override
public String getToolTipText(MouseEvent event)
{
String tip = null;
int rowIndex = rowAtPoint(event.getPoint());
if( rowIndex != -1 )
{
tip = ItemSearcher.this.model.getItemDescription(rowIndex);
}
if( tip == null || tip.trim().length() == 0 )
{
tip = CurrentLocale.get("com.tle.admin.security.tree.itemsearcher.nodesc");
}
else if( tip.length() > 100 )
{
tip = tip.substring(0, 100) + "...";
}
return tip;
}
};
table.getSelectionModel().addListSelectionListener(this);
JScrollPane scroller = new JScrollPane(table);
countLabel = new JLabel();
next = new JButton(">");
prev = new JButton("<");
next.setEnabled(false);
prev.setEnabled(false);
next.addActionListener(this);
prev.addActionListener(this);
final int width1 = label.getPreferredSize().width;
final int width2 = search.getPreferredSize().width;
final int height = search.getPreferredSize().height;
final int[] rows = {height, TableLayout.FILL, height,};
final int[] cols = {width1, TableLayout.FILL, width2, width2,};
setLayout(new TableLayout(rows, cols));
setBorder(AppletGuiUtils.DEFAULT_BORDER);
add(label, new Rectangle(0, 0, 1, 1));
add(query, new Rectangle(1, 0, 2, 1));
add(search, new Rectangle(3, 0, 1, 1));
add(scroller, new Rectangle(0, 1, 4, 1));
add(countLabel, new Rectangle(0, 2, 2, 1));
add(prev, new Rectangle(2, 2, 1, 1));
add(next, new Rectangle(3, 2, 1, 1));
updateEditor();
}