Gostaria de colocar uma imagem que está no meu projeto, porem estou com dificuldade de colocá-lo como final:
package Pacote;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
public class Tela extends JFrame implements ActionListener{
Container c = getContentPane();
JPanel login = new JPanel();
JLabel ll, ls;
JTextField tl;
JPasswordField ts;
JButton ok;
private JPanel panel;
public Tela(){
super ("Clinica Odontológica - IDENTIFIQUE-SE");
getContentPane().setBackground(new Color(240, 240, 240));
setIconImage(Toolkit.getDefaultToolkit().getImage(TelaLogin.class.getResource("/Clinica/imagens/logomarca.png")));
setSize(981, 623);
setVisible(true);
setResizable(false);
setLocation(10, 30);
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.setLayout(new BorderLayout());
final ImageIcon bg = new ImageIcon(TelaLogin.class.getResource("/Clinica/imagens/bg_telalogin.png"));
panel = new JPanel();
getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(new BorderLayout(0, 0));
login = new JPanel(){
Image image = bg.getImage();
{
setOpaque(false);
}
public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);
super.paint(g);
}
};
panel.add(login);
// login.setBorder(BorderFactory.createTitledBorder("LOGIN"));
login.add(ll = new JLabel("Login: "));
login.add(tl = new JTextField());
tl.setColumns(10);
login.add(ls = new JLabel("\nSenha: "));
ls.setHorizontalAlignment(SwingConstants.TRAILING);
login.add(ts = new JPasswordField());
login.add(ok = new JButton("ok"));
GroupLayout gl_login = new GroupLayout(login);
gl_login.setHorizontalGroup(
gl_login.createParallelGroup(Alignment.LEADING)
.addGroup(gl_login.createSequentialGroup()
.addGap(284)
.addComponent(ll)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(tl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(76)
.addComponent(ls)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(ts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(ok)
.addContainerGap(317, Short.MAX_VALUE))
);
gl_login.setVerticalGroup(
gl_login.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_login.createSequentialGroup()
.addContainerGap(343, Short.MAX_VALUE)
.addGroup(gl_login.createParallelGroup(Alignment.BASELINE)
.addComponent(tl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(ll)
.addComponent(ls)
.addComponent(ts, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(ok))
.addGap(229))
);
login.setLayout(gl_login);
ts.setColumns(10);
tl.setColumns(10);
}
public void actionPerformed(ActionEvent e) {
}
public static void main(String[] args) {
JFrame Janela= new Tela();
Janela.show();
WindowListener x=new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
};
Janela.addWindowListener(x);
}
}