Java swing 实现下拉框和文本框同步显示
想要MyEclipse中的swing中實現(xiàn)下拉框和文本框?qū)崿F(xiàn),對下拉框創(chuàng)建MouseEvent、ItemEvent、ActionEvent
private void xingbieMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
setSelectedItem(evt, this.xingbie1);
}
private void xingbieItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
setSelectedItem(evt, this.xingbie1);
}
private void setsex1(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setSelectedItem(evt, this.xingbie1);
}
public static void setSelectedItem(AWTEvent e, JTextField ipTextField) {
JComboBox target = (JComboBox) e.getSource();
String selectedPort = (String) target.getSelectedItem();
ipTextField.setText(selectedPort);
}
?
?
更多文章請關(guān)注以下公眾號
總結(jié)
以上是生活随笔為你收集整理的Java swing 实现下拉框和文本框同步显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信怎么还信用卡?微信还信用卡常见问题及
- 下一篇: java中数组的返回值是什么类型_Jav