ti ringrazio per la celere risposta.
avevo già provato con una icon ma con sacrso succecco..non riuscivo a visualizzare nulla...
edit: ci sono riuscita!
ma avrei sempre il problema di spostare l'immagine in alto in modo da inserire il testo in basso
posto il nuovo codice
codice:
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.setBounds(36, 10, 90, 74);
newButton.setText("");
// newButton.add(getNewIcon());
} catch (Exception e) {
e.printStackTrace();
}
}
return newButton;
}
}
grazie mille