-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel.java
More file actions
96 lines (67 loc) · 2.18 KB
/
Panel.java
File metadata and controls
96 lines (67 loc) · 2.18 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
package swingworkerdone;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Panel extends JPanel{
private JLabel label = new JLabel("Numero de iteraciones: ");
private JTextField iteraciones = new JTextField(16);
private JButton boton = new JButton();
private JTextField pi1 = new JTextField(16); //campo de texto donde se muestra el valor aproximado por MonteCarlo
private JTextField pi2 = new JTextField(16); //campo de texto donde se muestra el valor aproximado por Gregory-Leibniz
private JProgressBar progresoMonteCarlo = new JProgressBar(0,100);
private JProgressBar progresoLeibniz= new JProgressBar(0,100);
public Panel(){
this.setLayout(new GridLayout(3,1,0,0));
setBotonComenzar();
JPanel fila1=new JPanel();
fila1.add(label);
fila1.add(iteraciones);
fila1.add(boton);
this.add(fila1);
JPanel fila2=new JPanel();
fila2.add(new JLabel("Montecarlo"));
progresoMonteCarlo.setStringPainted(true);
fila2.add(progresoMonteCarlo);
fila2.add(pi1);
this.add(fila2);
JPanel fila3=new JPanel();
fila3.add(new JLabel("Series GLe."));
progresoLeibniz.setStringPainted(true);
fila3.add(progresoLeibniz);
fila3.add(pi2);
this.add(fila3);
}
public void setBotonComenzar() {
boton.setText("Comenzar");
boton.setActionCommand("COMENZAR");
}
public static String comenzar() {
return "COMENZAR";
}
public void setControlador(ActionListener ctr){
//TODO: registrar ctr en los eventos del boton
boton.addActionListener(ctr);
boton.setActionCommand("COMENZAR");
}
public int getIteraciones(){
return Integer.parseInt(iteraciones.getText());
}
public void escribePI1(Double v) {
pi1.setText(v.toString());
}
public void escribePI2(Double v) {
pi2.setText(v.toString());
}
public void limpia1(){
pi1.setText("");
}
public void limpia2(){
pi2.setText("");
}
public void setProgresoMonteCarlo(int p){
//TODO: ejercicio 2: actualiza el valor de la barra de progreso
}
public void setProgresoLeibniz(int p){
//TODO: ejercicio 2: actualiza el valor de la barra de progreso
}
}