-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrafica.java
More file actions
46 lines (40 loc) · 1.34 KB
/
grafica.java
File metadata and controls
46 lines (40 loc) · 1.34 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
package regresion;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.*;
import static regresion.Regresion.*;
/**
*
* @author Hendrix
*/
public class grafica extends JDialog implements ActionListener, ItemListener {
public JButton graficar;
JToggleButton cambio;
public grafica(JFrame frame, String nombre){ //crear frame para el plano
graficar = new JButton("Graficar");
graficar.addActionListener(this);
cambio = new JToggleButton("Modo Oscuro(off)");
cambio.setBounds(10,10,140,40);
cambio.addItemListener(this);
add(cambio);
}
public void actionPerformed(ActionEvent e) {
//colocar grafica en el plano
if(e.getSource() == graficar){
cuadro.plano.paintLinealF(cuadro.plano.getGraphics(), b0, b1);
}
}
public void itemStateChanged(ItemEvent d){
//colocar modo oscuro
if(cambio.isSelected()){
cuadro.plano.setBackground(Color.black);
cambio.setText("Modo Oscuro (ON)");
}else{
cuadro.plano.setBackground(Color.white);
cambio.setText("Modo Oscuro (OFF)");
}
}
}