Biblioteca Java - Rev 4
Subversion Repositories:
package oop.controltemperatura;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author evo2
*/
public class TermostatUI extends javax.swing.JFrame {
Termostat tr;
public TermostatUI(Termostat tr) {
this.tr = tr;
initComponents();
}
/**
* Creates new form TermostatUI
*/
public TermostatUI() {
initComponents();
}
void afiseazaStare(String s){
this.textStare.setText(s);
}
void afiseazaTemperatura(String s){
this.textCurent.setText(s);
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
textMax = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
textMin = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
textCurent = new javax.swing.JTextField();
butonMaxMinus = new javax.swing.JButton();
butonMaxPlus = new javax.swing.JButton();
butonMinMinus = new javax.swing.JButton();
butonMinPlus = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
textStare = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Termperatura maxima:");
jLabel2.setText("Temperatura minima:");
jLabel3.setText("Temperatura curenta:");
butonMaxMinus.setText("-");
butonMaxMinus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butonMaxMinusActionPerformed(evt);
}
});
butonMaxPlus.setText("+");
butonMaxPlus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butonMaxPlusActionPerformed(evt);
}
});
butonMinMinus.setText("-");
butonMinPlus.setText("+");
jLabel4.setText("Stare:");
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(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textMax, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textMin)
.addComponent(textCurent)
.addComponent(textStare))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(butonMaxMinus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(butonMaxPlus))
.addGroup(layout.createSequentialGroup()
.addComponent(butonMinMinus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(butonMinPlus)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(butonMaxMinus)
.addComponent(butonMaxPlus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(butonMinMinus)
.addComponent(butonMinPlus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(textCurent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(textStare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(16, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void butonMaxMinusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonMaxMinusActionPerformed
int t = tr.citesteMax();
t = t - 1;
tr.setMax(t);
textMax.setText(""+t);
}//GEN-LAST:event_butonMaxMinusActionPerformed
private void butonMaxPlusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonMaxPlusActionPerformed
int t = tr.citesteMax();
t = t + 1;
tr.setMax(t);
textMax.setText(""+t);
}//GEN-LAST:event_butonMaxPlusActionPerformed
/**
* @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(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TermostatUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton butonMaxMinus;
private javax.swing.JButton butonMaxPlus;
private javax.swing.JButton butonMinMinus;
private javax.swing.JButton butonMinPlus;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField textCurent;
private javax.swing.JTextField textMax;
private javax.swing.JTextField textMin;
private javax.swing.JTextField textStare;
// End of variables declaration//GEN-END:variables
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author evo2
*/
public class TermostatUI extends javax.swing.JFrame {
Termostat tr;
public TermostatUI(Termostat tr) {
this.tr = tr;
initComponents();
}
/**
* Creates new form TermostatUI
*/
public TermostatUI() {
initComponents();
}
void afiseazaStare(String s){
this.textStare.setText(s);
}
void afiseazaTemperatura(String s){
this.textCurent.setText(s);
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
textMax = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
textMin = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
textCurent = new javax.swing.JTextField();
butonMaxMinus = new javax.swing.JButton();
butonMaxPlus = new javax.swing.JButton();
butonMinMinus = new javax.swing.JButton();
butonMinPlus = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
textStare = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Termperatura maxima:");
jLabel2.setText("Temperatura minima:");
jLabel3.setText("Temperatura curenta:");
butonMaxMinus.setText("-");
butonMaxMinus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butonMaxMinusActionPerformed(evt);
}
});
butonMaxPlus.setText("+");
butonMaxPlus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
butonMaxPlusActionPerformed(evt);
}
});
butonMinMinus.setText("-");
butonMinPlus.setText("+");
jLabel4.setText("Stare:");
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(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textMax, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textMin)
.addComponent(textCurent)
.addComponent(textStare))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(butonMaxMinus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(butonMaxPlus))
.addGroup(layout.createSequentialGroup()
.addComponent(butonMinMinus)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(butonMinPlus)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(butonMaxMinus)
.addComponent(butonMaxPlus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(butonMinMinus)
.addComponent(butonMinPlus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(textCurent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(textStare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(16, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void butonMaxMinusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonMaxMinusActionPerformed
int t = tr.citesteMax();
t = t - 1;
tr.setMax(t);
textMax.setText(""+t);
}//GEN-LAST:event_butonMaxMinusActionPerformed
private void butonMaxPlusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonMaxPlusActionPerformed
int t = tr.citesteMax();
t = t + 1;
tr.setMax(t);
textMax.setText(""+t);
}//GEN-LAST:event_butonMaxPlusActionPerformed
/**
* @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(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TermostatUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TermostatUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton butonMaxMinus;
private javax.swing.JButton butonMaxPlus;
private javax.swing.JButton butonMinMinus;
private javax.swing.JButton butonMinPlus;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField textCurent;
private javax.swing.JTextField textMax;
private javax.swing.JTextField textMin;
private javax.swing.JTextField textStare;
// End of variables declaration//GEN-END:variables
}