codice:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
class dati extends JInternalFrame implements ActionListener{
private JTextField nome,cognome,eta,ind;
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
int ab=0,fig=0;
JLabel indirizzo,name,cogname,age,figo,cassa,sfondoF;
JButton salva=new JButton("Salva impostazioni");
Image sfondo = Toolkit.getDefaultToolkit().createImage("immagini/sfondi/dati.gif");
dati (String title){
super ("I tuoi dati"+(++openFrameCount),true,true,true,true);
init();
}
public void init(){
setTitle("I tuoi dati");
setSize(600,250);
setLocation(100,350);
getContentPane().setLayout(null);
salva.addActionListener(this);
getContentPane().add(salva);
salva.setBounds(85,180,200,15);
salva.setBorder(null);
//JLabel
indirizzo=new JLabel("Indirizzo");
name=new JLabel("Nome");
cogname=new JLabel("Cognome");
cassa=new JLabel("Cassa: "+moto.soldi);
figo=new JLabel("Figosità");
age=new JLabel("Età");
getContentPane().add(name);
getContentPane().add(cogname);
getContentPane().add(indirizzo);
getContentPane().add(age);
getContentPane().add(cassa);
getContentPane().add(figo);
name.setBounds(10,20,70,10);
cogname.setBounds(10,60,70,10);
indirizzo.setBounds(10,100,70,10);
age.setBounds(10,140,70,10);
cassa.setBounds(400,100,100,10);
//textField
nome=new JTextField(15);
cognome=new JTextField(15);
eta=new JTextField(2);
ind=new JTextField(30);
getContentPane().add(ind);
getContentPane().add(nome);
getContentPane().add(cognome);
getContentPane().add(eta);
ind.setBounds(85,140,175,20);
nome.setBounds(85,20,100,20);
cognome.setBounds(85,60,100,20);
eta.setBounds(85,100,25,20);
nome.setText(moto.a);
cognome.setText(moto.b);
eta.setText(moto.c);
ind.setText(moto.d);
repaint();
}
public void paintComponent(Graphics g){
g.drawImage(sfondo,0,0,this);
}
public void actionPerformed(ActionEvent ae){
if (ae.getSource()==salva){moto.a=nome.getText();
moto.b=cognome.getText();moto.c=eta.getText();moto.d=ind.getText(); init();};
repaint();
}
}
Se azikè usare piantConponent uso paint mi si vusualizza l'immagine ma ovviamente nn i conponenti!