我在Java中遇到了JTextField的问题。 它适用于Linux Ubuntu,但不适用于Mac Os。
单击它时,我无法修改JtextFieldValue。
这是我使用JText字段创建弹出窗口的函数:
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();
}
我如何称呼它:
createPopup("Nom du niveau ",panelRight,null,new JTextField("Nom de la sauvegarde",14),null);
感谢您的帮助。