Gostaria de saber como faço nesse código fonte para em vez de guando eu clicar em pedidos abrir outra pagina eu apenas mudar a página, ao clicar nos botões ele abre outras páginas.
import java.awt.;
import javax.swing.;
public class otica {
JFrame frame,frame2;
JPanel panel,panel2;
JButton bot1,bot2,bot3,bot4;
JLabel jl,jl1,jl2;
JTextField texto;
public static void main(String[] args){
otica gui=new otica();
gui.go();
}
void go(){
frame =new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bot1=new JButton(“Pedidos”);
bot2=new JButton(“Clientes”);
jl=new JLabel(“OTICA”);
panel=new JPanel();
jl1=new JLabel(“OTICA”);
panel.add(bot1);
panel.add(bot2);
frame.getContentPane().add(BorderLayout.WEST,panel);
frame.setSize(800, 600);
frame.setVisible(true);
bot1.addActionListener(new botaop());
bot2.addActionListener(new botaoc());
}
void pedidos(){
frame =new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bot2=new JButton(“Clientes”);
bot3=new JButton(“Adicionar pedido”);
jl=new JLabel(“OTICA”);
panel=new JPanel();
panel.add(bot2);
panel.add(bot3);
frame.getContentPane().add(BorderLayout.WEST,panel);
frame.setSize(800, 600);
frame.setVisible(true);
bot2.addActionListener(new botaoc());
}
void clientes(){
frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bot1=new JButton("Pedidos");
bot4=new JButton("Adicionar cliente");
jl=new JLabel("OTICA");
panel=new JPanel();
panel.add(bot1);
panel.add(bot4);
frame.getContentPane().add(BorderLayout.WEST,panel);
frame.setSize(800, 600);
frame.setVisible(true);
bot4.addActionListener(new addcli());
bot1.addActionListener(new botaop());
}
void addclientes(){
frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
bot1=new JButton("Pedidos");
bot2=new JButton("Clientes");
jl=new JLabel("OTICA");
jl1=new JLabel("Nome do Cliente");
jl2=new JLabel("Rua");
texto=new JTextField(20);
panel=new JPanel();
panel2=new JPanel();
panel.add(bot1);
panel.add(bot2);
panel2.add(jl1);
panel2.add(texto);
panel2.add(jl2);
panel2.add(texto);
frame.getContentPane().add(BorderLayout.WEST,panel);
frame.getContentPane().add(BorderLayout.CENTER,panel2);
frame.setSize(800, 600);
frame.setVisible(true);
bot1.addActionListener(new botaop());
bot2.addActionListener(new botaoc());
}
public class botaop implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
otica o=new otica();
o.pedidos();// TODO Auto-generated method stub
}
}
public class botaoc implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
otica o=new otica();
o.clientes();// TODO Auto-generated method stub
}
}
public class addped implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}
public class addcli implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
otica o=new otica();// TODO Auto-generated method stub
o.clientes();
}
}
}