[quote=ViniGodoy]Você deve tornar seu calculadora frame visível.
Primeiro de tudo, adicione um import para seu pacote. Se ele chamar ferramentas será algo como:
Em seguida, no seu botão, basta fazer:
CalculadoraFrame calculadora = new CalculadoraFrame();
calculadora.setVisible(true);
[/quote]
Cara vou aqui postar o código, um que eu peguei e estou fazendo tendo exemplo atraves dele. Por que ainda está dando erro.
public class Calculadora
{
public static void main(String[] args)
{
JFrame frame = new CalculatorFrame();
frame.show();
}
}
//agora a outra classe
class CalculatorFrame extends JFrame
{
JTextArea t;
public CalculatorFrame()
{
setTitle("Calculadora - Sistema DR");
setSize(435,240);
setResizable(false);//para nao aumentar ou diminuir a tela
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Container contentPane = getContentPane();
contentPane.add(new CalculatorPanel());
// -------------- Menu -----------------------
MenuBar bar = new MenuBar();
Menu calc = new Menu("Calculadora");
MenuItem exit = new MenuItem(" Sair ");
calc.add(exit);
exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
bar.add(calc);
Menu about = new Menu("Sobre");
bar.add(about);
MenuItem about1 = new MenuItem(" Calculadora");
about.add(about1);
about1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, " "
- "\n "
+"\n ");
}
});
bar.add(about);
setMenuBar(bar);
//--------------------------------------------
}
//A ultima classe da calculadora
package ferramentas;
/**
*
-
@author MDA
/
import java.awt.;
import java.awt.event.;
import java.math.;
import javax.swing.*;
class CalculatorPanel extends JPanel implements ActionListener
{
public CalculatorPanel()
{
setLayout(null);
setBackground(Color.green);
//------------ Display -----------------------
display = new JTextField("0");
display.setEditable(false);
add(display);
display.setBounds(10,15,300,25);
//------------ Botões ------------------------
b1 = new Button("0");
b1.setBackground(Color.white);
b1.setForeground(Color.blue);
add(b1);
b1.setBounds(10,155,30,30);
b1.addActionListener(this);
b2 = new Button("1");
b2.setBackground(Color.white);
b2.setForeground(Color.blue);
add(b2);
b2.addActionListener(this);
b2.setBounds(10,120,30,30);
b3 = new Button("4");
b3.setBackground(Color.white);
b3.setForeground(Color.blue);
add(b3);
b3.addActionListener(this);
b3.setBounds(10,85,30,30);
b4 = new Button("7");
b4.setBackground(Color.white);
b4.setForeground(Color.blue);
add(b4);
b4.addActionListener(this);
b4.setBounds(10,50,30,30);
b5 = new Button("+/-");
b5.setBackground(Color.white);
b5.setForeground(Color.blue);
add(b5);
b5.addActionListener(this);
b5.setBounds(45,155,30,30);
b6 = new Button("2");
b6.setBackground(Color.white);
b6.setForeground(Color.blue);
add(b6);
b6.addActionListener(this);
b6.setBounds(45,120,30,30);
b7 = new Button("5");
b7.setBackground(Color.white);
b7.setForeground(Color.blue);
add(b7);
b7.addActionListener(this);
b7.setBounds(45,85,30,30);
b8 = new Button("8");
b8.setBackground(Color.white);
b8.setForeground(Color.blue);
add(b8);
b8.addActionListener(this);
b8.setBounds(45,50,30,30);
b9 = new Button(".");
b9.setBackground(Color.white);
b9.setForeground(Color.blue);
add(b9);
b9.addActionListener(this);
b9.setBounds(80,155,30,30);
b10 = new Button("3");
b10.setBackground(Color.white);
b10.setForeground(Color.blue);
add(b10);
b10.addActionListener(this);
b10.setBounds(80,120,30,30);
b11 = new Button("6");
b11.setBackground(Color.white);
b11.setForeground(Color.blue);
add(b11);
b11.addActionListener(this);
b11.setBounds(80,85,30,30);
b12 = new Button("9");
b12.setBackground(Color.white);
b12.setForeground(Color.blue);
add(b12);
b12.addActionListener(this);
b12.setBounds(80,50,30,30);
b13= new Button("+");
b13.setBackground(Color.white);
b13.setForeground(Color.gray);
add(b13);
b13.addActionListener(this);
b13.setBounds(115,155,30,30);
b14 = new Button("-");
b14.setBackground(Color.white);
b14.setForeground(Color.gray);
add(b14);
b14.addActionListener(this);
b14.setBounds(115,120,30,30);
b15 = new Button("\u00d7");
b15.setBackground(Color.white);
b15.setForeground(Color.gray);
add(b15);
b15.addActionListener(this);
b15.setBounds(115,85,30,30);
b16 = new Button("\u00f7");
b16.setBackground(Color.white);
b16.setForeground(Color.gray);
add(b16);
b16.addActionListener(this);
b16.setBounds(115,50,30,30);
b17= new Button("=");
b17.setBackground(Color.green);
b17.setForeground(Color.black);
add(b17);
b17.addActionListener(this);
b17.setBounds(150,120,30,65);
b18 = new Button("%");
b18.setBackground(Color.white);
b18.setForeground(Color.red);
add(b18);
b18.addActionListener(this);
b18.setBounds(150,85,30,30);
b19 = new Button("sqrt");
b19.setBackground(Color.white);
b19.setForeground(Color.red);
add(b19);
b19.addActionListener(this);
b19.setBounds(150,50,30,30);
b20= new Button("E");
b20.setBackground(Color.gray);
b20.setForeground(Color.orange);
add(b20);
b20.addActionListener(this);
b20.setBounds(195,155,30,30);
b21 = new Button("PI");
b21.setBackground(Color.gray);
b21.setForeground(Color.orange);
add(b21);
b21.addActionListener(this);
b21.setBounds(195,120,30,30);
b22 = new Button("n!");
b22.setBackground(Color.gray);
b22.setForeground(Color.orange);
add(b22);
b22.addActionListener(this);
b22.setBounds(195,85,30,30);
b23 = new Button("In");
b23.setBackground(Color.gray);
b23.setForeground(Color.orange);
add(b23);
b23.addActionListener(this);
b23.setBounds(195,50,30,30);
b24= new Button("sin");
b24.setBackground(Color.gray);
b24.setForeground(Color.orange);
add(b24);
b24.addActionListener(this);
b24.setBounds(230,155,30,30);
b25 = new Button("cos");
b25.setBackground(Color.gray);
b25.setForeground(Color.orange);
add(b25);
b25.addActionListener(this);
b25.setBounds(230,120,30,30);
b26 = new Button("tan");
b26.setBackground(Color.gray);
b26.setForeground(Color.orange);
add(b26);
b26.addActionListener(this);
b26.setBounds(230,85,30,30);
b27 = new Button("log");
b27.setBackground(Color.gray);
b27.setForeground(Color.orange);
add(b27);
b27.addActionListener(this);
b27.setBounds(230,50,30,30);
b28= new Button("asin");
b28.setBackground(Color.gray);
b28.setForeground(Color.orange);
add(b28);
b28.addActionListener(this);
b28.setBounds(265,155,30,30);
b29 = new Button("acos");
b29.setBackground(Color.gray);
b29.setForeground(Color.orange);
add(b29);
b29.addActionListener(this);
b29.setBounds(265,120,30,30);
b30 = new Button("atan");
b30.setBackground(Color.gray);
b30.setForeground(Color.orange);
add(b30);
b30.addActionListener(this);
b30.setBounds(265,85,30,30);
b31 = new Button("mod");
b31.setBackground(Color.gray);
b31.setForeground(Color.orange);
add(b31);
b31.addActionListener(this);
b31.setBounds(265,50,30,30);
b32= new Button("x^2");
b32.setBackground(Color.gray);
b32.setForeground(Color.orange);
add(b32);
b32.addActionListener(this);
b32.setBounds(300,155,30,30);
b33 = new Button("x^3");
b33.setBackground(Color.gray);
b33.setForeground(Color.orange);
add(b33);
b33.addActionListener(this);
b33.setBounds(300,120,30,30);
b34 = new Button("x^y");
b34.setBackground(Color.gray);
b34.setForeground(Color.orange);
add(b34);
b34.addActionListener(this);
b34.setBounds(300,85,30,30);
b35 = new Button("e^x");
b35.setBackground(Color.gray);
b35.setForeground(Color.orange);
add(b35);
b35.addActionListener(this);
b35.setBounds(300,50,30,30);
b36= new Button("M");
b36.setBackground(Color.blue);
b36.setForeground(Color.yellow);
add(b36);
b36.addActionListener(this);
b36.setBounds(345,155,30,30);
b37 = new Button("RM");
b37.setBackground(Color.blue);
b37.setForeground(Color.yellow);
add(b37);
b37.addActionListener(this);
b37.setBounds(345,120,30,30);
b38 = new Button("M2");
b38.setBackground(Color.blue);
b38.setForeground(Color.yellow);
add(b38);
b38.addActionListener(this);
b38.setBounds(345,85,30,30);
b39 = new Button("M3");
b39.setBackground(Color.blue);
b39.setForeground(Color.yellow);
add(b39);
b39.addActionListener(this);
b39.setBounds(345,50,30,30);
b40= new Button("C");
b40.setBackground(Color.red);
b40.setForeground(Color.white);
add(b40);
b40.addActionListener(this);
b40.setBounds(385,120,30,65);
b41 = new Button("CE");
b41.setBackground(Color.red);
b41.setForeground(Color.white);
add(b41);
b41.addActionListener(this);
b41.setBounds(385,50,30,65);
}
public void actionPerformed(ActionEvent evt)
{
String s = evt.getActionCommand();
if (s.equals(“C”))
{
operando1 = 0;
op = “=”;
display.setText(“0”);
start = true;
}
else if(‘0’ <= s.charAt(0) && s.charAt(0) <= ‘9’|| s.equals("."))
{
if (start)
{
display.setText(s);
start = false;
}
else
{
display.setText(display.getText() + s);
}
}
else
{
if (s.equals("PI"))
{
double aux = 1;
aux = Math.PI;
display.setText("" + aux);
}
if(s.equals("E"))
{
double aux = 1;
aux = Math.E;
display.setText("" + aux);
}
if(s.equals("%"))
{
double x = Double.parseDouble(display.getText());
double total = (operando1*x)/100;
display.setText("" + total);
}
if(s.equals("+/-"))
{
double total = 0;
double x = Double.parseDouble(display.getText());
if (x != 0)
total = (x * -1);
display.setText("" + total);
}
String memoria = "M RM M2 M3";
if(memoria.indexOf(s)!= -1)
{
JOptionPane.showMessageDialog(
null, "Este recursos será implementado na Calculadora verão 2. Aguarde !!!");
}
String comp = "sqrt In n! PI log tan cos sin x^2"
- "x^3 asin acos atan e^x" ;
if (comp.indexOf(s) != -1)
{
calculate1(Double.parseDouble
(display.getText()),s);
start = true;
}
String comum = "= + - * / \u00d7 \u00f7 x^y mod";
if (s.equals("CE"))
{
display.setText("" + operando1);
op = s;
start = true;
}else if (comum.indexOf(s) != -1)
{
double x = Double.parseDouble(display.getText());
calculate(x);
op = s;
start = true;
}
}
}
public void calculate1(double opr,String op)
{
if (op.equals("sqrt")) opr = Math.sqrt(opr);
else if(op.equals("In")) opr = Math.log(opr);
else if(op.equals("n!")) opr = fatorial(opr);
else if(op.equals("log")) opr = Math.log(opr);
else if(op.equals("tan")) opr = Math.tan((oprMath.PI) / 180);
else if(op.equals("cos")) opr = Math.cos((oprMath.PI) / 180);
else if(op.equals("sin")) opr = Math.sin((opr*Math.PI) / 180) ;
else if(op.equals("asin")) opr = Math.asin(opr);
else if(op.equals("acos")) opr = Math.acos(opr);
else if(op.equals("atan")) opr = Math.atan(opr);
else if(op.equals("x^2")) opr = Math.pow(opr,2);
else if(op.equals("x^3")) opr = Math.pow(opr,3);
else if(op.equals("e^x")) opr = Math.exp(opr);
display.setText("" + opr);
}
public double fatorial(double nro)
{
if(nro <=1)
return 1;
else
return nro*fatorial(nro-1);
}
public double umSobre(double nro)
{
if (nro != 0)
return ((1)/(nro));
else
return 0;
}
public void calculate(double n)
{
if (op.equals("+")) operando1 += n;
else if (op.equals("-")) operando1 -= n;
else if (op.equals("\u00d7")) operando1 *= n;
else if (op.equals("\u00f7")) operando1 /= n;
else if (op.equals("=")) operando1 = n;
else if (op.equals("x^y")) operando1 = Math.pow(operando1,n);
else if (op.equals("mod")) operando1 %= n;
display.setText("" + operando1);
}
private JTextField display;
private double operando1 = 0;
private BigDecimal memory[];
private boolean start = true;
private String op = "=";
private Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,
b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,
b27,b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,b38,
b39,b40,b41;
}
//pronto por ultimo o frame que eu quero instanciar-las
mport ferramentas.Data;
import ferramentas.*;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
/**
*
-
@author Kayo
/
public class Tela_DT extends javax.swing.JFrame {
Data mostra_data;
/* Creates new form TelaPrincipal */
public Tela_DT() {
initComponents();
mostra_data = new Data();
mostra_data.le_data();
L_Data.setText(mostra_data.getDia()+", "//mostrar o dia do mês
+mostra_data.getDia_semana()+" de "//Mostrar o dia da semana
+mostra_data.getMes()+" de "//Mostrar o mês
+mostra_data.getAno());//Mostrar o ano
//Mostrar a hora atualizada
mostra_data.le_hora();
L_Hora.setText("Hora atual"+mostra_data.getHora());
//Iniciando o component timer
timer1.start();
//fazer a tela mudar forma
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception erro){
JOptionPane.showMessageDialog(null, erro);
}
}
/** 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() {
timer1 = new org.netbeans.examples.lib.timerbean.Timer();
jLabel2 = new javax.swing.JLabel();
L_Data = new javax.swing.JLabel();
jSeparator3 = new javax.swing.JSeparator();
jPanel1 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
L_Hora = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
Menu_Arquivos = new javax.swing.JMenu();
Sub_Menu_Cadastro = new javax.swing.JMenu();
Menu_cad_estudante = new javax.swing.JMenuItem();
Menu_cad_notas = new javax.swing.JMenuItem();
Menu_cad_faltas = new javax.swing.JMenuItem();
jSeparator1 = new javax.swing.JPopupMenu.Separator();
Menu_sair = new javax.swing.JMenuItem();
Sub_Menu_Busca = new javax.swing.JMenu();
Menu_cad_estudante1 = new javax.swing.JMenuItem();
Menu_cad_turma1 = new javax.swing.JMenuItem();
Menu_cad_serie1 = new javax.swing.JMenuItem();
Menu_cad_disciplina1 = new javax.swing.JMenuItem();
Menu_cad_notas1 = new javax.swing.JMenuItem();
Menu_cad_faltas1 = new javax.swing.JMenuItem();
Menu_Cad_Usuario1 = new javax.swing.JMenuItem();
Sub_Menu_Atualizacao = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
Menu_Desempenho = new javax.swing.JMenu();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
Menu_Ferramentas = new javax.swing.JMenu();
Menu_Calculadora = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem9 = new javax.swing.JMenuItem();
jMenuItem14 = new javax.swing.JMenuItem();
jMenuItem15 = new javax.swing.JMenuItem();
jMenuItem16 = new javax.swing.JMenuItem();
jMenuItem17 = new javax.swing.JMenuItem();
jSeparator4 = new javax.swing.JPopupMenu.Separator();
jMenu1 = new javax.swing.JMenu();
jMenuItem10 = new javax.swing.JMenuItem();
jMenuItem11 = new javax.swing.JMenuItem();
Menu_Ajuda = new javax.swing.JMenu();
Menu_Sair = new javax.swing.JMenu();
timer1.addTimerListener(new org.netbeans.examples.lib.timerbean.TimerListener() {
public void onTime(java.awt.event.ActionEvent evt) {
timer1OnTime(evt);
}
});
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“Sistema Diretor de Turma(S.D.T)”);
setBackground(new java.awt.Color(51, 204, 0));
setResizable(false);
jLabel2.setText(“Desenvolvimento de KRSoftware C”);
L_Data.setText(“Data.:”);
jPanel1.setBackground(new java.awt.Color(0, 204, 0));
jPanel1.setMinimumSize(new java.awt.Dimension(100, 200));
jLabel6.setText(“S.D.T”);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(359, 359, 359)
.addComponent(jLabel6)
.addContainerGap(380, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(53, 53, 53)
.addComponent(jLabel6)
.addContainerGap(31, Short.MAX_VALUE))
);
L_Hora.setText(“Hora.:”);
Menu_Arquivos.setText(“Arquivo”);
Sub_Menu_Cadastro.setText(“Cadastros”);
Menu_cad_estudante.setText(“Estudante”);
Sub_Menu_Cadastro.add(Menu_cad_estudante);
Menu_cad_notas.setText(“Notas”);
Sub_Menu_Cadastro.add(Menu_cad_notas);
Menu_cad_faltas.setText(“Faltas”);
Sub_Menu_Cadastro.add(Menu_cad_faltas);
Sub_Menu_Cadastro.add(jSeparator1);
Menu_sair.setText(“Sair”);
Sub_Menu_Cadastro.add(Menu_sair);
Menu_Arquivos.add(Sub_Menu_Cadastro);
Sub_Menu_Busca.setText(“Busca”);
Menu_cad_estudante1.setText(“Estudante”);
Sub_Menu_Busca.add(Menu_cad_estudante1);
Menu_cad_turma1.setText(“Turma”);
Sub_Menu_Busca.add(Menu_cad_turma1);
Menu_cad_serie1.setText(“Série”);
Sub_Menu_Busca.add(Menu_cad_serie1);
Menu_cad_disciplina1.setText(“Disciplina”);
Sub_Menu_Busca.add(Menu_cad_disciplina1);
Menu_cad_notas1.setText(“Notas”);
Sub_Menu_Busca.add(Menu_cad_notas1);
Menu_cad_faltas1.setText(“Faltas”);
Sub_Menu_Busca.add(Menu_cad_faltas1);
Menu_Cad_Usuario1.setText(“Usuario”);
Sub_Menu_Busca.add(Menu_Cad_Usuario1);
Menu_Arquivos.add(Sub_Menu_Busca);
Sub_Menu_Atualizacao.setText(“Atualização”);
Menu_Arquivos.add(Sub_Menu_Atualizacao);
jMenu2.setText(“Documentos”);
Menu_Arquivos.add(jMenu2);
jMenuBar1.add(Menu_Arquivos);
Menu_Desempenho.setMnemonic(‘D’);
Menu_Desempenho.setText(“Desempenho”);
jMenuItem3.setText(“Estudante”);
Menu_Desempenho.add(jMenuItem3);
jMenuItem4.setText(“Turma”);
Menu_Desempenho.add(jMenuItem4);
jMenuItem5.setText(“Spaece”);
Menu_Desempenho.add(jMenuItem5);
jMenuBar1.add(Menu_Desempenho);
Menu_Ferramentas.setMnemonic(‘F’);
Menu_Ferramentas.setText(“Ferramentas”);
Menu_Ferramentas.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Menu_FerramentasItemStateChanged(evt);
}
});
Menu_Calculadora.setText(“Calculadora”);
Menu_Calculadora.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
Menu_CalculadoraMouseClicked(evt);
}
});
Menu_Calculadora.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Menu_CalculadoraActionPerformed(evt);
}
});
Menu_Calculadora.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
Menu_CalculadoraKeyPressed(evt);
}
});
Menu_Calculadora.addMenuKeyListener(new javax.swing.event.MenuKeyListener() {
public void menuKeyPressed(javax.swing.event.MenuKeyEvent evt) {
Menu_CalculadoraMenuKeyPressed(evt);
}
public void menuKeyReleased(javax.swing.event.MenuKeyEvent evt) {
}
public void menuKeyTyped(javax.swing.event.MenuKeyEvent evt) {
}
});
Menu_Calculadora.addMenuDragMouseListener(new javax.swing.event.MenuDragMouseListener() {
public void menuDragMouseDragged(javax.swing.event.MenuDragMouseEvent evt) {
}
public void menuDragMouseEntered(javax.swing.event.MenuDragMouseEvent evt) {
Menu_CalculadoraMenuDragMouseEntered(evt);
}
public void menuDragMouseExited(javax.swing.event.MenuDragMouseEvent evt) {
}
public void menuDragMouseReleased(javax.swing.event.MenuDragMouseEvent evt) {
}
});
Menu_Ferramentas.add(Menu_Calculadora);
jMenuItem6.setText(“Importar Dados”);
Menu_Ferramentas.add(jMenuItem6);
jMenuItem8.setText(“Exportar Dados”);
Menu_Ferramentas.add(jMenuItem8);
jMenuItem9.setText(“Abrir Arquivo…”);
Menu_Ferramentas.add(jMenuItem9);
jMenuItem14.setText(“Mapeamento da turma”);
Menu_Ferramentas.add(jMenuItem14);
jMenuItem15.setText(“Aulas de Campo”);
Menu_Ferramentas.add(jMenuItem15);
jMenuItem16.setText(“S.D.T Web”);
Menu_Ferramentas.add(jMenuItem16);
jMenuItem17.setText(“Calendário”);
Menu_Ferramentas.add(jMenuItem17);
Menu_Ferramentas.add(jSeparator4);
jMenu1.setText(“Imprimir”);
jMenuItem10.setText(“Relatório”);
jMenu1.add(jMenuItem10);
jMenuItem11.setText(“Gráfico”);
jMenu1.add(jMenuItem11);
Menu_Ferramentas.add(jMenu1);
jMenuBar1.add(Menu_Ferramentas);
Menu_Ajuda.setMnemonic(‘A’);
Menu_Ajuda.setText(“Ajuda”);
jMenuBar1.add(Menu_Ajuda);
Menu_Sair.setMnemonic(‘S’);
Menu_Sair.setText(“Sair”);
Menu_Sair.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
Menu_SairMouseClicked(evt);
}
});
Menu_Sair.addMenuListener(new javax.swing.event.MenuListener() {
public void menuCanceled(javax.swing.event.MenuEvent evt) {
Menu_SairMenuCanceled(evt);
}
public void menuDeselected(javax.swing.event.MenuEvent evt) {
}
public void menuSelected(javax.swing.event.MenuEvent evt) {
}
});
Menu_Sair.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Menu_SairActionPerformed(evt);
}
});
jMenuBar1.add(Menu_Sair);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(L_Hora)
.addContainerGap(725, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(L_Data)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 520, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 288, Short.MAX_VALUE)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(L_Hora)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(L_Data)
.addComponent(jLabel2)))
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-782)/2, (screenSize.height-487)/2, 782, 487);
}// </editor-fold>
private void Menu_SairMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here: System.exit(0); }
System.exit(0);
}
private void Menu_SairMenuCanceled(javax.swing.event.MenuEvent evt) {
// TODO add your handling code here: System.exit(0); }
}
private void Menu_SairActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: }
}
private void timer1OnTime(java.awt.event.ActionEvent evt) {
mostra_data.le_hora();
L_Hora.setText(“Hora atual”+mostra_data.getHora());
}
private void Menu_CalculadoraKeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
//Nome da classe do Novo Formulario
}
private void Menu_CalculadoraMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void Menu_CalculadoraMenuDragMouseEntered(javax.swing.event.MenuDragMouseEvent evt) {
// TODO add your handling code here:
}
private void Menu_CalculadoraMenuKeyPressed(javax.swing.event.MenuKeyEvent evt) {
// TODO add your handling code here:
}
private void Menu_FerramentasItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
}
//aqui em baixo é onde estou instanciando
private void Menu_CalculadoraActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Calculadora calculadora = new Calculadora();
calculadora.setVisible(true);
}
Vlw! Obrigado, e estou esperando vossa ajuda!