dopo la modifica ma non funzia...
ecco il codice:
codice:
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
public class provaimmagine extends javax.swing.JPanel {
private JButton newButton;
/**
* Auto-generated main method to display this JPanel inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().add(new provaimmagine());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public provaimmagine() {
super();
initGUI();
}
private void initGUI() {
try {
this.setPreferredSize(new java.awt.Dimension(796, 94));
this.setMaximumSize(new java.awt.Dimension(796, 94));
this.setMinimumSize(new java.awt.Dimension(796, 94));
this.setLayout(null);
this.setSize(796, 94);
this.setBackground(new java.awt.Color(255, 0, 0));
this.add(getNewButton());
} catch (Exception e) {
e.printStackTrace();
}
}
private JButton getNewButton() {
if (newButton == null) {
try {
ImageIcon icon = (ImageIcon) (new Func()).getImageFromJar(
"newIcon.png", true);
newButton = new JButton(icon);
newButton.setText("testo");
newButton.setVerticalTextPosition(AbstractButton.BOTTOM);
newButton.setBounds(36, 10, 90, 74);
} catch (Exception e) {
e.printStackTrace();
}
}
return newButton;
}
}
solo che ho utilizzato la setText.
ora proverò a seguire il consiglio di andbin e vediamo cosa riesco a tirare fuori.
grazie a tutti!