public void addInstanceNameEditor() { InstanceNameTF = new TextFieldComponent(InstanceName); InstanceNameTF.selectAll(); // InstanceNameTF.setInputVerifier(new AxoObjectInstanceNameVerifier()); InstanceNameTF.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String s = InstanceNameTF.getText(); setInstanceName(s); getParent().remove(InstanceNameTF); } }); InstanceNameTF.addFocusListener( new FocusListener() { @Override public void focusLost(FocusEvent e) { String s = InstanceNameTF.getText(); setInstanceName(s); getParent().remove(InstanceNameTF); patch.repaint(); } @Override public void focusGained(FocusEvent e) {} }); InstanceNameTF.addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent ke) {} @Override public void keyReleased(KeyEvent ke) {} @Override public void keyPressed(KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_ENTER) { String s = InstanceNameTF.getText(); setInstanceName(s); getParent().remove(InstanceNameTF); patch.repaint(); } } }); getParent().add(InstanceNameTF, 0); InstanceNameTF.setLocation(getLocation().x, getLocation().y + InstanceLabel.getLocation().y); InstanceNameTF.setSize(getWidth(), 15); InstanceNameTF.setVisible(true); InstanceNameTF.requestFocus(); // patch.repaint(); }
public void setInstanceName(String InstanceName) { if (this.InstanceName.equals(InstanceName)) { return; } if (patch != null) { AxoObjectInstanceAbstract o1 = patch.GetObjectInstance(InstanceName); if ((o1 != null) && (o1 != this)) { Logger.getLogger(AxoObjectInstanceAbstract.class.getName()) .log(Level.SEVERE, "Object name {0} already exists!", InstanceName); doLayout(); repaint(); return; } } this.InstanceName = InstanceName; if (InstanceLabel != null) { InstanceLabel.setText(InstanceName); } doLayout(); if (getParent() != null) { getParent().repaint(); } }