Como chamar o Internal frame de outra classe?

0 respostas
ryouta

na classe 1 se encontra o frame e o desktoppanel e na classe 2 se encontra o internalframe

como chamo o internalframe da classe 2 ?

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


public class classe1 extends JFrame implements ActionListener {


		
	JButton  b10;
	JDesktopPane desktop;
	
		public classe1() {
           
			
			// Configuração do Frame
			super("Login Para o Sistema");
			
			int w = this.getToolkit().getDefaultToolkit().getScreenSize().width;
			int h = this.getToolkit().getDefaultToolkit().getScreenSize().height;
			int z = 2;
			int x = (w - 700) / z;
			int y = (h - 480)/ z;
			this.setSize(700, 480);
			this.setLocation(x,y);
			this.setResizable(false);
			
	              b10 = new JButton("aqui");
		        b10.setBounds(0,0,50,50);
		      b10.addActionListener(this);
		
		
        
	     String local = System.getProperty("user.dir");  
		
		JLabel img = new JLabel(new ImageIcon(local+"\\src\\naveRyouta3.jpg"));
		img.setLocation(new Point(0,0));
		img.setSize(700,480);
	    img.setVisible(true);
		
		
	    
	    desktop = new JDesktopPane();
	    desktop.add(b10);
	    desktop.add(img);
	    this.add(desktop);

	    
	    
	    this.setVisible(true);
	 
			
		}

		public static void main(String[] args) {// main
			new classe1();
		}

		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource()== b10){
				
								
			}

	}
}
import java.awt.Component;

import javax.swing.ImageIcon;  
    import javax.swing.JDesktopPane;  
    import javax.swing.JInternalFrame;  
import javax.swing.JLabel;  
      
      
      
    public class classe2 {  
      
      classe1 class1;

		public classe2(){
        
             
            JInternalFrame frame1 = new JInternalFrame("Janela ex 4");  
            frame1.setSize(250,250);  
            frame1.setLocation(50,50);  
            frame1.setVisible(true);  
              
            this.class1 = class1;//pega a class1 e joga no seu objeto class1 dessa classe  
            this.class1.getContentPane().add(frame1);//adiciona o iframe no seu class1      
          
          }
          
          
    }
Criado 9 de maio de 2011
Respostas 0
Participantes 1