Ciao Andrea,
innanzitutto ti ringrazio per i consigli che sono stati molto utili.
Ti volevo chiedere un altro aiutino
ho creato una classe AUTOSAVE per salvare in automatico ogni tot secondi su un file txt.
non riesco a dirgli però di salcare quello che legge all'interno di un JcomboBox presente in un altra classe.
Ti ringrazio tantissimo
Ecco il codice
package sig.attrezzature;
import java.awt.Color;
import java.awt.Toolkit;
import javax.swing.JPanel;
import java.util.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;
import java.io.FileWriter;
import java.util.Scanner;
import javax.swing.JFrame;
/**
*
* @author Nicola Pedalino
*/
class JFrame_HOME extends javax.swing.JFrame {
/**
* Creates new form JFrame_HOME
*/
public JFrame_HOME() {
//metodo per autosave
Timer timer = new Timer();
timer.schedule(new Autosave(), 0, 5000);
//metodo per fullsize a tutto schermo
initComponents();
setExtendedState(getExtendedState() | JFrame_HOME.MAXIMIZED_BOTH);
}
/**
* 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() {
buttonGroupA = new javax.swing.ButtonGroup();
jLabel7 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jComboBoxDiametroA = new javax.swing.JComboBox<>();
jComboBoxRaggioMedioA = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
jLabel_LOGO = new javax.swing.JLabel();
jComboBoxMaterialeA = new javax.swing.JComboBox<>();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jComboBoxDiametroB = new javax.swing.JComboBox<>();
jComboBoxRaggioMedioB = new javax.swing.JComboBox<>();
jComboBoxMaterialeB = new javax.swing.JComboBox<>();
jLabelA = new javax.swing.JLabel();
jButtonSalvaA = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
jButtonSalvaB = new javax.swing.JButton();
jLabelB = new javax.swing.JLabel();
jButtoneExit = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SIG_GESTIONE_ATTREZZATURE ");
setBackground(new java.awt.Color(0, 89, 114));
setMaximumSize(new java.awt.Dimension(1500, 900));
setSize(new java.awt.Dimension(1500, 900));
jLabel7.setFont(new java.awt.Font("Albertus Medium", 2, 11)); // NOI18N
jLabel7.setForeground(new java.awt.Color(0, 51, 102));
jLabel7.setText("created by Nicola Pedalino");
jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel1.setForeground(new java.awt.Color(0, 51, 102));
jLabel1.setText("DIAMETRO");
jComboBoxDiametroA.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxDiametroA.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxDiametroA.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "Ø30", "Ø35", "Ø38", "Ø40", "Ø42", "Ø45", "Ø48", "Ø50", "Ø55", "Ø60", "Ø63.5", "Ø70", "Ø76.1", "Ø80", "Ø88.9", "Ø101.6", "Ø114.3", "Ø127" }));
jComboBoxDiametroA.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jComboBoxDiametroA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxDiametroAActionPerformed(evt);
}
});
jComboBoxRaggioMedioA.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxRaggioMedioA.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxRaggioMedioA.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "55", "60", "65", "75", "80", "81.5", "90", "100", "105", "115", "130", "190", "120", "150", "170", "230" }));
jComboBoxRaggioMedioA.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jLabel2.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 51, 102));
jLabel2.setText("CURVATUBI A - ELECT 102");
jLabel2.setMaximumSize(new java.awt.Dimension(230, 30));
jLabel2.setMinimumSize(new java.awt.Dimension(230, 30));
jLabel2.setPreferredSize(new java.awt.Dimension(230, 30));
jLabel_LOGO.setIcon(new javax.swing.ImageIcon("C:\\Users\\cesare\\Desktop\\logo sig_piccolo.jpg")); // NOI18N
jLabel_LOGO.setOpaque(true);
jComboBoxMaterialeA.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxMaterialeA.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxMaterialeA.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "ALLUMINATO", "AISI 304" }));
jComboBoxMaterialeA.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jComboBoxMaterialeA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxMaterialeAActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel4.setForeground(new java.awt.Color(0, 51, 102));
jLabel4.setText("MATERIALE");
jLabel5.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel5.setForeground(new java.awt.Color(0, 51, 102));
jLabel5.setText("RAGGIO MEDIO");
jLabel6.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel6.setForeground(new java.awt.Color(0, 51, 102));
jLabel6.setText("CURVATUBI B - ELECT 80");
jLabel6.setMaximumSize(new java.awt.Dimension(230, 30));
jLabel6.setMinimumSize(new java.awt.Dimension(230, 30));
jLabel6.setPreferredSize(new java.awt.Dimension(230, 30));
jComboBoxDiametroB.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxDiametroB.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxDiametroB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "Ø30", "Ø35", "Ø38", "Ø40", "Ø42", "Ø45", "Ø48", "Ø50", "Ø55", "Ø60", "Ø63.5", "Ø70", "Ø76.1", "Ø80", "Ø88.9", "Ø101.6", "Ø114.3", "Ø127" }));
jComboBoxDiametroB.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jComboBoxDiametroB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxDiametroBActionPerformed(evt);
}
});
jComboBoxRaggioMedioB.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxRaggioMedioB.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxRaggioMedioB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "55", "60", "65", "75", "80", "81.5", "90", "100", "105", "115", "130", "190", "120", "150", "170", "230" }));
jComboBoxRaggioMedioB.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jComboBoxMaterialeB.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jComboBoxMaterialeB.setForeground(new java.awt.Color(0, 51, 102));
jComboBoxMaterialeB.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---", "AISI 304", "ALLUMINATO" }));
jComboBoxMaterialeB.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jComboBoxMaterialeB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBoxMaterialeBActionPerformed(evt);
}
});
jLabelA.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
jLabelA.setForeground(new java.awt.Color(0, 102, 51));
jLabelA.setText("---------------------------------------");
jButtonSalvaA.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jButtonSalvaA.setText("SALVA");
jButtonSalvaA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSalvaAActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jLabel8.setForeground(new java.awt.Color(0, 51, 102));
jLabel8.setText(" ATTREZZATURA IN USO");
jButtonSalvaB.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jButtonSalvaB.setText("SALVA");
jButtonSalvaB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSalvaBActionPerformed(evt);
}
});
jLabelB.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
jLabelB.setForeground(new java.awt.Color(0, 102, 51));
jLabelB.setText("---------------------------------------");
jButtoneExit.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
jButtoneExit.setText("SALVA ED ESCI");
jButtoneExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtoneExitActionPerformed(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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel_LOGO, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBoxDiametroA, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(jLabel1)))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBoxRaggioMedioA, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(jComboBoxMaterialeA, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonSalvaA))
.addGroup(layout.createSequentialGroup()
.addGap(66, 66, 66)
.addComponent(jLabel4))))
.addGroup(layout.createSequentialGroup()
.addComponent(jComboBoxDiametroB, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(jComboBoxRaggioMedioB, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addComponent(jComboBoxMaterialeB, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButtonSalvaB)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabelB, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelA, javax.swing.GroupLayout.PREFERRED_SIZE, 432, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButtoneExit, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25, 25, 25))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxDiametroA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBoxRaggioMedioA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBoxMaterialeA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonSalvaA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabelA, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxDiametroB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBoxRaggioMedioB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBoxMaterialeB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonSalvaB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabelB, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 521, Short.MAX_VALUE)
.addComponent(jButtoneExit, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel_LOGO)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
);
setSize(new java.awt.Dimension(1516, 939));
setLocationRelativeTo(null);
}// </editor-fold>
private void jComboBoxDiametroAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jComboBoxMaterialeAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jComboBoxDiametroBActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jComboBoxMaterialeBActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtonSalvaAActionPerformed(java.awt.event.ActionEvent evt) {
// scittura A
String valueDiametroA = (String) jComboBoxDiametroA.getSelectedItem();
String valueRmA = (String)jComboBoxRaggioMedioA.getSelectedItem();
String DATA = new SimpleDateFormat("dd/MM/yyyy , ").format(Calendar.getInstance().getTime());
String ORA = new SimpleDateFormat(" HH:mm").format(Calendar.getInstance().getTime());
int jComboBoxDiametroA;
jLabelA.setText(valueDiametroA + " Rm " + valueRmA + "mm" + " " + DATA + " ore" + ORA);
try {
try (FileWriter myWriter = new FileWriter("C:\\Users\\cesare\\Documents\\NetBeansProjects\\SIG-ATTREZZATURE\\FileHandling\\databaseA.txt",true)) {
myWriter.write(valueDiametroA + " Rm " + valueRmA + "mm" + " " + DATA + " ore" + ORA );
myWriter.write(System.getProperty( "line.separator" ));
myWriter.flush();
myWriter.close();
}
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
private void jButtonSalvaBActionPerformed(java.awt.event.ActionEvent evt) {
// lettura da file
// scrittura B
String valueDiametroB=(String) jComboBoxDiametroB.getSelectedItem();
String valueRmB=(String)jComboBoxRaggioMedioB.getSelectedItem();
String DATA = new SimpleDateFormat("dd/MM/yyyy , ").format(Calendar.getInstance().getTime());
String ORA = new SimpleDateFormat(" HH:mm").format(Calendar.getInstance().getTime());
jLabelB.setText(valueDiametroB + " Rm " + valueRmB + "mm" + " " + DATA + " ore" + ORA);
try {
try (FileWriter myWriter = new FileWriter("C:\\Users\\cesare\\Documents\\NetBeansProjects\\SIG-ATTREZZATURE\\FileHandling\\databaseB.txt",true)) {
myWriter.write(valueDiametroB + " Rm " + valueRmB + "mm" + " " + DATA + " ore" + ORA);
myWriter.write(System.getProperty( "line.separator" ));
myWriter.flush();
myWriter.close();
}
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
private void jButtoneExitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @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(JFrame_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JFrame_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JFrame_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JFrame_HOME.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 JFrame_HOME().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroupA;
public javax.swing.JButton jButtonSalvaA;
public javax.swing.JButton jButtonSalvaB;
private javax.swing.JButton jButtoneExit;
public javax.swing.JComboBox<String> jComboBoxDiametroA;
public javax.swing.JComboBox<String> jComboBoxDiametroB;
public javax.swing.JComboBox<String> jComboBoxMaterialeA;
public javax.swing.JComboBox<String> jComboBoxMaterialeB;
public javax.swing.JComboBox<String> jComboBoxRaggioMedioA;
public javax.swing.JComboBox<String> jComboBoxRaggioMedioB;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
public javax.swing.JLabel jLabelA;
public javax.swing.JLabel jLabelB;
private javax.swing.JLabel jLabel_LOGO;
// End of variables declaration
boolean getValue() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
questo invece il codice della classe AUTOSAVE
package sig.attrezzature;
import java.io.FileWriter;
import java.io.IOException;
import java.util.TimerTask;
/**
*
* @author Nicola
*/
public class Autosave extends TimerTask{
public void run() {
try {
JFrame_HOME save = new JFrame_HOME();
try (FileWriter myWriter = new FileWriter("C:\\Users\\cesare\\Documents\\NetBeansProjects\\SIG-ATTREZZATURE\\FileHandling\\Autosave.txt")) {
myWriter.write( jComboBoxDiametroA);
//myWriter.write(System.getProperty( "line.separator" ));
//myWriter.flush();
//myWriter.close();
}
System.out.println("Successfully wrote to the file.");
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}