-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrainingProgressDialog.java
More file actions
132 lines (109 loc) · 4.59 KB
/
TrainingProgressDialog.java
File metadata and controls
132 lines (109 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* TrainingProgressDialog.java
*
* Created on 12 déc. 2013, 14:19:55
*/
package com.masim.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*Show the progress of the trainning of the ANN Model.
* @author user
*/
public class TrainingProgressDialog extends javax.swing.JDialog {
/** Creates new form TrainingProgressDialog */
public TrainingProgressDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
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">//GEN-BEGIN:initComponents
private void initComponents() {
jProgressBar1 = new javax.swing.JProgressBar();
btnCancel = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
btnCancel.setText("Cancel");
jLabel1.setText("Training model please wait...");
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(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addComponent(btnCancel))
.addGroup(layout.createSequentialGroup()
.addGap(98, 98, 98)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(btnCancel)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* Used only for test.
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TrainingProgressDialog dialog = new TrainingProgressDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
public javax.swing.JButton btnCancel;
public javax.swing.JLabel jLabel1;
public javax.swing.JProgressBar jProgressBar1;
// End of variables declaration//GEN-END:variables
public static TrainingProgressDialog currentDialog=null;
public static boolean stop;
public static void createDialog(String ttl){
TrainingProgressDialog tProgressDiag= new TrainingProgressDialog(Console.current, false);
tProgressDiag.setTitle(ttl);
tProgressDiag.jProgressBar1.setValue(0);
stop=false;
currentDialog= tProgressDiag;
currentDialog.setVisible(true);
currentDialog.btnCancel.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
stop=true;
}
});
}
public static boolean Update(int val, int epoch, double error){
currentDialog.jLabel1.setText("Epoch # "+epoch+" Error="+error);
currentDialog.jProgressBar1.setValue(val);
return stop;
}
}