SlideShare a Scribd company logo
PROGRAMAÇÃO SISTEMAS
DISTRIBUÍDOS
JAVA PARA WEB
NETBEANS
Por Vera Cymbron 2012
EXERCICIO 1 – CALCULADORA
Source
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package calculadora;
/**
*
* @author CAO VeraCymbron
*/
public class Calculadora extends javax.swing.JFrame {
/**
* Creates new form Calculadora
*/
public Calculadora() {
initComponents();
}
/**
* 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() {
valor1 = new javax.swing.JLabel();
valor2 = new javax.swing.JLabel();
TF2 = new javax.swing.JTextField();
bsoma = new javax.swing.JButton();
TF3 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
bdivisao = new javax.swing.JButton();
bsubtraccao = new javax.swing.JButton();
bmultiplicacao = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
valor1.setText("Numero1");
valor1.setToolTipText("");
valor2.setText("Numero2");
TF2.setToolTipText("");
bsoma.setMnemonic('s');
bsoma.setText("Soma");
bsoma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bsomaActionPerformed(evt);
}
});
TF3.setToolTipText("");
jLabel3.setText("Resultado:");
bdivisao.setMnemonic('s');
bdivisao.setText("Divisão");
bdivisao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bdivisaoActionPerformed(evt);
}
});
bsubtraccao.setMnemonic('s');
bsubtraccao.setText("Subtracção");
bsubtraccao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bsubtraccaoActionPerformed(evt);
}
});
bmultiplicacao.setMnemonic('s');
bmultiplicacao.setText("Multiplicação");
bmultiplicacao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bmultiplicacaoActionPerformed(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(85, 85, 85)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(bsoma, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(TF3)
.addComponent(bdivisao, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(TF2, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(bsubtraccao, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bmultiplicacao, javax.swing.GroupLayout.DEFAULT_SIZE, 107,
Short.MAX_VALUE))
.addGap(91, 91, 91))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(117, 117, 117)
.addComponent(valor1)
.addGap(71, 71, 71)
.addComponent(valor2))
.addGroup(layout.createSequentialGroup()
.addGap(147, 147, 147)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor1)
.addComponent(valor2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(TF3, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TF2, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bsoma)
.addComponent(bsubtraccao))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(bdivisao)
.addComponent(bmultiplicacao))
.addGap(18, 18, 18)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(122, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void bsomaActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 + num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bdivisaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 / num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bsubtraccaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 - num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
private void bmultiplicacaoActionPerformed(java.awt.event.ActionEvent evt) {
double num1, num2, res; //variáveis auxiliares
//converter o numero digitado em Float
num1 = Double.parseDouble(TF2.getText());
num2 = Double.parseDouble (TF3.getText());
res = num1 * num2;
//converte o resultado em String e mostrar
jLabel3.setText(String.valueOf("Resultado: " +res));
TF2.setText(" ");//Limpar o JTextField
TF3.setText(" ");
TF3.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Calculadora().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField TF2;
private javax.swing.JTextField TF3;
private javax.swing.JButton bdivisao;
private javax.swing.JButton bmultiplicacao;
private javax.swing.JButton bsoma;
private javax.swing.JButton bsubtraccao;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel valor1;
private javax.swing.JLabel valor2;
// End of variables declaration
}
EXERCICIO 2 – CALCULAR VALOR DA INDEMINIZAÇÃO
SOURCE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package valorindeminizacao;
/**
*
* @author CAO 12
*/
public class ValorIndemnizacao extends javax.swing.JFrame {
/**
* Creates new form ValorIndemnizacao
*/
public ValorIndemnizacao() {
initComponents();
}
/**
* 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() {
valor1 = new javax.swing.JLabel();
valor2 = new javax.swing.JLabel();
num1 = new javax.swing.JTextField();
num2 = new javax.swing.JTextField();
num3 = new javax.swing.JTextField();
calcular = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
valor3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
valor1.setText("Tempo de serviço (MESES)");
valor2.setText("Vencimento mensal");
calcular.setText("Cacular");
calcular.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calcularActionPerformed(evt);
}
});
jLabel4.setText("Valor da Indemnização é :");
valor3.setText("No caso de ter dias de férias por gozar indique");
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(44, 44, 44)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(layout.createSequentialGroup()
.addComponent(calcular, javax.swing.GroupLayout.PREFERRED_SIZE, 83,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(valor3, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(valor2)
.addComponent(valor1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(num1, javax.swing.GroupLayout.DEFAULT_SIZE, 104,
Short.MAX_VALUE)
.addComponent(num2))))
.addGap(18, 18, 18)
.addComponent(num3, javax.swing.GroupLayout.PREFERRED_SIZE, 83,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(20, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor1)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor2)
.addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor3)
.addComponent(num3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(calcular)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(149, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void calcularActionPerformed(java.awt.event.ActionEvent evt) {
double valor1, valor2, valor3, valor = 0;
//variáveis auxiliares
//converter o numero digitado em Float
valor1 = Double.parseDouble(num1.getText());
valor2 = Double.parseDouble (num2.getText());
valor3 = Double.parseDouble (num3.getText());
if (valor1<=6) {
valor = ((valor1*3*valor2)/30)+((valor3*valor2)/30);
}
else
if (valor1 >=7) {
valor = ((valor1*2*valor2)/30)+((valor3*valor2)/30);
}
//converte o resultado em String e mostrar
jLabel4.setText(String.valueOf("O valor da indemnização é: " +valor+ "€"));
num1.setText(" ");//Limpar o JTextField
num2.setText(" ");
num3.setText(" ");
num1.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ValorIndemnizacao().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton calcular;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField num1;
private javax.swing.JTextField num2;
private javax.swing.JTextField num3;
private javax.swing.JLabel valor1;
private javax.swing.JLabel valor2;
private javax.swing.JLabel valor3;
// End of variables declaration
}
EXERCICIO 3 – ORÇAMENTO
SOURCE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package orcamento;
import javax.swing.JComboBox;
/**
*
* @author CAO 12
*/
public class Orcamento extends javax.swing.JFrame {
/**
* Creates new form Orcamento
*/
public Orcamento() {
initComponents();
}
/**
* 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() {
jComboBox2 = new javax.swing.JComboBox();
area = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
num1 = new javax.swing.JTextField();
saida = new javax.swing.JLabel();
jcomboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "->",
"Estuco", "Teto falso com Plauduro normal", "Teto falso com Plauduro hidrofugado" }));
jComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox2ActionPerformed(evt);
}
});
area.setText("Área m2");
jLabel2.setText("Seleccione o serviço pretendido");
saida.setText("O valor é:");
jcomboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "23", "16"
}));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 173,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(area)
.addGap(18, 18, 18)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, 63,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 369,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(saida, javax.swing.GroupLayout.PREFERRED_SIZE, 343,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jcomboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(66, 66, 66)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(area)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jcomboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48,
Short.MAX_VALUE)
.addComponent(saida, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23))
);
pack();
}// </editor-fold>
private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {
double valor, resultado = 0;
double iva = 0;
iva = Double.parseDouble (String.valueOf(jcomboBox1.getSelectedItem()));
if
(jComboBox2.getSelectedItem().equals("Estuco"))
{
valor = Double.parseDouble (num1.getText());
if(jcomboBox1.getSelectedItem().equals("23")){
resultado = (valor*7.5)*1.23;
}
if(jcomboBox1.getSelectedItem().equals("16")){
resultado = (valor*7.5)*1.16;
}
}
else
if
(jComboBox2.getSelectedItem().equals("Teto falso com Plauduro normal")){
valor = Double.parseDouble (num1.getText());
resultado = (valor*12.5)*iva;
}
else
if
(jComboBox2.getSelectedItem().equals("Teto falso com Plauduro hidrofugado")){
valor = Double.parseDouble (num1.getText());
resultado = (valor*17.5)* iva;
}
//converte o resultado em String e mostrar
saida.setText(String.valueOf("O valor do serviço é: " +resultado+"€"));
num1.setText(" ");//Limpar o JTextField
num1.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Orcamento().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel area;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox jcomboBox1;
private javax.swing.JTextField num1;
private javax.swing.JLabel saida;
// End of variables declaration
}
EXERCICIO 4 – CALCULO DA MASSA CORPORAL
SOURCE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package massacorporal;
/**
*
* @author CAO 12
*/
public class MASSACORPORAL extends javax.swing.JFrame {
/**
* Creates new form MASSACORPORAL
*/
public MASSACORPORAL() {
initComponents();
}
/**
* 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() {
valor1 = new javax.swing.JLabel();
valor2 = new javax.swing.JLabel();
Calcular = new javax.swing.JButton();
num1 = new javax.swing.JTextField();
num2 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
valor1.setText("Peso");
valor2.setText("Altura");
Calcular.setText("Calcular");
Calcular.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CalcularActionPerformed(evt);
}
});
jLabel4.setText("Massa Corporal é");
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(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Calcular)
.addGap(98, 98, 98)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 143,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(valor1)
.addGap(18, 18, 18)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, 87,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(valor2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE, 89,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(65, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor1)
.addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valor2)
.addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(78, 78, 78)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Calcular)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(110, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void CalcularActionPerformed(java.awt.event.ActionEvent evt) {
double valor1, valor2, res; //variáveis auxiliares
//converter o numero digitado em Float
valor1 = Double.parseDouble(num1.getText());
valor2 = Double.parseDouble (num2.getText());
res = valor1/( valor2 * valor2);
//converte o resultado em String e mostrar
jLabel4.setText(String.valueOf("Resultado: " +res));
num1.setText(" ");//Limpar o JTextField
num2.setText(" ");
num1.requestFocus();//muda o foco para o JTextField1
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MASSACORPORAL().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Calcular;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField num1;
private javax.swing.JTextField num2;
private javax.swing.JLabel valor1;
private javax.swing.JLabel valor2;
// End of variables declaration
}

More Related Content

What's hot

Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Juriy Zaytsev
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
Iram Ramrajkar
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and UtilitiesPramod Kumar
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
Visual Engineering
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
Doeun KOCH
 
Don't Make Android Bad... Again
Don't Make Android Bad... AgainDon't Make Android Bad... Again
Don't Make Android Bad... Again
Pedro Vicente
 
Magic methods
Magic methodsMagic methods
Magic methods
Matthew Barlocker
 
Refactoring Jdbc Programming
Refactoring Jdbc ProgrammingRefactoring Jdbc Programming
Refactoring Jdbc Programmingchanwook Park
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Kim Hunmin
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bitsChris Saylor
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
Rafael Winterhalter
 
Deferred
DeferredDeferred
Deferred
daiying-zhang
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
Rodica Dada
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
PHP 5 Magic Methods
PHP 5 Magic MethodsPHP 5 Magic Methods
PHP 5 Magic Methods
David Stockton
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
Wanbok Choi
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 
Testing the waters of iOS
Testing the waters of iOSTesting the waters of iOS
Testing the waters of iOS
Kremizas Kostas
 
Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8
Wilson Su
 

What's hot (20)

Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
Don't Make Android Bad... Again
Don't Make Android Bad... AgainDon't Make Android Bad... Again
Don't Make Android Bad... Again
 
Magic methods
Magic methodsMagic methods
Magic methods
 
Refactoring Jdbc Programming
Refactoring Jdbc ProgrammingRefactoring Jdbc Programming
Refactoring Jdbc Programming
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
Code generation for alternative languages
Code generation for alternative languagesCode generation for alternative languages
Code generation for alternative languages
 
Deferred
DeferredDeferred
Deferred
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
 
PHP 5 Magic Methods
PHP 5 Magic MethodsPHP 5 Magic Methods
PHP 5 Magic Methods
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Testing the waters of iOS
Testing the waters of iOSTesting the waters of iOS
Testing the waters of iOS
 
Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8Practical JavaScript Programming - Session 6/8
Practical JavaScript Programming - Session 6/8
 

Similar to Exercícios Netbeans - Vera Cymbron

Settings
SettingsSettings
Settings
yito24
 
Maze
MazeMaze
Maze
yito24
 
Grain final border one
Grain final border oneGrain final border one
Grain final border one
Ashish Gupta
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
arvindarora20042013
 
Server1
Server1Server1
Server1
FahriIrawan3
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mary772
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
mccormicknadine86
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
College management system.pptx
College management system.pptxCollege management system.pptx
College management system.pptx
ManujArora3
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student PortalPeeyush Ranjan
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
wahyuseptiansyah
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
kvangork
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
JOYITAKUNDU1
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
javatwo2011
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3martha leon
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
Krzysztof Szafranek
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
Ryunosuke SATO
 

Similar to Exercícios Netbeans - Vera Cymbron (20)

Settings
SettingsSettings
Settings
 
Maze
MazeMaze
Maze
 
Grain final border one
Grain final border oneGrain final border one
Grain final border one
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
Server1
Server1Server1
Server1
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
College management system.pptx
College management system.pptxCollege management system.pptx
College management system.pptx
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
New text document
New text documentNew text document
New text document
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
JavaScript Refactoring
JavaScript RefactoringJavaScript Refactoring
JavaScript Refactoring
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 

More from cymbron

Exercício 3
Exercício 3Exercício 3
Exercício 3cymbron
 
Exercício 2
Exercício 2Exercício 2
Exercício 2cymbron
 
Exercício 1
Exercício 1Exercício 1
Exercício 1cymbron
 
Exercício 5
Exercício 5Exercício 5
Exercício 5cymbron
 
Exercício 4
Exercício 4Exercício 4
Exercício 4cymbron
 
Administração de Rede Local
Administração de Rede LocalAdministração de Rede Local
Administração de Rede Localcymbron
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Netcymbron
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Netcymbron
 
Código Opção Substituir
Código Opção SubstituirCódigo Opção Substituir
Código Opção Substituircymbron
 
Código Splash Screen
Código Splash ScreenCódigo Splash Screen
Código Splash Screencymbron
 
Log me in cymbron
Log me in cymbronLog me in cymbron
Log me in cymbroncymbron
 
Filezilla cymbron
Filezilla cymbronFilezilla cymbron
Filezilla cymbroncymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbroncymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbroncymbron
 
Orçamento pc - vera cymbron
Orçamento   pc - vera cymbronOrçamento   pc - vera cymbron
Orçamento pc - vera cymbroncymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbroncymbron
 
Catálogo reminiscências
Catálogo  reminiscênciasCatálogo  reminiscências
Catálogo reminiscênciascymbron
 
Catálogo exposição pele da alma
Catálogo exposição pele da almaCatálogo exposição pele da alma
Catálogo exposição pele da almacymbron
 

More from cymbron (18)

Exercício 3
Exercício 3Exercício 3
Exercício 3
 
Exercício 2
Exercício 2Exercício 2
Exercício 2
 
Exercício 1
Exercício 1Exercício 1
Exercício 1
 
Exercício 5
Exercício 5Exercício 5
Exercício 5
 
Exercício 4
Exercício 4Exercício 4
Exercício 4
 
Administração de Rede Local
Administração de Rede LocalAdministração de Rede Local
Administração de Rede Local
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Net
 
Código Acerca Editor_Net
Código Acerca Editor_NetCódigo Acerca Editor_Net
Código Acerca Editor_Net
 
Código Opção Substituir
Código Opção SubstituirCódigo Opção Substituir
Código Opção Substituir
 
Código Splash Screen
Código Splash ScreenCódigo Splash Screen
Código Splash Screen
 
Log me in cymbron
Log me in cymbronLog me in cymbron
Log me in cymbron
 
Filezilla cymbron
Filezilla cymbronFilezilla cymbron
Filezilla cymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbron
 
Orçamento pc - vera cymbron
Orçamento   pc - vera cymbronOrçamento   pc - vera cymbron
Orçamento pc - vera cymbron
 
Dispositivos e periféricos vera cymbron
Dispositivos e periféricos   vera cymbronDispositivos e periféricos   vera cymbron
Dispositivos e periféricos vera cymbron
 
Catálogo reminiscências
Catálogo  reminiscênciasCatálogo  reminiscências
Catálogo reminiscências
 
Catálogo exposição pele da alma
Catálogo exposição pele da almaCatálogo exposição pele da alma
Catálogo exposição pele da alma
 

Recently uploaded

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

Exercícios Netbeans - Vera Cymbron

  • 1. PROGRAMAÇÃO SISTEMAS DISTRIBUÍDOS JAVA PARA WEB NETBEANS Por Vera Cymbron 2012
  • 2. EXERCICIO 1 – CALCULADORA Source /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package calculadora; /** * * @author CAO VeraCymbron */ public class Calculadora extends javax.swing.JFrame { /** * Creates new form Calculadora */ public Calculadora() { initComponents(); } /** * 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() { valor1 = new javax.swing.JLabel(); valor2 = new javax.swing.JLabel(); TF2 = new javax.swing.JTextField();
  • 3. bsoma = new javax.swing.JButton(); TF3 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); bdivisao = new javax.swing.JButton(); bsubtraccao = new javax.swing.JButton(); bmultiplicacao = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); valor1.setText("Numero1"); valor1.setToolTipText(""); valor2.setText("Numero2"); TF2.setToolTipText(""); bsoma.setMnemonic('s'); bsoma.setText("Soma"); bsoma.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bsomaActionPerformed(evt); } }); TF3.setToolTipText(""); jLabel3.setText("Resultado:"); bdivisao.setMnemonic('s'); bdivisao.setText("Divisão"); bdivisao.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bdivisaoActionPerformed(evt); } }); bsubtraccao.setMnemonic('s'); bsubtraccao.setText("Subtracção"); bsubtraccao.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bsubtraccaoActionPerformed(evt); } }); bmultiplicacao.setMnemonic('s'); bmultiplicacao.setText("Multiplicação"); bmultiplicacao.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bmultiplicacaoActionPerformed(evt); } });
  • 4. 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(85, 85, 85) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(bsoma, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) .addComponent(TF3) .addComponent(bdivisao, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(TF2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(bsubtraccao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(bmultiplicacao, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)) .addGap(91, 91, 91)))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(117, 117, 117) .addComponent(valor1) .addGap(71, 71, 71) .addComponent(valor2)) .addGroup(layout.createSequentialGroup() .addGap(147, 147, 147) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor1) .addComponent(valor2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(TF3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 5. .addComponent(TF2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(bsoma) .addComponent(bsubtraccao)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(bdivisao) .addComponent(bmultiplicacao)) .addGap(18, 18, 18) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(122, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void bsomaActionPerformed(java.awt.event.ActionEvent evt) { double num1, num2, res; //variáveis auxiliares //converter o numero digitado em Float num1 = Double.parseDouble(TF2.getText()); num2 = Double.parseDouble (TF3.getText()); res = num1 + num2; //converte o resultado em String e mostrar jLabel3.setText(String.valueOf("Resultado: " +res)); TF2.setText(" ");//Limpar o JTextField TF3.setText(" "); TF3.requestFocus();//muda o foco para o JTextField1 } private void bdivisaoActionPerformed(java.awt.event.ActionEvent evt) { double num1, num2, res; //variáveis auxiliares //converter o numero digitado em Float num1 = Double.parseDouble(TF2.getText()); num2 = Double.parseDouble (TF3.getText()); res = num1 / num2; //converte o resultado em String e mostrar jLabel3.setText(String.valueOf("Resultado: " +res)); TF2.setText(" ");//Limpar o JTextField TF3.setText(" "); TF3.requestFocus();//muda o foco para o JTextField1 } private void bsubtraccaoActionPerformed(java.awt.event.ActionEvent evt) { double num1, num2, res; //variáveis auxiliares //converter o numero digitado em Float num1 = Double.parseDouble(TF2.getText()); num2 = Double.parseDouble (TF3.getText());
  • 6. res = num1 - num2; //converte o resultado em String e mostrar jLabel3.setText(String.valueOf("Resultado: " +res)); TF2.setText(" ");//Limpar o JTextField TF3.setText(" "); TF3.requestFocus();//muda o foco para o JTextField1 } private void bmultiplicacaoActionPerformed(java.awt.event.ActionEvent evt) { double num1, num2, res; //variáveis auxiliares //converter o numero digitado em Float num1 = Double.parseDouble(TF2.getText()); num2 = Double.parseDouble (TF3.getText()); res = num1 * num2; //converte o resultado em String e mostrar jLabel3.setText(String.valueOf("Resultado: " +res)); TF2.setText(" ");//Limpar o JTextField TF3.setText(" "); TF3.requestFocus();//muda o foco para o JTextField1 } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (IllegalAccessException ex) {
  • 7. java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Calculadora().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTextField TF2; private javax.swing.JTextField TF3; private javax.swing.JButton bdivisao; private javax.swing.JButton bmultiplicacao; private javax.swing.JButton bsoma; private javax.swing.JButton bsubtraccao; private javax.swing.JLabel jLabel3; private javax.swing.JLabel valor1; private javax.swing.JLabel valor2; // End of variables declaration } EXERCICIO 2 – CALCULAR VALOR DA INDEMINIZAÇÃO SOURCE /*
  • 8. * To change this template, choose Tools | Templates * and open the template in the editor. */ package valorindeminizacao; /** * * @author CAO 12 */ public class ValorIndemnizacao extends javax.swing.JFrame { /** * Creates new form ValorIndemnizacao */ public ValorIndemnizacao() { initComponents(); } /** * 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() { valor1 = new javax.swing.JLabel(); valor2 = new javax.swing.JLabel(); num1 = new javax.swing.JTextField(); num2 = new javax.swing.JTextField(); num3 = new javax.swing.JTextField(); calcular = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); valor3 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); valor1.setText("Tempo de serviço (MESES)"); valor2.setText("Vencimento mensal"); calcular.setText("Cacular"); calcular.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { calcularActionPerformed(evt); } }); jLabel4.setText("Valor da Indemnização é :"); valor3.setText("No caso de ter dias de férias por gozar indique");
  • 9. 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(44, 44, 44) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(calcular, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(valor3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(valor2) .addComponent(valor1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(num1, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE) .addComponent(num2)))) .addGap(18, 18, 18) .addComponent(num3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor1) .addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor2) .addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  • 10. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor3) .addComponent(num3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(calcular) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(149, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void calcularActionPerformed(java.awt.event.ActionEvent evt) { double valor1, valor2, valor3, valor = 0; //variáveis auxiliares //converter o numero digitado em Float valor1 = Double.parseDouble(num1.getText()); valor2 = Double.parseDouble (num2.getText()); valor3 = Double.parseDouble (num3.getText()); if (valor1<=6) { valor = ((valor1*3*valor2)/30)+((valor3*valor2)/30); } else if (valor1 >=7) { valor = ((valor1*2*valor2)/30)+((valor3*valor2)/30); } //converte o resultado em String e mostrar jLabel4.setText(String.valueOf("O valor da indemnização é: " +valor+ "€")); num1.setText(" ");//Limpar o JTextField num2.setText(" "); num3.setText(" "); num1.requestFocus();//muda o foco para o JTextField1 } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) {
  • 11. javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ValorIndemnizacao.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ValorIndemnizacao().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton calcular; private javax.swing.JLabel jLabel4; private javax.swing.JTextField num1; private javax.swing.JTextField num2; private javax.swing.JTextField num3; private javax.swing.JLabel valor1; private javax.swing.JLabel valor2; private javax.swing.JLabel valor3; // End of variables declaration }
  • 12. EXERCICIO 3 – ORÇAMENTO SOURCE /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package orcamento; import javax.swing.JComboBox; /** * * @author CAO 12 */ public class Orcamento extends javax.swing.JFrame { /** * Creates new form Orcamento */ public Orcamento() { initComponents(); } /** * 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">
  • 13. private void initComponents() { jComboBox2 = new javax.swing.JComboBox(); area = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); num1 = new javax.swing.JTextField(); saida = new javax.swing.JLabel(); jcomboBox1 = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "->", "Estuco", "Teto falso com Plauduro normal", "Teto falso com Plauduro hidrofugado" })); jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); area.setText("Área m2"); jLabel2.setText("Seleccione o serviço pretendido"); saida.setText("O valor é:"); jcomboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "23", "16" })); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(area) .addGap(18, 18, 18) .addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 369, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(saida, javax.swing.GroupLayout.PREFERRED_SIZE, 343, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jcomboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  • 14. .addGroup(layout.createSequentialGroup() .addGap(66, 66, 66) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(area) .addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jLabel2) .addGap(18, 18, 18) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(jcomboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE) .addComponent(saida, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(23, 23, 23)) ); pack(); }// </editor-fold> private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) { double valor, resultado = 0; double iva = 0; iva = Double.parseDouble (String.valueOf(jcomboBox1.getSelectedItem())); if (jComboBox2.getSelectedItem().equals("Estuco")) { valor = Double.parseDouble (num1.getText()); if(jcomboBox1.getSelectedItem().equals("23")){ resultado = (valor*7.5)*1.23; } if(jcomboBox1.getSelectedItem().equals("16")){ resultado = (valor*7.5)*1.16; } } else if (jComboBox2.getSelectedItem().equals("Teto falso com Plauduro normal")){ valor = Double.parseDouble (num1.getText()); resultado = (valor*12.5)*iva; } else if (jComboBox2.getSelectedItem().equals("Teto falso com Plauduro hidrofugado")){ valor = Double.parseDouble (num1.getText()); resultado = (valor*17.5)* iva; }
  • 15. //converte o resultado em String e mostrar saida.setText(String.valueOf("O valor do serviço é: " +resultado+"€")); num1.setText(" ");//Limpar o JTextField num1.requestFocus();//muda o foco para o JTextField1 } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Orcamento.class.getName()).log(java.util.logging.Level.SEVE RE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Orcamento().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JLabel area; private javax.swing.JComboBox jComboBox2;
  • 16. private javax.swing.JLabel jLabel2; private javax.swing.JComboBox jcomboBox1; private javax.swing.JTextField num1; private javax.swing.JLabel saida; // End of variables declaration } EXERCICIO 4 – CALCULO DA MASSA CORPORAL SOURCE /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package massacorporal; /** * * @author CAO 12 */ public class MASSACORPORAL extends javax.swing.JFrame { /** * Creates new form MASSACORPORAL */ public MASSACORPORAL() { initComponents(); } /** * 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.
  • 17. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { valor1 = new javax.swing.JLabel(); valor2 = new javax.swing.JLabel(); Calcular = new javax.swing.JButton(); num1 = new javax.swing.JTextField(); num2 = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); valor1.setText("Peso"); valor2.setText("Altura"); Calcular.setText("Calcular"); Calcular.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CalcularActionPerformed(evt); } }); jLabel4.setText("Massa Corporal é"); 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(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(Calcular) .addGap(98, 98, 98) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(valor1) .addGap(18, 18, 18) .addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(valor2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(65, Short.MAX_VALUE))
  • 18. ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor1) .addComponent(num1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(valor2) .addComponent(num2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(78, 78, 78) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(Calcular) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(110, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void CalcularActionPerformed(java.awt.event.ActionEvent evt) { double valor1, valor2, res; //variáveis auxiliares //converter o numero digitado em Float valor1 = Double.parseDouble(num1.getText()); valor2 = Double.parseDouble (num2.getText()); res = valor1/( valor2 * valor2); //converte o resultado em String e mostrar jLabel4.setText(String.valueOf("Resultado: " +res)); num1.setText(" ");//Limpar o JTextField num2.setText(" "); num1.requestFocus();//muda o foco para o JTextField1 } /** * @param args the command line arguments */ public static void main(String args[]) { //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */
  • 19. try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MASSACORPORAL.class.getName()).log(java.util.logging.Lev el.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MASSACORPORAL().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton Calcular; private javax.swing.JLabel jLabel4; private javax.swing.JTextField num1; private javax.swing.JTextField num2; private javax.swing.JLabel valor1; private javax.swing.JLabel valor2; // End of variables declaration }