convex.gui.components.HostCombo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of convex-gui Show documentation
Show all versions of convex-gui Show documentation
Convex desktop GUI and test applications
The newest version!
package convex.gui.components;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
@SuppressWarnings("serial")
public class HostCombo extends JComboBox {
private static String[] defaultHosts= {"localhost:18888","convex.world"};
private static DefaultComboBoxModel model=new DefaultComboBoxModel<>(defaultHosts) {
};
public HostCombo() {
setModel(model);
setEditable(true);
}
public String getText() {
return (String)getSelectedItem();
}
public void setText(String text) {
this.getModel().setSelectedItem(text);
}
public static void registerGoodConnection(String target) {
if (model.getIndexOf(target)<0) {
model.addElement(target);
model.setSelectedItem(target);
}
}
}