Modify JTextField

132 Views Asked by At

I have an issue with a JTextField in Java. It's works on Linux Ubuntu but not on Mac Os.

I can't modify a JtextFieldValue when I click on it. Impossible to modify JTextField

This is my function to create a popup with the JText Field :

    protected void createPopup(String popUpText, JPanel panelContent,JList<String> jList,JTextField jTextField,String msg){
    if(popup!=null){
        buttons.remove(this.controller.getOK_SAUVEGARDE());
        popup.hide();
    }
    JPanel panelPopup;
    if(msg!=null)
        panelPopup = new JPanel(new GridLayout(3,1));
    else
        panelPopup = new JPanel(new GridLayout(4,1));
    JLabel labelPopup = new JLabel(popUpText);
    panelPopup.add(labelPopup);
    if(jTextField!=null){
        jTextField.setEditable(true);
        textPopup = jTextField;
        buttons.put(this.controller.getOK_SAUVEGARDE(), createButton(this.controller.getOK_SAUVEGARDE()));
        panelPopup.add(textPopup);
        panelPopup.add(buttons.get(this.controller.getOK_SAUVEGARDE()));
    }else if (jList!=null){
        niveauList = jList;
        buttons.put(this.controller.getOK_LOAD(), createButton(this.controller.getOK_LOAD()));
        panelPopup.add(niveauList);
        panelPopup.add(buttons.get(this.controller.getOK_LOAD()));
    }else if(msg != null){
        JLabel gameOverText = new JLabel(msg);
        panelPopup.add(gameOverText);
        panelPopup.add(buttons.get(this.controller.getMENU_BUTTON()));
    }
    if(msg==null){
        buttons.put(this.controller.getQUITTER_POPUP(),createButton(this.controller.getQUITTER_POPUP()));
        panelPopup.add(buttons.get(this.controller.getQUITTER_POPUP()));
    }

    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    popup = popupFactory.getPopup(panelContent, panelPopup,this.controller.getMyFrame().getWidth()/2,this.controller.getMyFrame().getHeight()/4);
    popup.show();
}

This how I call it :

createPopup("Nom du niveau ",panelRight,null,new JTextField("Nom de la sauvegarde",14),null);

Thanks for your help.

0

There are 0 best solutions below