Java Code Examples for javax.swing.JTextField

The following are top voted examples for showing how to use javax.swing.JTextField. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: myster   File: MessageManager.java   View source code 7 votes vote down vote up
public MessagePreferencesPanel() {
    setLayout(null);

    refuseMessages = new JCheckBox("Refuse Messages");
    refuseMessages.setSize(150, 25);
    refuseMessages.setLocation(10, 25);
    refuseMessages.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            updateEnabled();
        }
    });
    add(refuseMessages);

    denyMessageLabel = new JLabel("Refusal Message:");
    denyMessageLabel.setSize(150, 25);
    denyMessageLabel.setLocation(20, 50);
    add(denyMessageLabel);

    denyMessageText = new JTextField(REFUSAL_MESSAGE_DEFAULT);
    denyMessageText.setSize(400, 25);
    denyMessageText.setLocation(25, 75);
    add(denyMessageText);

    setSize(STD_XSIZE, STD_YSIZE);
}
 
Example 2
Project: QN-ACTR-Release   File: DistributionsEditor.java   View source code 7 votes vote down vote up
/**
 * Helper method to extract the probability components the dialog's components.
 * These components are the probability labels and the probability TextFields.
 * @return a Vector of probability related components
 * @author Federico Dal Castello
 */
private Vector<Component> getProbabilityComponents() {
	Vector<Component> probabilityComponents = new Vector<Component>();

	Vector<Component> components = new Vector<Component>();
	components.addAll(Arrays.asList(intervalPanels[1].getComponents()));
	components.addAll(Arrays.asList(intervalPanels[2].getComponents()));

	Iterator<Component> it = components.iterator();

	while (it.hasNext()) {
		Component comp = it.next();

		if (comp instanceof JTextField) {
			if (comp.getName().equals(PROBABILITY_INTERVAL_A) || comp.getName().equals(PROBABILITY_INTERVAL_B)) {
				probabilityComponents.add(comp);
			}
		}

		if (comp instanceof JLabel && ((JLabel) comp).getText().equals(PROBABILITY)) {
			probabilityComponents.add(comp);
		}
	}

	return probabilityComponents;
}
 
Example 3
Project: AgentWorkbench   File: TableCellEditor4Domains.java   View source code 6 votes vote down vote up
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {

	Component editComponent = null;
	
	this.domainVector = ctsDialog.getDomainVector();
	this.domainName = (String) value;
	if (this.domainName!=null && this.domainName.equals(GeneralGraphSettings4MAS.DEFAULT_DOMAIN_SETTINGS_NAME)==true) {
		JLabel jLabel = new JLabel(this.domainName);
		editComponent = jLabel;
		
	} else {
		JTextField jTextField = new JTextField(this.domainName);
        jTextField.setBorder(BorderFactory.createEmptyBorder());
        jTextField.getDocument().addDocumentListener(this.getTextFieldDocumentListener());
        editComponent = jTextField;
        
	}
	return editComponent;
}
 
Example 4
Project: DocIT   File: DeptView.java   View source code 6 votes vote down vote up
public DeptView(Controller controller) {
	this.controller = controller;
	frame = new JFrame();
	namePanel = new JPanel(new GridLayout(1, 2, 0, 0));
	managerPanel = new JPanel(new GridLayout(1, 2, 66, 0));
	employeePanel = new JPanel(new GridLayout(1, 2, 30, 0));
	subDeptPanel = new JPanel(new GridLayout(1, 2, 20, 0));
	salaryPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 0));
	buttonPanel = new JPanel(new GridLayout(1, 3, 20, 0));
	subDeptLabel = new JLabel();
	salaryLabel = new JLabel();
	cutButton = new JButton();
	saveButton = new JButton();
	okButton = new JButton();
	cancelButton = new JButton();
	nameField = new JTextField();
	managerButton = new JButton();
	employeeListModel = new DefaultListModel();
	subDeptListModel = new DefaultListModel();
	employeeList = new JList(employeeListModel);
	subDeptList = new JList(subDeptListModel);
	init();
}
 
Example 5
Project: jaer   File: AbstractMultiBitRegisterCP.java   View source code 6 votes vote down vote up
private void setValueFromGUI(final JTextField tf) {
	final AbstractMultiBitRegisterCP embeddingCP = (AbstractMultiBitRegisterCP) tf.getParent();

	embeddingCP.startEdit();
	try {
		embeddingCP.reg.setPartialValue(componentID, Integer.parseInt(tf.getText()));
		embeddingCP.reg.setFileModified();
		tf.setBackground(Color.white);
	}
	catch (final Exception ex) {
		tf.selectAll();
		tf.setBackground(Color.red);
		log.warning(ex.toString());
	}
	finally {
		embeddingCP.endEdit();
	}
}
 
Example 6
Project: GOLAD   File: TimeLimit.java   View source code 6 votes vote down vote up
public void clickAction(){
    JTextField hours = new JTextField();
    JTextField minutes = new JTextField();
    JTextField seconds = new JTextField();
    Object[] message = {
        "Hours", hours,
        "Minutes", minutes,
        "Seconds",seconds
    };
    int option = JOptionPane.showConfirmDialog(null, message, "Time Limit", JOptionPane.OK_CANCEL_OPTION);
    if (option == JOptionPane.OK_OPTION) {
        try{
            w.setTimeLimit(Integer.parseInt(hours.getText()),
            Integer.parseInt(minutes.getText()),
            Integer.parseInt(seconds.getText()),0);
        }catch(Exception e){
            w.setTimeLimit(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE);
        }
    }
}
 
Example 7
Project: Community_Tieba-Data-Analyzer   File: WebCrawler.java   View source code 6 votes vote down vote up
public void paintCrawler(JPanel _panel) {
		//Define all new Components GUI
		JPanel crawlerPanel = new JPanel();
		JPanel configPanel = new JPanel();
		JButton crawl = new JButton(" Crawl ");
		JTextField name = new JTextField(25);
		name.setText("userNameID");
		JButton random = new JButton("Random");
				
		//Add action Listener
		crawl.addActionListener(event -> crawlInfo(name.getText()));
//		random.addActionListener();
		        
		//add to pane and manage layout
		_panel.add(configPanel, BorderLayout.CENTER);
		_panel.add(crawlerPanel, BorderLayout.SOUTH);
		crawlerPanel.add(crawl);
		configPanel.add(name);
		crawlerPanel.add(random);
	}
 
Example 8
Project: https-github.com-apache-zookeeper   File: ZooInspectorConnectionPropertiesDialog.java   View source code 6 votes vote down vote up
private void loadConnectionProps(Properties props) {
    if (props != null) {
        for (Object key : props.keySet()) {
            String propsKey = (String) key;
            if (components.containsKey(propsKey)) {
                JComponent component = components.get(propsKey);
                String value = props.getProperty(propsKey);
                if (component instanceof JTextField) {
                    ((JTextField) component).setText(value);
                } else if (component instanceof JComboBox) {
                    ((JComboBox) component).setSelectedItem(value);
                }
            }
        }
    }
}
 
Example 9
Project: Cognizant-Intelligent-Test-Scripter   File: TreeSearch.java   View source code 6 votes vote down vote up
private void createToolBar() {
    searchBar = new JToolBar();
    searchBar.setFloatable(false);
    searchBar.setLayout(new BoxLayout(searchBar, BoxLayout.X_AXIS));
    searchBar.setBorder(BorderFactory.createEtchedBorder());

    JLabel searchLabel = new JLabel(Utils.getIconByResourceName("/ui/resources/search"));

    searchField = new JTextField();
    searchField.setActionCommand("SearchField");
    searchField.addActionListener(this);

    searchBar.add(searchLabel);
    searchBar.add(new javax.swing.Box.Filler(new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 32767)));
    searchBar.add(searchField);

}
 
Example 10
Project: openjdk-jdk10   File: Test6505027.java   View source code 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 11
Project: incubator-netbeans   File: PropertyPanel.java   View source code 6 votes vote down vote up
/** Creates new form PropertyPanel */
public PropertyPanel(String propCat, boolean add, SessionFactory sessionFactory, String propName, String propValue) {
    initComponents();

    // The comb box only contains the property names that are not defined yet when adding
    if (add) {
        nameComboBox.setModel(new DefaultComboBoxModel(Util.getAvailPropNames(propCat, sessionFactory)));
    } else {
        nameComboBox.setModel(new DefaultComboBoxModel(Util.getAllPropNames(propCat)));
        nameComboBox.setSelectedItem(propName);
    }

    valueTextField = new JTextField();
    valueComboBox = new JComboBox();

    // Add the appropriate component for the value 
    String selectedPropName = (String) nameComboBox.getSelectedItem();
    addValueComponent(selectedPropName, propValue);

    nameComboBox.addActionListener((ActionListener) this);

    // Disable the name combo box for editing
    nameComboBox.setEnabled(add);
}
 
Example 12
Project: incubator-netbeans   File: NameAndLocationPanel.java   View source code 6 votes vote down vote up
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final HTMLIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title", getMessage("LBL_TCWizardTitle"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            if (checkValidity()) {
                updateData();
            }
        }
    };
    txtPrefix.getDocument().addDocumentListener(dListener);
    txtIcon.getDocument().addDocumentListener(dListener);
    
    if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
        txt.getDocument().addDocumentListener(dListener);
    }
}
 
Example 13
Project: incubator-netbeans   File: IDEValidation.java   View source code 6 votes vote down vote up
/** Test Options  
 * - open Options window from main menu Tools|Options
 * - select Editor category
 * - select Fonts & Colors category
 * - select Keymap category
 * - select General category
 * - pick Manual Proxy Setting
 * - set Proxy Host to emea-proxy.uk.oracle.com
 * - set Proxy Port to 80
 * - click OK to confirm and close Options window
 */
public void testOptions() {
    OptionsOperator optionsOper = OptionsOperator.invoke();
    optionsOper.selectEditor();
    optionsOper.selectFontAndColors();
    optionsOper.selectKeymap();
    optionsOper.selectGeneral();
    // "Manual Proxy Setting"
    String hTTPProxyLabel = Bundle.getStringTrimmed(
            "org.netbeans.core.ui.options.general.Bundle", "CTL_Use_HTTP_Proxy");
    new JRadioButtonOperator(optionsOper, hTTPProxyLabel).push();
    // "HTTP Proxy:"
    String proxyHostLabel = Bundle.getStringTrimmed(
            "org.netbeans.core.ui.options.general.Bundle", "CTL_Proxy_Host");
    JLabelOperator jloHost = new JLabelOperator(optionsOper, proxyHostLabel);
    new JTextFieldOperator((JTextField) jloHost.getLabelFor()).setText("emea-proxy.uk.oracle.com"); // NOI18N
    // "Port:"
    String proxyPortLabel = Bundle.getStringTrimmed(
            "org.netbeans.core.ui.options.general.Bundle", "CTL_Proxy_Port");
    JLabelOperator jloPort = new JLabelOperator(optionsOper, proxyPortLabel);
    new JTextFieldOperator((JTextField) jloPort.getLabelFor()).setText("80"); // NOI18N
    optionsOper.ok();
}
 
Example 14
Project: jdk8u-jdk   File: Test6505027.java   View source code 6 votes vote down vote up
public Test6505027(JFrame main) {
    Container container = main;
    if (INTERNAL) {
        JInternalFrame frame = new JInternalFrame();
        frame.setBounds(OFFSET, OFFSET, WIDTH, HEIGHT);
        frame.setVisible(true);

        JDesktopPane desktop = new JDesktopPane();
        desktop.add(frame, new Integer(1));

        container.add(desktop);
        container = frame;
    }
    if (TERMINATE) {
        this.table.putClientProperty(KEY, Boolean.TRUE);
    }
    TableColumn column = this.table.getColumn(COLUMNS[1]);
    column.setCellEditor(new DefaultCellEditor(new JComboBox(ITEMS)));

    container.add(BorderLayout.NORTH, new JTextField());
    container.add(BorderLayout.CENTER, new JScrollPane(this.table));
}
 
Example 15
Project: incubator-netbeans   File: GenericToolbar.java   View source code 6 votes vote down vote up
public Dimension getPreferredSize() {
    Dimension dim = super.getPreferredSize();
    if (PREFERRED_HEIGHT == -1) {
        GenericToolbar tb = new GenericToolbar();
        tb.setBorder(getBorder());
        tb.setBorderPainted(isBorderPainted());
        tb.setRollover(isRollover());
        tb.setFloatable(isFloatable());
        Icon icon = Icons.getIcon(GeneralIcons.SAVE);
        tb.add(new JButton("Button", icon)); // NOI18N
        tb.add(new JToggleButton("Button", icon)); // NOI18N
        tb.add(new JTextField("Text")); // NOI18N
        JComboBox c = new JComboBox();
        c.setEditor(new BasicComboBoxEditor());
        c.setRenderer(new BasicComboBoxRenderer());
        tb.add(c);
        tb.addSeparator();
        PREFERRED_HEIGHT = tb.getSuperPreferredSize().height;
    }
    dim.height = getParent() instanceof JToolBar ? 1 :
                 Math.max(dim.height, PREFERRED_HEIGHT);
    return dim;
}
 
Example 16
Project: openjdk-jdk10   File: DefaultButtonModelCrashTest.java   View source code 6 votes vote down vote up
private void go() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        ButtonModel model = new DefaultButtonModel();

        JCheckBox check = new JCheckBox("a bit broken");
        check.setModel(model);
        panel = new JPanel(new BorderLayout());
        panel.add(new JTextField("Press Tab (twice?)"), BorderLayout.NORTH);
        panel.add(check);
        contentPane.add(panel);
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
 
Example 17
Project: xdman   File: ConfigDialog.java   View source code 5 votes vote down vote up
Credential getCredential(String shost, String suser, String spass) {
	JTextField host = new JTextField(shost);
	JTextField user = new JTextField(suser);
	JPasswordField pass = new JPasswordField(spass);
	Object[] obj = new Object[6];
	obj[0] = getString("HOST");
	obj[1] = host;
	obj[2] = getString("USER_NAME");
	obj[3] = user;
	obj[4] = getString("PASSWORD");
	obj[5] = pass;

	while (JOptionPane.showOptionDialog(null, obj, getString("LBL_CR"),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
			null, null, null) == JOptionPane.OK_OPTION) {
		if (host.getText() == null || host.getText().length() < 1) {
			JOptionPane.showMessageDialog(null, getString("LBL_HOST"));
			continue;
		}
		if (user.getText() == null || user.getText().length() < 1) {
			JOptionPane.showMessageDialog(null, getString("LBL_USER"));
			continue;
		}

		Credential c = new Credential();
		c.host = host.getText();
		c.user = user.getText();
		c.pass = pass.getPassword().length > 0 ? new String(pass
				.getPassword()) : null;
		return c;
	}
	return null;
}
 
Example 18
Project: incubator-netbeans   File: GUIRegistrationPanel.java   View source code 5 votes vote down vote up
private void setEditable(final JComboBox combo) {
    combo.setEditable(true);
    if (combo.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField) combo.getEditor().getEditorComponent();
        // XXX check if there are not multiple (--> redundant) listeners
        txt.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
            public void insertUpdate(DocumentEvent e) {
                if (!UIUtil.isWaitModel(combo.getModel())) {
                    checkValidity();
                }
            }
        });
    }
}
 
Example 19
Project: Community_Tieba-Data-Analyzer   File: SetupDisplay.java   View source code 5 votes vote down vote up
private void generateSetupFile(JTextField t1, JTextField t2) throws UnknownHostException{
	if((t1.getText() != null) && (t2.getText() != null)){
		
		String str = createClientInfoString(t1, t2);
		
		byte[] ns = str.getBytes();
		byte[] ret = new byte[ns.length];
		for(int i = 0; i < ns.length; i++){
			ret[i] = (byte) (ns[i] + 4);
		}
		str = new String(ret);
		
		//String to File
		byte[] tempCharRead = str.getBytes();
		try{
			FileOutputStream write = new FileOutputStream(Config.getIns().getProgLocation() + Config.PATH_SEP + "emailMe.cstudio");
			for(int i = 0; i < tempCharRead.length; i ++){
				write.write((tempCharRead[i]));
			}
			write.close();	
		}catch(IOException e){
			e.printStackTrace();
			Util.errMessage(e.getMessage());
		}
	}else{
		t1.setText("You have to fillout this section!");
		t2.setText("You have to fillout this section!");
	}
}
 
Example 20
Project: marathonv5   File: JListXTest.java   View source code 5 votes vote down vote up
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
                @Override public void eventDispatched(AWTEvent event) {
                }
            }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            Object[] listData = new Object[30];
            for (int i = 1; i <= listData.length; i++) {
                if (i == 25) {
                    listData[i - 1] = "List Item - '" + i + "'";
                } else {
                    listData[i - 1] = "List Item - " + i;
                }
            }
            list = new JList(listData);
            list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            list.setName("list-1");
            list.setDragEnabled(true);
            JPanel p = new JPanel(new BorderLayout());
            p.add(new JScrollPane(list), BorderLayout.NORTH);
            textfield = new JTextField(80);
            textfield.setName("text-field");
            textfield.setDropMode(DropMode.USE_SELECTION);
            p.add(textfield, BorderLayout.SOUTH);
            frame.getContentPane().add(p);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
            list.requestFocusInWindow();
        }
    });
}
 
Example 21
Project: TrabalhoCrisParte2   File: Generica.java   View source code 5 votes vote down vote up
public static void Limpar_Campos_Tela(JPanel tela, Boolean bloquear_Componentes){
    for (Component componente : tela.getComponents()) {
        if (componente instanceof JPanel) {
            Limpar_Campos_Tela((JPanel) componente,bloquear_Componentes);
        }
        if(componente instanceof JScrollPane){
            JViewport viewport = ((JScrollPane)componente).getViewport(); 
            JTable table = (JTable)viewport.getView();
            
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.getDataVector().removeAllElements();
            model.fireTableDataChanged();
            
            table.setEnabled(!bloquear_Componentes);
        }
        if (componente instanceof JTextField) {
            ((JTextField) componente).setText("");
            ((JTextField) componente).setEnabled(!bloquear_Componentes);
        }
        if (componente instanceof JFormattedTextField) {
            ((JFormattedTextField) componente).setText("");
            ((JFormattedTextField) componente).setEnabled(!bloquear_Componentes);
        }
        if(componente instanceof JButton){
            ((JButton) componente).setEnabled(!bloquear_Componentes);
        }
    }
}
 
Example 22
Project: OpenDA   File: Query.java   View source code 5 votes vote down vote up
public QueryFileChooser(
        String name,
        String defaultName,
        URI base,
        File startingDirectory,
        Color background) {
    super(BoxLayout.X_AXIS);
    _base = base;
    _startingDirectory = startingDirectory;
    _entryBox = new JTextField(defaultName, _width);
    _entryBox.setBackground(background);
    JButton button = new JButton("Browse");
    button.addActionListener(this);
    add(_entryBox);
    add(button);
    // Add the listener last so that there is no notification
    // of the first value.
    _entryBox.addActionListener(new QueryActionListener(name));

    // Add a listener for loss of focus.  When the entry gains
    // and then loses focus, listeners are notified of an update,
    // but only if the value has changed since the last notification.
    // FIXME: Unfortunately, Java calls this listener some random
    // time after the window has been closed.  It is not even a
    // a queued event when the window is closed.  Thus, we have
    // a subtle bug where if you enter a value in a line, do not
    // hit return, and then click on the X to close the window,
    // the value is restored to the original, and then sometime
    // later, the focus is lost and the entered value becomes
    // the value of the parameter.  I don't know of any workaround.
    _entryBox.addFocusListener(new QueryFocusListener(name));

    _name = name;
}
 
Example 23
Project: JavaGraph   File: FreshNameDialog.java   View source code 5 votes vote down vote up
/**
 * Lazily creates and returns the option pane that is to form the content of
 * the dialog.
 */
private JOptionPane getOptionPane() {
    if (this.optionPane == null) {
        JTextField nameField = getNameField();
        this.optionPane = new JOptionPane(new Object[] {nameField, getErrorLabel()},
            JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null,
            new Object[] {getOkButton(), getCancelButton()});
    }
    return this.optionPane;
}
 
Example 24
Project: JavaGraph   File: FindReplaceDialog.java   View source code 5 votes vote down vote up
/** Returns the text field in which the user is to enter his input. */
private JTextField getNewField() {
    if (this.newField == null) {
        this.newField = new JTextField();
        this.newField.getDocument().addDocumentListener(new OverlapListener());
        this.newField.addActionListener(getNameFieldListener());
    }
    return this.newField;
}
 
Example 25
Project: jmt   File: DefaultsEditor.java   View source code 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	// Unregister all stringListener to avoid strange random things
	JTextField tmp;
	while (!registeredStringListener.isEmpty()) {
		tmp = registeredStringListener.remove(0);
		tmp.removeFocusListener(stringListener);
		tmp.removeKeyListener(stringListener);
	}
	Defaults.revertToDefaults();
	DefaultsEditor.this.getContentPane().removeAll();
	DefaultsEditor.this.initComponents(target);
	DefaultsEditor.this.show();
}
 
Example 26
Project: DocIT   File: EmployeeView.java   View source code 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param model
 */
public EmployeeView(Model model) {
	super(model);

	address = new JTextField();

	createView();
}
 
Example 27
Project: MaxSim   File: CFGOptionsPanel.java   View source code 5 votes vote down vote up
public FontChooser(String propertyName) {
    this.propertyName = propertyName;
    preview = new JTextField("");
    preview.setEditable(false);
    button = new JButton("...");
    button.setMargin(new Insets(0, 0, 0, 0));
    button.addActionListener(this);
}
 
Example 28
Project: incubator-netbeans   File: NameAndLocationPanel.java   View source code 5 votes vote down vote up
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final NewLoaderIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            if (checkValidity()) {
                updateData();
            }
        }
    };
    txtPrefix.getDocument().addDocumentListener(dListener);
    txtIcon.getDocument().addDocumentListener(dListener);
    
    if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
        txt.getDocument().addDocumentListener(dListener);
    }
    
    if (data.canUseMultiview()) {
        useMultiView.setEnabled(true);
        useMultiView.setSelected(true);
    } else {
        useMultiView.setEnabled(false);
        useMultiView.setSelected(false);
    }
}
 
Example 29
Project: JavaGraph   File: FreshNameDialog.java   View source code 5 votes vote down vote up
/** Returns the text field in which the user is to enter his input. */
private JTextField getNameField() {
    if (this.nameField == null) {
        this.nameField = new JTextField(30);
        this.nameField.getDocument()
            .addDocumentListener(new OverlapListener());
        this.nameField.addActionListener(getNameFieldListener());
    }
    return this.nameField;
}
 
Example 30
Project: fuck_zookeeper   File: ZooInspectorConnectionPropertiesDialog.java   View source code 5 votes vote down vote up
private Properties getConnectionProps() {
    Properties connectionProps = new Properties();
    for (Entry<String, JComponent> entry : components.entrySet()) {
        String value = null;
        JComponent component = entry.getValue();
        if (component instanceof JTextField) {
            value = ((JTextField) component).getText();
        } else if (component instanceof JComboBox) {
            value = ((JComboBox) component).getSelectedItem().toString();
        }
        connectionProps.put(entry.getKey(), value);
    }
    return connectionProps;
}
 
Example 31
Project: BassNES   File: AddBreakPoint.java   View source code 5 votes vote down vote up
/**
 * Create the frame.
 */
public AddBreakPoint(DefaultListModel<BreakPoint> breakpoint) {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 450, 300);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JComboBox<Object> comboBox = new JComboBox<Object>();
	comboBox.setModel(new DefaultComboBoxModel<Object>(Variable.values()));
	comboBox.setBounds(10, 115, 141, 20);
	contentPane.add(comboBox);
	
	textField = new JTextField();
	textField.setBounds(226, 115, 141, 20);
	contentPane.add(textField);
	textField.setColumns(10);
	
	JButton btnAddBreakpoint = new JButton("Add BreakPoint");
	btnAddBreakpoint.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			Object val = null;
			String text = textField.getText().toLowerCase();
			if(text.equals("true"))
				val = true;
			else if(text.equals("false"))
				val = false;
			else{
				val = Integer.parseInt(text, 16);
			}
			breakpoint.addElement(new BreakPoint((Variable) comboBox.getSelectedItem(),val));
			setVisible(false);
			dispose();
		}
	});
	btnAddBreakpoint.setBounds(138, 191, 141, 23);
	contentPane.add(btnAddBreakpoint);
}
 
Example 32
Project: rapidminer   File: OAuthValueCellEditor.java   View source code 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	if (value != null) {
		((JTextField) editorComponent).setText(String.valueOf(value));
	}
	return container;
}
 
Example 33
Project: openjdk-jdk10   File: JTextFieldOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JTextField.getScrollOffset()} through queue
 */
public int getScrollOffset() {
    return (runMapping(new MapIntegerAction("getScrollOffset") {
        @Override
        public int map() {
            return ((JTextField) getSource()).getScrollOffset();
        }
    }));
}
 
Example 34
Project: incubator-netbeans   File: PropertyPanel.java   View source code 5 votes vote down vote up
private void keyBundleTextChanged() {
    if (internalTextChange == 0) {
        String key = ((JTextField) keyBundleCombo.getEditor().getEditorComponent()).getText();

        if (!key.equals(i18nString.getKey())) {
            i18nString.setKey(key);
            firePropertyChange(PROP_STRING, null, null);
        }
    }
}
 
Example 35
Project: Dahlem_SER316   File: LoginDialogTest.java   View source code 5 votes vote down vote up
/**
 * Tests to ensure account is not generated when it shouldn't be. For
 * example: Differing passwords or account already exists. This does not
 * validate the account creation process details.
 */
@Test
public void testAccountCreation() {
	JTextField usernameField = dlg.getUsernameField();
	JPasswordField passPrimary = dlg.getPasswordFieldPrimary();
	JPasswordField passVerify = dlg.getPasswordFieldVerify();
	JButton button = dlg.getBtnCreateNewAccount();

	// Test account created no password
	usernameField.setText("HeyTestGuy1");
	passPrimary.setText("");
	passVerify.setText("");
	button.doClick();
	assertTrue(AccountManager.userExists("HeyTestGuy1"));

	// Test account NOT created - mismatched password
	usernameField.setText("HeyTestGuy2");
	passPrimary.setText("ardvark");
	passVerify.setText("");
	button.doClick();
	assertFalse(AccountManager.userExists("HeyTestGuy2"));

	//Test all correct values.
	usernameField.setText("HeyTestGuy3");
	passPrimary.setText("ardvark");
	passVerify.setText("ardvark");
	button.doClick();
	assertTrue(AccountManager.userExists("HeyTestGuy3"));
			
	assertTrue(AccountManager.removeUserAccount("HeyTestGuy1"));
	assertTrue(AccountManager.removeUserAccount("HeyTestGuy3"));
}
 
Example 36
Project: COE1186   File: ScheduleJTable.java   View source code 5 votes vote down vote up
private void addTextAreaToColumn() {
	//Create the ComboBox and add the line blocks to it
	JTextField textArea = new JTextField();
	
	//Add a listener to the ComboBox, add stop when state changes
	textArea.addKeyListener(new KeyAdapter() {
		@Override
		public void keyReleased(KeyEvent e) {
			int row = table.getSelectedRow();
			String timeToDwell = textArea.getText();
			
			if(SimTime.isValid(timeToDwell) && row>=0) {
				schedule.addStop(row, new SimTime(timeToDwell));
				fireScheduleChanged();
			}
		}
	});

	//Put the TextArea into the JTable cell
	DefaultCellEditor textAreaEditor = new DefaultCellEditor(textArea);
	this.getColumnModel().getColumn(1).setCellEditor(textAreaEditor);
	
	//Add a tooltip
    DefaultTableCellRenderer textAreaRenderer = new DefaultTableCellRenderer();
    textAreaRenderer.setToolTipText("Type time to spend at the station");
    this.getColumnModel().getColumn(1).setCellRenderer(textAreaRenderer);
}
 
Example 37
Project: Equella   File: OAIPlugin.java   View source code 5 votes vote down vote up
@Override
public void initGUI()
{
	serverField = new JTextField();

	JPanel setsPanel = new JPanel();
	aSetField = new JComboBox<>();
	aSetField.setEditable(true);
	getSetsButton = new JButton(getString("oaiplugin.getsets"));
	getSetsButton.addActionListener(this);

	setupPanel(setsPanel, aSetField, getSetsButton);

	JPanel metaPanel = new JPanel();
	metaField = new JComboBox<>();
	metaField.setEditable(true);
	getMetaButton = new JButton(getString("oaiplugin.getmetas"));
	getMetaButton.addActionListener(this);

	setupPanel(metaPanel, metaField, getMetaButton);

	panel.addComponent(new JLabel(getString("oaiplugin.settings")));
	panel.addNameAndComponent(getString("oaiplugin.server"), serverField);
	panel.addNameAndComponent(getString("oaiplugin.format"), metaPanel);
	panel.addNameAndComponent(getString("oaiplugin.aset"), setsPanel);

}
 
Example 38
Project: incubator-netbeans   File: BaseTable.java   View source code 5 votes vote down vote up
public void focusGained(FocusEvent e) {
    //it will be the first focus gained event, so go select
    //whatever matches the first character
    processSearchText(((JTextField) e.getSource()).getText());

    JRootPane root = getRootPane();

    if (root != null) { // #57417 NPE
        root.getLayeredPane().repaint();
    }
    setCaretPosition(getText().length());
}
 
Example 39
Project: ohjelmistotuotanto2017   File: Tapahtumankuuntelija.java   View source code 5 votes vote down vote up
public Tapahtumankuuntelija(JButton plus, JButton miinus, JButton nollaa, JButton undo, JTextField tuloskentta, JTextField syotekentta) {
    this.plus = plus;
    this.miinus = miinus;
    this.nollaa = nollaa;
    this.undo = undo;
    this.tuloskentta = tuloskentta;
    this.syotekentta = syotekentta;
    this.sovellus = new Sovelluslogiikka();
}
 
Example 40
Project: AgentWorkbench   File: ClassSelectionPanel.java   View source code 5 votes vote down vote up
/**
 * This method checks if a given class reference is valid.
 *
 * @param jTextField the j text field
 * @param jButton the j button
 * @return true, if is valid class
 */
private boolean isValidClass(JTextField jTextField) {
	
	String className = jTextField.getText().trim();
	if (this.class2Search4DefaultValue==null && className.equals("")) {
		// --- If no default value is configured, an empty text field is allowed -----
		this.getJButtonCheckClass().setIcon(this.imageGreen);
		this.setValidClass(true);
		return true;
	} else if (isAllowNull()==true && className.equals("")) {
		this.getJButtonCheckClass().setIcon(this.imageGreen);
		this.setValidClass(true);
		return true;
		
	} else {
		// --- If a default value is configured, there should be a valid class ------ 
		try {
			@SuppressWarnings("unused")
			Class<?> clazz = BaseClassLoadServiceUtility.forName(className);
			this.getJButtonCheckClass().setIcon(this.imageGreen);
			this.setValidClass(true);
			return true;
			
		} catch (ClassNotFoundException e) {
			//e.printStackTrace();
			this.getJButtonCheckClass().setIcon(this.imageRed);
		}
	}
	this.setValidClass(false);
	return false;
}