-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJacobianDisplay.java
More file actions
136 lines (109 loc) · 3.55 KB
/
JacobianDisplay.java
File metadata and controls
136 lines (109 loc) · 3.55 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
133
134
135
136
package Jacobian;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import javax.swing.JButton;
/**
*
* @author Anthony Stange
*/
@SuppressWarnings("serial")
public class JacobianDisplay extends JPanel{
private JLabel lblHidden;
private JRadioButton rdbtnNoSortMethod, rdbtnSortMethod;
private GraphSort panel;
private GraphNoSort panel2;
private TextArea textArea;
/**
* Creates the App
* Generated by WindowBuilder
*/
public JacobianDisplay() {
setLayout(null);
setFocusable(true);
setPreferredSize(new Dimension(684, 623));
rdbtnNoSortMethod = new JRadioButton("No Sort Method");
rdbtnNoSortMethod.setSelected(true);
rdbtnNoSortMethod.setBounds(6, 34, 141, 23);
add(rdbtnNoSortMethod);
rdbtnSortMethod = new JRadioButton("Sort Method");
rdbtnSortMethod.setBounds(148, 34, 141, 23);
add(rdbtnSortMethod);
JLabel lblJacobianMethod = new JLabel("Jacobian Method");
lblJacobianMethod.setBounds(6, 6, 112, 16);
add(lblJacobianMethod);
panel = new GraphSort();
panel.setBounds(6, 97, 326, 244);
add(panel);
JLabel lblJacobianNoSort = new JLabel("Jacobian Graph Sort");
lblJacobianNoSort.setBounds(6, 69, 129, 16);
add(lblJacobianNoSort);
panel2 = new GraphNoSort();
panel2.setBounds(344, 97, 329, 244);
add(panel2);
JLabel lblJacobianGraphNo = new JLabel("Jacobian Graph No Sort");
lblJacobianGraphNo.setBounds(344, 69, 151, 16);
add(lblJacobianGraphNo);
JLabel lblValuesOfOffb = new JLabel("Vaues of Off(B)");
lblValuesOfOffb.setBounds(6, 353, 112, 16);
add(lblValuesOfOffb);
textArea = new TextArea();
textArea.setBounds(6, 381, 667, 231);
add(textArea);
JButton btnRun = new JButton("Run");
btnRun.setBounds(266, 33, 117, 29);
btnRun.addActionListener(new ButtonListener());
add(btnRun);
lblHidden = new JLabel("");
lblHidden.setBounds(266, 6, 341, 16);
add(lblHidden);
}
private class ButtonListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
//If both radio buttons are selected notify the user
if(rdbtnNoSortMethod.isSelected() && rdbtnSortMethod.isSelected()){
lblHidden.setText("Please only select one method to run");
}
//If both radio buttons aren't selected notify the user
else if(!rdbtnNoSortMethod.isSelected() && !rdbtnSortMethod.isSelected()){
lblHidden.setText("Please select a method to run");
}
//If the radio button for no sort is selected, then clear the text fields
//And run the no sort method
else if(rdbtnNoSortMethod.isSelected()){
textArea.setText("");
lblHidden.setText("");
panel2.run();
textArea.setText(panel2.getOffB());
repaint();
}
//If the radio button for sort is selected, then clear the text fields
//and run the sort method
else{
textArea.setText("");
lblHidden.setText("");
panel.run();
textArea.setText(panel.getOffB());
repaint();
}
}
}
/**
* Creates the frame that holds all the information
* @param args - command line arguments
*/
public static void main(String[] args) {
JFrame frame = new JFrame("Jacobian Graph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JacobianDisplay panel = new JacobianDisplay();
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}