galera como poderia fazer apos vc clicar botão irá gerar um monte de tela de uma só vez
segue o codigo
/**
*Esta classe Cria uma tela de interação com o usuário
* @author vcarretero
* @since 01/10/2010
*/
public class Tela extends javax.swing.JFrame {
MudarPosicao t1;
/** Creates new form Tela */
public Tela() {
initComponents();
setTitle("Mudar Tela de Posição");
setLocation(400,300);
setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btBotao = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
btBotao.setText("Mudar Tela de Posição");
btBotao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btBotaoActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(121, 121, 121)
.addComponent(btBotao)
.addContainerGap(138, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(142, Short.MAX_VALUE)
.addComponent(btBotao)
.addGap(135, 135, 135))
);
pack();
}// </editor-fold>
/*Quando clicado no botão, a tela muda de posição*/
private void btBotaoActionPerformed(java.awt.event.ActionEvent evt) {
t1 = new MudarPosicao();
t1.start();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Tela().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btBotao;
// End of variables declaration
public void setLocation(int x, int y, int w) {
}
}
import javax.swing.JOptionPane;
/**
* Esta classe executa uma Thread, criando uma nova janela visual
* e localizando aleatóriamente, a mesma, na tela
* @author vcaretero
* @since 01/10/2010
*/
public class MudarPosicao extends Thread {
int x,y,w;
public MudarPosicao(){
}
public void run(){
try{
/*Criando um objeto do tipo tela*/
Tela tela = new Tela();
/*Gerando um numero aleatório para mudar aleatóriamente a tela de local*/
x = (int)(Math.random()*500) ;
y = (int)(Math.random()*500) ;
w =(int) (Math.random()*600);
/*Mudando a tela de posição a cada vez que o botão é acionado pelo usuario*/
tela.setLocation(x,y,w);
}catch(Exception e){
JOptionPane.showMessageDialog(null,"Ferrou");
}//fim da catch
}
}
/**
* Esta é a classe principal onde cria o objeto Tela
* @author vcarretero
* @since 01/10/2010
*/
public class Main {
public static void main (String[] args){
Tela tela = new Tela();
}//fim da void main
}//fim da