Aí…eu coloquei o método paint depois, pra não fazer um new MediaTracker…
tipo, o que ta falatando agora é fazer com que ela abra na outra janela, pq eu testei aki, e ela abre na janela principal, só naum abre na outra…
deixei assim depois do tk.
[code]public class JnPrincipal extends JFrame implements ActionListener {
//ConectBanco bd = new ConectBanco();
PicturePanel pp = new PicturePanel();
private JTabbedPane tabs;
Image imfoto;
private JButton btAnt;
private JButton btProx;
private JButton btAbrir;
private Toolkit tk = Toolkit.getDefaultToolkit();
private FileDialog fd = new FileDialog(this, "Selecione a Imagem: ");
private JLabel lbcaminho = new JLabel();
private JLabel lbimagem = new JLabel();
public JnPrincipal(){
super("Janela Principal");
// this.setResizable(false);
//ABA 1
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
this.setLocation(new Point((screenSize.width - frameSize.width) / 5,
(screenSize.height - frameSize.width) / 5));
tabs = new JTabbedPane();
JPanel panel = new JPanel();
ImageIcon icon = new ImageIcon("diam-verm.gif");
JLabel lbnome = new JLabel("Nome: ");
JTextField tfnome = new JTextField(20);
JLabel lbcidade = new JLabel("Cidade: ");
JTextField tfcidade = new JTextField(30);
JLabel lbcontato = new JLabel("Contato: ");
JTextField tfcontato = new JTextField(30);
JLabel lbrg = new JLabel("RG: ");
JTextField tfrg = new JTextField(10);
JLabel lbfone = new JLabel("Telefone: ");
JTextField tffone = new JTextField(11);
JLabel lbemail = new JLabel("E-mail: ");
JTextField tfemail = new JTextField(30);
JLabel lbend = new JLabel("Endereço: ");
JTextField tfend = new JTextField(30);
JLabel lbfoto = new JLabel("Foto: ");
//ImageIcon iifoto = new ImageIcon(imfoto);
//lbcaminho = new JLabel(iifoto);
/*
response.setContentType("image/png");
OutputStream os = response.getOutputStream();
ImageIO.write(buffer, "png", os);
os.close();
*/
//====ADD===
panel.add(lbnome);
panel.add(tfnome);
panel.add(lbcidade);
panel.add(tfcidade);
panel.add(lbcontato);
panel.add(tfcontato);
panel.add(lbrg);
panel.add(tfrg);
panel.add(lbfone);
panel.add(tffone);
panel.add(lbend);
panel.add(tfend);
panel.add(lbemail);
panel.add(tfemail);
panel.add(lbfoto);
panel.add(btAbrir = new JButton("Abrir"),"West");
panel.add(lbcaminho);
panel.checkImage(imfoto, 150, 150, this);
btAbrir.addActionListener(this);
//addWindowListener(new CloseAndExit());
//ta.setLineWrap(true); ta.setWrapStyleWord(true);
tabs.addTab("Entrada", new ImageIcon("diam-azul.gif"), panel);
//ABA 2
JPanel panel2 = new JPanel();
panel2.setBackground(Color.white);
tabs.addTab("Saída", new ImageIcon("diam-lilas.gif"), panel2);
//ABA 3
panel = new JPanel();
panel.add(new JLabel("Teste"));
tabs.addTab("Relatorio", new ImageIcon("diam-azul.gif"), panel);
//ABA 4
JPanel panel4 = new JPanel();
tabs.addTab("Localizar", new ImageIcon("diam-verde.gif"), panel4);
getContentPane().add(tabs, "Center");
//Painel de COntrole
JPanel p1 = new JPanel(), p2 = new JPanel(new GridLayout(1,1,1,1));
p2.add(btAnt = new JButton("Anterior"));
p2.add(btProx = new JButton("Próximo"));
p1.add(p2);
getContentPane().add(p1, "North");
btAnt.addActionListener(this);
btProx.addActionListener(this);
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
// PicturePanel pp = new PicturePanel();
fd.show();
if(fd.getFile()!= null){
lbcaminho.setText(fd.getDirectory()+fd.getFile());
imfoto = tk.getImage(lbcaminho.getText());}
}
public void paint(Graphics g){
JnPrincipal princ = new JnPrincipal();
super.paint(g);
if(imfoto != null){
Dimension apl = getSize();
imfoto = imfoto.getScaledInstance(
this.getWidth(), this.getHeight(), 10);
MediaTracker media = new MediaTracker(this);
media.addImage(imfoto, 0);
try {
media.waitForID(0);
} catch (InterruptedException ie) {
}
new JnFoto().show();
}
}
public static void main(String[] args){
new JnPrincipal().show();
}
// TODO Auto-generated method stub
}[/code]
Isso aí é todo o código da Janela Principal…
se eu colocar essas duas linhas a imagem aparece nela:
g.drawImage(imfoto, 0, 280, 150, 150, this);
this.imfoto = princ.imfoto;
aí quando eu tiro, não aparece em nenhuma das duas…hehe
éee…só falta msm, add a imagem na outra janela,pq chamar já chamou neh!!!