gpt4 book ai didi

java - 这是 JComboBox 中的意图行为吗?我怎样才能避免这种行为?

转载 作者:行者123 更新时间:2023-11-30 05:12:46 25 4
gpt4 key购买 nike

我意识到,如果您在 JComboBox 中有相同的选择,则使用向上/向下箭头键将无法帮助您导航选择。我怎样才能避免这种行为?

请参阅下面的屏幕截图:

alt text http://sites.google.com/site/yanchengcheok/Home/jcombobox.png

public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();

/* If you are having 3 same strings here. Using, up/down arrow key,
* will not move the selection around.
*/
this.jComboBox1.addItem("Intel");
this.jComboBox1.addItem("Intel");
this.jComboBox1.addItem("Intel");
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jComboBox1 = new javax.swing.JComboBox();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jComboBox1.setEditable(true);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(105, 105, 105)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(137, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(63, 63, 63)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(217, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
// End of variables declaration
}

最佳答案

退出 cross posting .

答案已在该帖子中给出。

关于java - 这是 JComboBox 中的意图行为吗?我怎样才能避免这种行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2794606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com