-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChooseStrategiesDialog.java
More file actions
147 lines (130 loc) · 4.92 KB
/
ChooseStrategiesDialog.java
File metadata and controls
147 lines (130 loc) · 4.92 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
137
138
139
140
141
142
143
144
145
146
147
package com.masim.ui;
import com.masim.core.CooperationStrategy;
import com.masim.utils.SimProcessState;
import com.masim.utils.SimulationFramework;
/*
* ChooseStrategiesDialog.java
*
* Created on 17 janv. 2014, 11:23:37
*/
/**
* Dialog to choose among all possible decision strategies.
* @author Sabri Ghazi
*/
public class ChooseStrategiesDialog extends javax.swing.JDialog {
/** Creates new form ChooseStrategiesDialog */
public ChooseStrategiesDialog(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() {
jLabel1 = new javax.swing.JLabel();
strategi_ListBox = new javax.swing.JComboBox();
cancel_btn = new javax.swing.JButton();
ok_btn = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Cooperation Strategy");
strategi_ListBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Greedy", "Naive", "Centralized", "NPD", "Q-learning","Voting" }));
cancel_btn.setText("Cancel");
cancel_btn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancel_btnActionPerformed(evt);
}
});
ok_btn.setText("Ok");
ok_btn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ok_btnActionPerformed(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()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(strategi_ListBox, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(45, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(261, Short.MAX_VALUE)
.addComponent(ok_btn)
.addGap(18, 18, 18)
.addComponent(cancel_btn)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(strategi_ListBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancel_btn)
.addComponent(ok_btn))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void cancel_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_btnActionPerformed
setVisible(false);
}//GEN-LAST:event_cancel_btnActionPerformed
private void ok_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok_btnActionPerformed
int i =strategi_ListBox.getSelectedIndex();
switch (i) {
case 0:
SimulationFramework.currentStrategy= CooperationStrategy.GREEDY;
break;
case 1:
SimulationFramework.currentStrategy= CooperationStrategy.NAIVE;
break;
case 2:
SimulationFramework.currentStrategy= CooperationStrategy.CENTRALIZED;
break;
case 3:
SimulationFramework.currentStrategy= CooperationStrategy.NEGOTIATION;
break;
case 4:
SimulationFramework.currentStrategy= CooperationStrategy.Qlearning;
break;
case 5:
SimulationFramework.currentStrategy= CooperationStrategy.Voting;
break;
default:
break;
}
setVisible(false);
}//GEN-LAST:event_ok_btnActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
ChooseStrategiesDialog dialog = new ChooseStrategiesDialog(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
private javax.swing.JButton cancel_btn;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton ok_btn;
private javax.swing.JComboBox strategi_ListBox;
// End of variables declaration//GEN-END:variables
}