All Downloads are FREE. Search and download functionalities are using the official Maven repository.

convex.gui.components.HostCombo Maven / Gradle / Ivy

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);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy