This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Ok, it gives a workaround for Jemmy: > public String getApproveButtonText() { > if(approveButtonText==null){ > return getUI().getApproveButtonText(this); > }else{ > return approveButtonText; > } public JButton getApproveButton() { String aText = getApproveButtonText(); if(aText == null) { aText = getUI().getApproveButtonText(this); } if(aText != null) { return((JButton)innerSearcher. findComponent(new ButtonFinder(aText))); } else { throw(new JemmyException("JFileChooser.getApproveButtonText() and " + "JFileChooser.getUI().getApproveButtonText()" + "return null")); } }
I digged into it and it looks like a bug in the swing JFileChooser.getApproveButtonText: ----------------------------- JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(mFrame); System.out.println(chooser.getApproveButtonText()); ----------------------------- prints "null" to stdout. the javadoc for JFileChosser.getApproveButtonText says: "Returns the text used in the ApproveButton in the FileChooserUI. If null, the UI object will determine the button's text. Typically, this would be "Open" or "Save"." What means "If null"? If you look at the source: public String getApproveButtonText() { return approveButtonText; } approveButtonText is defined as instance variable of JFileChooser: private String approveButtonText = null; So I guess this should be something like: public String getApproveButtonText() { if(approveButtonText==null){ return getUI().getApproveButtonText(this); }else{ return approveButtonText; } } // which does not take care of property changes or public String getApproveButtonText() { if(approveButtonText==null){ setApproveButtonText(getUI().getApproveButtonText(this)); }else{ return approveButtonText; } } // which does not take care about changed text in the button This code JFileChooser chooser = new JFileChooser(); System.out.println(chooser.getUI().getApproveButtonText(chooser)); prints the correct approved button text. So another workaround is to use JFileChooser chooser = new JFileChooser(); chooser.setApproveButtonText(chooser.getUI().getApproveButtonText(chooser)); chooser.showOpenDialog(mFrame); to get the approveButtonText be set explicitley
http://developer.java.sun.com/developer/bugParade/bugs/4903648.html
This is the only one I am accepting: "Returns the text used in the ApproveButton in the FileChooserUI. If null, the UI object will determine the button's text. Typically, this would be "Open" or "Save"." Looking for _a_ button is not such a good idea - there could be more (like, within combobox). _Changing_ text I do not like either. Let's do it according to javadoc. Thanks.