JButton with action and icon but no text
Hi, I'm doing the bog standard text editor thing and want to make a toolbar that uses actions that I have already defined in the menus. The menus have actions, such as:
cutAction = new DefaultEditorKit.CutAction();
and I'm using the Sun code to create an imageicon for the button, but the button keeps on having the text from the action on it as well, which I don't want. My button code is:
ImageIcon copyIcon = createImageIcon ("images/copy.gif", "Copy"); // createImageIcon is a method 'borrowed' from Sun
copyButton = new JButton("");
copyButton.setToolTipText("Copy selected text");
Any ideas on how to prevent the text 'Copy_to_clipboard' appearing on the button with the imageicon?
I am not too sure if this will solve your problem, but I have two ideas:
Firstly, you are sure that the text isnīt part of the image? silly question but must be asked.
Secondly, try moving your setText("") down a few lines, just before toolBar.add() method. or try use a different constructor: ImageIcon copyIcon = createImageIcon ("images/copy.gif");
I am not sure if this will solve your problem but I canīt see where else the problem is coming from.
Does the text still show if there is no image on the button?
I think, therefore I am....... I think.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center