SHOW:
|
|
- or go back to the newest paste.
1 | package topicsystem; | |
2 | ||
3 | /** | |
4 | * | |
5 | * @author Tsvetan | |
6 | */ | |
7 | public class TopicView extends javax.swing.JFrame { | |
8 | ||
9 | /** | |
10 | * Creates new form TopicView | |
11 | */ | |
12 | public TopicView() { | |
13 | initComponents(); | |
14 | } | |
15 | ||
16 | /** | |
17 | * This method is called from within the constructor to initialize the form. | |
18 | * WARNING: Do NOT modify this code. The content of this method is always | |
19 | * regenerated by the Form Editor. | |
20 | */ | |
21 | @SuppressWarnings("unchecked") | |
22 | // <editor-fold defaultstate="collapsed" desc="Generated Code"> | |
23 | private void initComponents() { | |
24 | ||
25 | jScrollPane1 = new javax.swing.JScrollPane(); | |
26 | jList1 = new javax.swing.JList(); | |
27 | jTextField1 = new javax.swing.JTextField(); | |
28 | jLabel1 = new javax.swing.JLabel(); | |
29 | jLabel2 = new javax.swing.JLabel(); | |
30 | jButton1 = new javax.swing.JButton(); | |
31 | jScrollPane2 = new javax.swing.JScrollPane(); | |
32 | jList2 = new javax.swing.JList(); | |
33 | jButton2 = new javax.swing.JButton(); | |
34 | jLabel3 = new javax.swing.JLabel(); | |
35 | ||
36 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
37 | setTitle("Search for speakers"); | |
38 | ||
39 | jList1.setModel(new javax.swing.AbstractListModel() { | |
40 | String[] strings = { "Travel", "Science", "Politics" }; | |
41 | public int getSize() { return strings.length; } | |
42 | public Object getElementAt(int i) { return strings[i]; } | |
43 | }); | |
44 | jList1.setToolTipText(""); | |
45 | jScrollPane1.setViewportView(jList1); | |
46 | ||
47 | jTextField1.addActionListener(new java.awt.event.ActionListener() { | |
48 | public void actionPerformed(java.awt.event.ActionEvent evt) { | |
49 | jTextField1ActionPerformed(evt); | |
50 | } | |
51 | }); | |
52 | ||
53 | jLabel1.setText("Category :"); | |
54 | ||
55 | jLabel2.setText("Date :"); | |
56 | ||
57 | jButton1.setText("Search"); | |
58 | jButton1.setToolTipText(""); | |
59 | jButton1.addActionListener(new java.awt.event.ActionListener() { | |
60 | public void actionPerformed(java.awt.event.ActionEvent evt) { | |
61 | jButton1ActionPerformed(evt); | |
62 | } | |
63 | }); | |
64 | ||
65 | jList2.setModel(new javax.swing.AbstractListModel() { | |
66 | String[] strings = { "Penka" }; | |
67 | public int getSize() { return strings.length; } | |
68 | public Object getElementAt(int i) { return strings[i]; } | |
69 | }); | |
70 | jScrollPane2.setViewportView(jList2); | |
71 | ||
72 | jButton2.setText("Book"); | |
73 | jButton2.setToolTipText("or not to book"); | |
74 | jButton2.addActionListener(new java.awt.event.ActionListener() { | |
75 | public void actionPerformed(java.awt.event.ActionEvent evt) { | |
76 | jButton2ActionPerformed(evt); | |
77 | } | |
78 | ||
79 | jLabel3.setText("Speakers available :"); | |
80 | ||
81 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
82 | getContentPane().setLayout(layout); | |
83 | layout.setHorizontalGroup( | |
84 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
85 | .addGroup(layout.createSequentialGroup() | |
86 | .addGap(26, 26, 26) | |
87 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
88 | .addComponent(jLabel3) | |
89 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) | |
90 | .addGroup(layout.createSequentialGroup() | |
91 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) | |
92 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
93 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
94 | .addGroup(layout.createSequentialGroup() | |
95 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) | |
96 | .addComponent(jScrollPane1) | |
97 | .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
98 | .addGap(52, 52, 52) | |
99 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
100 | .addComponent(jLabel2) | |
101 | .addGroup(layout.createSequentialGroup() | |
102 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) | |
103 | .addGap(74, 74, 74) | |
104 | .addComponent(jButton1)))))) | |
105 | .addContainerGap(24, Short.MAX_VALUE)) | |
106 | ); | |
107 | layout.setVerticalGroup( | |
108 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
109 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
110 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | |
111 | .addGroup(layout.createSequentialGroup() | |
112 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
113 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
114 | .addGroup(layout.createSequentialGroup() | |
115 | .addGap(7, 7, 7) | |
116 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
117 | .addComponent(jLabel1) | |
118 | .addComponent(jLabel2)) | |
119 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
120 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
121 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
122 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) | |
123 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE) | |
125 | .addComponent(jLabel3) | |
126 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
127 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
128 | .addGap(94, 94, 94)) | |
129 | ); | |
130 | ||
131 | pack(); | |
132 | }// </editor-fold> | |
133 | ||
134 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { | |
135 | // TODO add your handling code here: | |
136 | } | |
137 | ||
138 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { | |
139 | // TODO add your handling code here: | |
140 | } | |
141 | ||
142 | ||
143 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { | |
144 | int i = jList2.getLeadSelectionIndex(); | |
145 | if (i > -1) { | |
146 | bookSpeaker(jList2.strings[i]); | |
147 | } | |
148 | } | |
149 | ||
150 | /** | |
151 | * @param args the command line arguments | |
152 | */ | |
153 | public static void main(String args[]) { | |
154 | /* Set the Nimbus look and feel */ | |
155 | //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> | |
156 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. | |
157 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html | |
158 | */ | |
159 | try { | |
160 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { | |
161 | if ("Nimbus".equals(info.getName())) { | |
162 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); | |
163 | break; | |
164 | } | |
165 | } | |
166 | } catch (ClassNotFoundException ex) { | |
167 | java.util.logging.Logger.getLogger(TopicView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
168 | } catch (InstantiationException ex) { | |
169 | java.util.logging.Logger.getLogger(TopicView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
170 | } catch (IllegalAccessException ex) { | |
171 | java.util.logging.Logger.getLogger(TopicView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
172 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { | |
173 | java.util.logging.Logger.getLogger(TopicView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
174 | } | |
175 | //</editor-fold> | |
176 | ||
177 | /* Create and display the form */ | |
178 | java.awt.EventQueue.invokeLater(new Runnable() { | |
179 | public void run() { | |
180 | new TopicView().setVisible(true); | |
181 | } | |
182 | }); | |
183 | } | |
184 | ||
185 | // Variables declaration - do not modify | |
186 | private javax.swing.JButton jButton1; | |
187 | private javax.swing.JButton jButton2; | |
188 | private javax.swing.JLabel jLabel1; | |
189 | private javax.swing.JLabel jLabel2; | |
190 | private javax.swing.JLabel jLabel3; | |
191 | private javax.swing.JList jList1; | |
192 | private javax.swing.JList jList2; | |
193 | private javax.swing.JScrollPane jScrollPane1; | |
194 | private javax.swing.JScrollPane jScrollPane2; | |
195 | private javax.swing.JTextField jTextField1; | |
196 | // End of variables declaration |