Employee management system

But it's a very simple system. And with a nicer Swing GUI, which is mostly created using NetBeans design tool. It's just a simple Swing/SQL/Persistence... exercise.
It stores and manges data (name, age, address, income) about employees.
Application functionalities are: display of all employees, showing only certain employees according to one of the criteria, change of employee data based on criteria, deleting an employee based on the criteria and entry of new employees.
Only a few classes are shown, because logic is mostly the same... 
And there is a bit enhanced Hibernate/HQL version.


Main.java

1:  package zaposlenisistem;  
2:    
3:  import java.awt.Color;  
4:  import javax.swing.UIManager;  
5:    
6:  /**  
7:   *  
8:   * @author djordje  
9:   */  
10:  public class Main {  
11:    public static void main(String[] args) {  
12:      try {   
13:        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");   
14:      } catch(Exception e){ }  
15:        
16:      MainFrame f = new MainFrame();  
17:      f.setSize(650,400);  
18:      f.getContentPane().setBackground(Color.WHITE);  
19:      f.setLocationRelativeTo(null);  
20:      f.setVisible(true);  
21:    }  
22:      
23:  }  

Zaposleni.java

1:  package zaposlenisistem;  
2:    
3:  import java.sql.Connection;  
4:  import java.sql.DriverManager;  
5:  import java.sql.PreparedStatement;  
6:  import java.sql.ResultSet;  
7:  import java.sql.SQLException;  
8:  import java.sql.Statement;  
9:    
10:  public class Zaposleni {  
11:      
12:    private int id;  
13:    private String ime;  
14:    private int godine;  
15:    private String adresa;  
16:    private int dohodak;  
17:      
18:    public int getId() {  
19:      return id;  
20:    }  
21:    public String getIme() {  
22:      return ime;  
23:    }  
24:    public int getGodine() {  
25:      return godine;  
26:    }  
27:    public String getAdresa() {  
28:      return adresa;  
29:    }  
30:    public int getDohodak() {  
31:      return dohodak;  
32:    }  
33:    public void setId( int id ) {  
34:      this.id = id;  
35:    }  
36:    public void setIme( String ime ) {  
37:      this.ime = ime;  
38:    }  
39:    public void setGodine( int godine ) {  
40:      this.godine = godine;  
41:    }  
42:    public void setAdresa( String adresa ) {  
43:      this.adresa = adresa;  
44:    }  
45:    public void setDohodak( int dohodak ) {  
46:      this.dohodak = dohodak;  
47:    }  
48:      
49:    public Zaposleni(){}  
50:    public Zaposleni(int id, String ime, int godine, String adresa, int dohodak) {  
51:      this.id = id;  
52:      this.ime = ime;  
53:      this.godine = godine;  
54:      this.adresa = adresa;  
55:      this.dohodak = dohodak;  
56:    }  
57:      
58:    // METODE ZA PRIKAZ ZAPOSLENIH  
59:      
60:    static String prikazSvihZaposlenih() throws ClassNotFoundException {  
61:        
62:      StringBuilder prikazSvih = new StringBuilder();  
63:      Class.forName("com.mysql.jdbc.Driver");  
64:        
65:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
66:        Statement st = conn.createStatement();  
67:        st.executeQuery("select * from zaposleni");  
68:        ResultSet rs = st.getResultSet();  
69:          
70:        while(rs.next()) {  
71:          prikazSvih.append(rs.getString("zaposleni_id"));  
72:          prikazSvih.append(" . ");  
73:          prikazSvih.append(rs.getString("ime"));  
74:          prikazSvih.append(" / ");  
75:          prikazSvih.append(rs.getString("godine"));  
76:          prikazSvih.append(" / ");  
77:          prikazSvih.append(rs.getString("adresa"));  
78:          prikazSvih.append(" / ");  
79:          prikazSvih.append(rs.getString("dohodak"));   
80:          prikazSvih.append("\n");  
81:        }  
82:        
83:          
84:      } catch (SQLException e) {  
85:        prikazSvih.append("GRESKA1 :");  
86:        prikazSvih.append(e.getMessage());  
87:      }  
88:        
89:      return prikazSvih.toString();  
90:    }  
91:      
92:    static String prikazNaOsnovuImena(String izbor) throws ClassNotFoundException {  
93:      Class.forName("com.mysql.jdbc.Driver");  
94:      StringBuilder rezultat = new StringBuilder();  
95:        
96:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
97:        Statement st = conn.createStatement();  
98:        st.executeQuery("select * from zaposleni where ime='" + izbor + "'");  
99:          
100:        ResultSet rs = st.getResultSet();  
101:        while(rs.next()) {  
102:          rezultat.append(rs.getString("zaposleni_id"));  
103:          rezultat.append(" . ");  
104:          rezultat.append(rs.getString("ime"));  
105:          rezultat.append(" / ");  
106:          rezultat.append(rs.getString("godine"));  
107:          rezultat.append(" / ");  
108:          rezultat.append(rs.getString("adresa"));  
109:          rezultat.append(" / ");  
110:          rezultat.append(rs.getString("dohodak"));   
111:          rezultat.append("\n");  
112:        }  
113:        
114:      }catch (SQLException e) {  
115:        rezultat.append("GRESKA! ");  
116:        rezultat.append(e.getMessage());  
117:      }  
118:      
119:      return rezultat.toString();  
120:    }  
121:      
122:    static String prikazNaOsnovuGodina(String izbor) throws ClassNotFoundException {  
123:      Class.forName("com.mysql.jdbc.Driver");  
124:      StringBuilder rezultat = new StringBuilder();  
125:        
126:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
127:        Statement st = conn.createStatement();  
128:        st.executeQuery("select * from zaposleni where godine='" + izbor + "'");   
129:    
130:        ResultSet rs = st.getResultSet();  
131:        while(rs.next()) {  
132:          rezultat.append(rs.getString("zaposleni_id"));  
133:          rezultat.append(" . ");  
134:          rezultat.append(rs.getString("ime"));  
135:          rezultat.append(" / ");  
136:          rezultat.append(rs.getString("godine"));  
137:          rezultat.append(" / ");  
138:          rezultat.append(rs.getString("adresa"));  
139:          rezultat.append(" / ");  
140:          rezultat.append(rs.getString("dohodak"));   
141:          rezultat.append("\n");  
142:        }        
143:        
144:      } catch (SQLException e) {  
145:        rezultat.append("GRESKA! ");  
146:        rezultat.append(e.getMessage());  
147:      }  
148:        
149:      return rezultat.toString();  
150:    }  
151:      
152:    static String prikazNaOsnovuAdrese(String izbor) throws ClassNotFoundException {  
153:      Class.forName("com.mysql.jdbc.Driver");  
154:      StringBuilder rezultat = new StringBuilder();  
155:        
156:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
157:        Statement st = conn.createStatement();  
158:        st.executeQuery("select * from zaposleni where adresa='" + izbor + "'");   
159:    
160:        ResultSet rs = st.getResultSet();  
161:        while(rs.next()) {  
162:          rezultat.append(rs.getString("zaposleni_id"));  
163:          rezultat.append(" . ");  
164:          rezultat.append(rs.getString("ime"));  
165:          rezultat.append(" / ");  
166:          rezultat.append(rs.getString("godine"));  
167:          rezultat.append(" / ");  
168:          rezultat.append(rs.getString("adresa"));  
169:          rezultat.append(" / ");  
170:          rezultat.append(rs.getString("dohodak"));   
171:          rezultat.append("\n");  
172:        }        
173:        
174:      } catch (SQLException e) {  
175:        rezultat.append("GRESKA! ");  
176:        rezultat.append(e.getMessage());  
177:      }  
178:        
179:      return rezultat.toString();  
180:    }    
181:      
182:    static String prikazNaOsnovuDohotka(String izbor) throws ClassNotFoundException {  
183:      Class.forName("com.mysql.jdbc.Driver");  
184:      StringBuilder rezultat = new StringBuilder();  
185:        
186:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
187:        Statement st = conn.createStatement();  
188:        st.executeQuery("select * from zaposleni where dohodak='" + izbor + "'");   
189:    
190:        ResultSet rs = st.getResultSet();  
191:        while(rs.next()) {  
192:          rezultat.append(rs.getString("zaposleni_id"));  
193:          rezultat.append(" . ");  
194:          rezultat.append(rs.getString("ime"));  
195:          rezultat.append(" / ");  
196:          rezultat.append(rs.getString("godine"));  
197:          rezultat.append(" / ");  
198:          rezultat.append(rs.getString("adresa"));  
199:          rezultat.append(" / ");  
200:          rezultat.append(rs.getString("dohodak"));   
201:          rezultat.append("\n");  
202:        }        
203:        
204:      } catch (SQLException e) {  
205:        rezultat.append("GRESKA! ");  
206:        rezultat.append(e.getMessage());  
207:      }  
208:        
209:      return rezultat.toString();  
210:    }    
211:      
212:    static String prikazNaOsnovuId(String id) throws ClassNotFoundException {  
213:      Class.forName("com.mysql.jdbc.Driver");  
214:      StringBuilder rezultat = new StringBuilder();  
215:        
216:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
217:        Statement st = conn.createStatement();  
218:        st.executeQuery("select * from zaposleni where zaposleni_id='" + id + "'");  
219:          
220:        ResultSet rs = st.getResultSet();  
221:        while(rs.next()) {  
222:          rezultat.append(rs.getString("zaposleni_id"));  
223:          rezultat.append(" . ");  
224:          rezultat.append(rs.getString("ime"));  
225:          rezultat.append(" / ");  
226:          rezultat.append(rs.getString("godine"));  
227:          rezultat.append(" / ");  
228:          rezultat.append(rs.getString("adresa"));  
229:          rezultat.append(" / ");  
230:          rezultat.append(rs.getString("dohodak"));   
231:          rezultat.append("\n");  
232:        }  
233:        
234:      }catch (SQLException e) {  
235:        rezultat.append("GRESKA! ");  
236:        rezultat.append(e.getMessage());  
237:      }  
238:      
239:      return rezultat.toString();  
240:    }  
241:      
242:    // METODA ZA UNOS ZAPOSLENIH  
243:      
244:    static String unosZaposlenog(String ime, String godine, String adresa, String dohodak) throws ClassNotFoundException {  
245:      Class.forName("com.mysql.jdbc.Driver");   
246:      String poruka = "Unos uspesno obavljen";  
247:        
248:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
249:        PreparedStatement st = conn.prepareStatement("insert into zaposleni (ime,godine,adresa,dohodak) values (?,?,?,?)");  
250:        st.setString(1, ime);  
251:        st.setString(2, godine);  
252:        st.setString(3, adresa);  
253:        st.setString(4, dohodak);  
254:        st.execute();   
255:              
256:      } catch (SQLException e) {  
257:        poruka = "GRESKA! " + e.getMessage();  
258:      }  
259:        
260:      return poruka;  
261:    }   
262:      
263:    // METODE ZA IZMENU ZAPOSLENIH  
264:      
265:    static void izmenaImena(String id, String ime) throws ClassNotFoundException {  
266:      Class.forName("com.mysql.jdbc.Driver");   
267:        
268:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
269:        PreparedStatement st = conn.prepareStatement("update zaposleni set ime=? where zaposleni_id=?");  
270:        st.setString(1, ime);  
271:        st.setString(2, id);  
272:        st.execute();   
273:              
274:      } catch (SQLException e) {  
275:        System.out.println("GRESKA! " + e.getMessage());  
276:      }  
277:        
278:    }  
279:      
280:    static void izmenaGodina(String id, String godine) throws ClassNotFoundException {  
281:      Class.forName("com.mysql.jdbc.Driver");   
282:        
283:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
284:        PreparedStatement st = conn.prepareStatement("update zaposleni set godine=? where zaposleni_id=?");  
285:        st.setString(1, godine);  
286:        st.setString(2, id);  
287:        st.execute();   
288:              
289:      } catch (SQLException e) {  
290:        System.out.println("GRESKA! " + e.getMessage());  
291:      }  
292:        
293:    }  
294:      
295:    static void izmenaAdrese(String id, String adresa) throws ClassNotFoundException {  
296:      Class.forName("com.mysql.jdbc.Driver");   
297:        
298:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
299:        PreparedStatement st = conn.prepareStatement("update zaposleni set adresa=? where zaposleni_id=?");  
300:        st.setString(1, adresa);  
301:        st.setString(2, id);  
302:        st.execute();   
303:              
304:      } catch (SQLException e) {  
305:        System.out.println("GRESKA! " + e.getMessage());  
306:      }  
307:        
308:    }  
309:      
310:    static void izmenaDohotka(String id, String dohodak) throws ClassNotFoundException {  
311:      Class.forName("com.mysql.jdbc.Driver");   
312:        
313:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
314:        PreparedStatement st = conn.prepareStatement("update zaposleni set dohodak=? where zaposleni_id=?");  
315:        st.setString(1, dohodak);  
316:        st.setString(2, id);  
317:        st.execute();   
318:              
319:      } catch (SQLException e) {  
320:        System.out.println("GRESKA! " + e.getMessage());  
321:      }  
322:        
323:    }  
324:      
325:    // METODE ZA BRISANJE ZAPOSLENIH  
326:      
327:    static void brisanjeNaOsnovuId(String id) throws ClassNotFoundException {  
328:      Class.forName("com.mysql.jdbc.Driver");   
329:        
330:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
331:        PreparedStatement st = conn.prepareStatement("delete from zaposleni where zaposleni_id=?");  
332:      
333:        st.setString(1, id);  
334:        st.execute();   
335:              
336:      } catch (SQLException e) {  
337:        System.out.println("GRESKA! " + e.getMessage());  
338:      }  
339:        
340:    }  
341:      
342:    static void brisanjeNaOsnovuImena(String ime) throws ClassNotFoundException {  
343:      Class.forName("com.mysql.jdbc.Driver");   
344:        
345:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
346:        PreparedStatement st = conn.prepareStatement("delete from zaposleni where ime=?");  
347:      
348:        st.setString(1, ime);  
349:        st.execute();   
350:              
351:      } catch (SQLException e) {  
352:        System.out.println("GRESKA! " + e.getMessage());  
353:      }  
354:        
355:    }  
356:      
357:    static void brisanjeNaOsnovuGodina(String godine) throws ClassNotFoundException {  
358:      Class.forName("com.mysql.jdbc.Driver");   
359:        
360:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
361:        PreparedStatement st = conn.prepareStatement("delete from zaposleni where godine=?");  
362:      
363:        st.setString(1, godine);  
364:        st.execute();   
365:              
366:      } catch (SQLException e) {  
367:        System.out.println("GRESKA! " + e.getMessage());  
368:      }  
369:        
370:    }  
371:      
372:    static void brisanjeNaOsnovuAdrese(String adresa) throws ClassNotFoundException {  
373:      Class.forName("com.mysql.jdbc.Driver");   
374:        
375:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
376:        PreparedStatement st = conn.prepareStatement("delete from zaposleni where adresa=?");  
377:      
378:        st.setString(1, adresa);  
379:        st.execute();   
380:              
381:      } catch (SQLException e) {  
382:        System.out.println("GRESKA! " + e.getMessage());  
383:      }  
384:        
385:    }  
386:      
387:    static void brisanjeNaOsnovuDohotka(String dohodak) throws ClassNotFoundException {  
388:      Class.forName("com.mysql.jdbc.Driver");   
389:        
390:      try( Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/zaposleniDB","root","");) {  
391:        PreparedStatement st = conn.prepareStatement("delete from zaposleni where dohodak=?");  
392:      
393:        st.setString(1, dohodak);  
394:        st.execute();   
395:              
396:      } catch (SQLException e) {  
397:        System.out.println("GRESKA! " + e.getMessage());  
398:      }  
399:        
400:    }  
401:      
402:      
403:      
404:      
405:      
406:      
407:  }  
408:    

MainFrame.java

1:  package zaposlenisistem;  
2:    
3:  import java.awt.Color;  
4:    
5:  /**  
6:   *  
7:   * @author djordje  
8:   */  
9:  public class MainFrame extends javax.swing.JFrame {  
10:    
11:    /**  
12:     * Creates new form MainFrame  
13:     */  
14:    public MainFrame() {  
15:      initComponents();  
16:    }  
17:      
18:    
19:    /**  
20:     * This method is called from within the constructor to initialize the form.  
21:     * WARNING: Do NOT modify this code. The content of this method is always  
22:     * regenerated by the Form Editor.  
23:     */  
24:    @SuppressWarnings("unchecked")  
25:    // <editor-fold defaultstate="collapsed" desc="Generated Code">               
26:    private void initComponents() {  
27:    
28:      jLabel1 = new javax.swing.JLabel();  
29:      prikazBtn = new javax.swing.JButton();  
30:      izmenaBtn = new javax.swing.JButton();  
31:      brisanjeBtn = new javax.swing.JButton();  
32:      unosBtn = new javax.swing.JButton();  
33:      jLabel3 = new javax.swing.JLabel();  
34:    
35:      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
36:      setBackground(javax.swing.UIManager.getDefaults().getColor("Nb.ScrollPane.Border.color"));  
37:      setPreferredSize(new java.awt.Dimension(650, 400));  
38:      setSize(new java.awt.Dimension(650, 400));  
39:    
40:      jLabel1.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N  
41:      jLabel1.setForeground(new java.awt.Color(0, 92, 92));  
42:      jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);  
43:      jLabel1.setText("Dobrodošli");  
44:    
45:      prikazBtn.setBackground(new java.awt.Color(0, 92, 92));  
46:      prikazBtn.setForeground(new java.awt.Color(255, 254, 255));  
47:      prikazBtn.setText("Prikaz zaposlenih");  
48:      prikazBtn.addActionListener(new java.awt.event.ActionListener() {  
49:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
50:          prikazBtnActionPerformed(evt);  
51:        }  
52:      });  
53:    
54:      izmenaBtn.setBackground(new java.awt.Color(0, 92, 92));  
55:      izmenaBtn.setForeground(new java.awt.Color(255, 254, 255));  
56:      izmenaBtn.setText("Izmena podataka");  
57:      izmenaBtn.addActionListener(new java.awt.event.ActionListener() {  
58:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
59:          izmenaBtnActionPerformed(evt);  
60:        }  
61:      });  
62:    
63:      brisanjeBtn.setBackground(new java.awt.Color(0, 92, 92));  
64:      brisanjeBtn.setForeground(new java.awt.Color(255, 254, 255));  
65:      brisanjeBtn.setText("Brisanje zaposlenih");  
66:      brisanjeBtn.addActionListener(new java.awt.event.ActionListener() {  
67:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
68:          brisanjeBtnActionPerformed(evt);  
69:        }  
70:      });  
71:    
72:      unosBtn.setBackground(new java.awt.Color(0, 92, 92));  
73:      unosBtn.setForeground(new java.awt.Color(255, 254, 255));  
74:      unosBtn.setText("Unos novih zaposlenih");  
75:      unosBtn.addActionListener(new java.awt.event.ActionListener() {  
76:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
77:          unosBtnActionPerformed(evt);  
78:        }  
79:      });  
80:    
81:      jLabel3.setFont(new java.awt.Font("Noto Sans", 0, 10)); // NOI18N  
82:      jLabel3.setForeground(new java.awt.Color(0, 92, 92));  
83:      jLabel3.setText(" Đorđe Gavrilović ITA16");  
84:    
85:      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
86:      getContentPane().setLayout(layout);  
87:      layout.setHorizontalGroup(  
88:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
89:        .addGroup(layout.createSequentialGroup()  
90:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
91:            .addGroup(layout.createSequentialGroup()  
92:              .addGap(278, 278, 278)  
93:              .addComponent(jLabel1))  
94:            .addGroup(layout.createSequentialGroup()  
95:              .addGap(202, 202, 202)  
96:              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
97:                .addComponent(jLabel3)  
98:                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)  
99:                  .addComponent(prikazBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)  
100:                  .addComponent(brisanjeBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)  
101:                  .addComponent(unosBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)  
102:                  .addComponent(izmenaBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))  
103:          .addContainerGap(207, Short.MAX_VALUE))  
104:      );  
105:      layout.setVerticalGroup(  
106:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
107:        .addGroup(layout.createSequentialGroup()  
108:          .addGap(34, 34, 34)  
109:          .addComponent(jLabel1)  
110:          .addGap(56, 56, 56)  
111:          .addComponent(prikazBtn)  
112:          .addGap(18, 18, 18)  
113:          .addComponent(izmenaBtn)  
114:          .addGap(18, 18, 18)  
115:          .addComponent(brisanjeBtn)  
116:          .addGap(18, 18, 18)  
117:          .addComponent(unosBtn)  
118:          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)  
119:          .addComponent(jLabel3)  
120:          .addGap(45, 45, 45))  
121:      );  
122:    
123:      pack();  
124:    }// </editor-fold>              
125:    
126:    private void prikazBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
127:      PrikazFrame pf = new PrikazFrame();  
128:      pf.setSize(900, 650);  
129:      pf.getContentPane().setBackground(Color.WHITE);  
130:      pf.setLocationRelativeTo(null);  
131:      pf.setVisible(true);  
132:        
133:      this.dispose();  
134:    }                       
135:    
136:    private void unosBtnActionPerformed(java.awt.event.ActionEvent evt) {                      
137:      UnosFrame uf = new UnosFrame();  
138:      uf.setSize(900, 650);  
139:      uf.getContentPane().setBackground(Color.WHITE);  
140:      uf.setLocationRelativeTo(null);  
141:      uf.setVisible(true);  
142:        
143:      this.dispose();  
144:    }                      
145:    
146:    private void izmenaBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
147:      IzmenaFrame izf = new IzmenaFrame();  
148:      izf.setSize(900,650);  
149:      izf.getContentPane().setBackground(Color.WHITE);  
150:      izf.setLocationRelativeTo(null);  
151:      izf.setVisible(true);  
152:        
153:      this.dispose();  
154:    }                       
155:    
156:    private void brisanjeBtnActionPerformed(java.awt.event.ActionEvent evt) {                        
157:      BrisanjeFrame bf = new BrisanjeFrame();  
158:      bf.setSize(900,650);  
159:      bf.getContentPane().setBackground(Color.WHITE);  
160:      bf.setLocationRelativeTo(null);  
161:      bf.setVisible(true);  
162:        
163:      this.dispose();  
164:    }                        
165:    
166:    /**  
167:     * @param args the command line arguments  
168:     */  
169:    public static void main(String args[]) {  
170:      /* Set the Nimbus look and feel */  
171:      //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">  
172:      /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.  
173:       * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html   
174:       */  
175:      try {  
176:        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {  
177:          if ("Nimbus".equals(info.getName())) {  
178:            javax.swing.UIManager.setLookAndFeel(info.getClassName());  
179:            break;  
180:          }  
181:        }  
182:      } catch (ClassNotFoundException ex) {  
183:        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
184:      } catch (InstantiationException ex) {  
185:        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
186:      } catch (IllegalAccessException ex) {  
187:        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
188:      } catch (javax.swing.UnsupportedLookAndFeelException ex) {  
189:        java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
190:      }  
191:      //</editor-fold>  
192:    
193:      /* Create and display the form */  
194:      java.awt.EventQueue.invokeLater(new Runnable() {  
195:        public void run() {  
196:          new MainFrame().setVisible(true);  
197:        }  
198:      });  
199:    }  
200:    
201:    // Variables declaration - do not modify             
202:    private javax.swing.JButton brisanjeBtn;  
203:    private javax.swing.JButton izmenaBtn;  
204:    private javax.swing.JLabel jLabel1;  
205:    private javax.swing.JLabel jLabel3;  
206:    private javax.swing.JButton prikazBtn;  
207:    private javax.swing.JButton unosBtn;  
208:    // End of variables declaration            
209:  }  
210:    

PrikazFrame.java

1:    
2:  package zaposlenisistem;  
3:    
4:  import java.awt.Color;  
5:  import java.util.logging.Level;  
6:  import java.util.logging.Logger;  
7:    
8:  /**  
9:   *  
10:   * @author djordje  
11:   */  
12:  public class PrikazFrame extends javax.swing.JFrame {  
13:    
14:    /**  
15:     * Creates new form PrikazFrame  
16:     */  
17:    public PrikazFrame() {  
18:      initComponents();  
19:    }  
20:    
21:    /**  
22:     * This method is called from within the constructor to initialize the form.  
23:     * WARNING: Do NOT modify this code. The content of this method is always  
24:     * regenerated by the Form Editor.  
25:     */  
26:    @SuppressWarnings("unchecked")  
27:    // <editor-fold defaultstate="collapsed" desc="Generated Code">               
28:    private void initComponents() {  
29:    
30:      jScrollPane1 = new javax.swing.JScrollPane();  
31:      prikazTa = new javax.swing.JTextArea();  
32:      povratakBtn = new javax.swing.JButton();  
33:      imeLabel = new javax.swing.JLabel();  
34:      godineLabel = new javax.swing.JLabel();  
35:      adresaLabel = new javax.swing.JLabel();  
36:      dohodakLabel = new javax.swing.JLabel();  
37:      imeTf = new javax.swing.JTextField();  
38:      godineTf = new javax.swing.JTextField();  
39:      adresaTf = new javax.swing.JTextField();  
40:      dohodakTf = new javax.swing.JTextField();  
41:      imeBtn = new javax.swing.JButton();  
42:      godineBtn = new javax.swing.JButton();  
43:      adresaBtn = new javax.swing.JButton();  
44:      dohodakBtn = new javax.swing.JButton();  
45:      sviBtn = new javax.swing.JButton();  
46:    
47:      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
48:      setTitle("PRIKAZ ZAPOSLENIH");  
49:      addWindowListener(new java.awt.event.WindowAdapter() {  
50:        public void windowOpened(java.awt.event.WindowEvent evt) {  
51:          formWindowOpened(evt);  
52:        }  
53:      });  
54:    
55:      jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));  
56:    
57:      prikazTa.setEditable(false);  
58:      prikazTa.setBackground(new java.awt.Color(223, 222, 223));  
59:      prikazTa.setColumns(20);  
60:      prikazTa.setForeground(new java.awt.Color(0, 92, 92));  
61:      prikazTa.setRows(5);  
62:      prikazTa.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Zaposleni:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12), new java.awt.Color(0, 92, 92))); // NOI18N  
63:      jScrollPane1.setViewportView(prikazTa);  
64:    
65:      povratakBtn.setBackground(new java.awt.Color(0, 93, 92));  
66:      povratakBtn.setForeground(new java.awt.Color(255, 254, 255));  
67:      povratakBtn.setText("Povratak u Meni");  
68:      povratakBtn.addActionListener(new java.awt.event.ActionListener() {  
69:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
70:          povratakBtnActionPerformed(evt);  
71:        }  
72:      });  
73:    
74:      imeLabel.setForeground(new java.awt.Color(0, 92, 92));  
75:      imeLabel.setText("Ime");  
76:    
77:      godineLabel.setForeground(new java.awt.Color(0, 92, 92));  
78:      godineLabel.setText("Godine");  
79:    
80:      adresaLabel.setForeground(new java.awt.Color(0, 92, 92));  
81:      adresaLabel.setText("Adresa");  
82:    
83:      dohodakLabel.setForeground(new java.awt.Color(0, 92, 92));  
84:      dohodakLabel.setText("Dohodak");  
85:    
86:      imeTf.setForeground(new java.awt.Color(0, 93, 92));  
87:    
88:      godineTf.setForeground(new java.awt.Color(0, 93, 92));  
89:    
90:      adresaTf.setForeground(new java.awt.Color(0, 93, 92));  
91:    
92:      dohodakTf.setForeground(new java.awt.Color(0, 93, 92));  
93:    
94:      imeBtn.setBackground(new java.awt.Color(0, 93, 92));  
95:      imeBtn.setForeground(new java.awt.Color(255, 254, 255));  
96:      imeBtn.setText("Prikaži");  
97:      imeBtn.addActionListener(new java.awt.event.ActionListener() {  
98:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
99:          imeBtnActionPerformed(evt);  
100:        }  
101:      });  
102:    
103:      godineBtn.setBackground(new java.awt.Color(0, 93, 92));  
104:      godineBtn.setForeground(new java.awt.Color(255, 254, 255));  
105:      godineBtn.setText("Prikaži");  
106:      godineBtn.addActionListener(new java.awt.event.ActionListener() {  
107:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
108:          godineBtnActionPerformed(evt);  
109:        }  
110:      });  
111:    
112:      adresaBtn.setBackground(new java.awt.Color(0, 93, 92));  
113:      adresaBtn.setForeground(new java.awt.Color(255, 254, 255));  
114:      adresaBtn.setText("Prikaži");  
115:      adresaBtn.addActionListener(new java.awt.event.ActionListener() {  
116:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
117:          adresaBtnActionPerformed(evt);  
118:        }  
119:      });  
120:    
121:      dohodakBtn.setBackground(new java.awt.Color(0, 93, 92));  
122:      dohodakBtn.setForeground(new java.awt.Color(255, 254, 255));  
123:      dohodakBtn.setText("Prikaži");  
124:      dohodakBtn.addActionListener(new java.awt.event.ActionListener() {  
125:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
126:          dohodakBtnActionPerformed(evt);  
127:        }  
128:      });  
129:    
130:      sviBtn.setBackground(new java.awt.Color(0, 93, 92));  
131:      sviBtn.setForeground(new java.awt.Color(255, 254, 255));  
132:      sviBtn.setText("Svi zaposleni");  
133:      sviBtn.addActionListener(new java.awt.event.ActionListener() {  
134:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
135:          sviBtnActionPerformed(evt);  
136:        }  
137:      });  
138:    
139:      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
140:      getContentPane().setLayout(layout);  
141:      layout.setHorizontalGroup(  
142:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
143:        .addGroup(layout.createSequentialGroup()  
144:          .addContainerGap()  
145:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
146:            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 876, Short.MAX_VALUE)  
147:            .addGroup(layout.createSequentialGroup()  
148:              .addGap(18, 18, 18)  
149:              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
150:                .addGroup(layout.createSequentialGroup()  
151:                  .addComponent(sviBtn)  
152:                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)  
153:                  .addComponent(povratakBtn))  
154:                .addGroup(layout.createSequentialGroup()  
155:                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
156:                    .addComponent(imeLabel)  
157:                    .addComponent(godineLabel)  
158:                    .addComponent(adresaLabel)  
159:                    .addComponent(dohodakLabel))  
160:                  .addGap(21, 21, 21)  
161:                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)  
162:                    .addComponent(imeTf)  
163:                    .addComponent(godineTf)  
164:                    .addComponent(adresaTf)  
165:                    .addComponent(dohodakTf, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE))  
166:                  .addGap(39, 39, 39)  
167:                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
168:                    .addComponent(imeBtn)  
169:                    .addComponent(godineBtn)  
170:                    .addComponent(adresaBtn)  
171:                    .addComponent(dohodakBtn))  
172:                  .addGap(0, 0, Short.MAX_VALUE)))))  
173:          .addContainerGap())  
174:      );  
175:      layout.setVerticalGroup(  
176:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
177:        .addGroup(layout.createSequentialGroup()  
178:          .addGap(22, 22, 22)  
179:          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)  
180:          .addGap(34, 34, 34)  
181:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
182:            .addComponent(imeLabel)  
183:            .addComponent(imeTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
184:            .addComponent(imeBtn))  
185:          .addGap(16, 16, 16)  
186:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
187:            .addComponent(godineLabel)  
188:            .addComponent(godineTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
189:            .addComponent(godineBtn))  
190:          .addGap(16, 16, 16)  
191:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
192:            .addComponent(adresaLabel)  
193:            .addComponent(adresaTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
194:            .addComponent(adresaBtn))  
195:          .addGap(16, 16, 16)  
196:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
197:            .addComponent(dohodakLabel)  
198:            .addComponent(dohodakTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
199:            .addComponent(dohodakBtn))  
200:          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)  
201:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
202:            .addComponent(povratakBtn)  
203:            .addComponent(sviBtn))  
204:          .addGap(21, 21, 21))  
205:      );  
206:    
207:      pack();  
208:    }// </editor-fold>              
209:    
210:    private void povratakBtnActionPerformed(java.awt.event.ActionEvent evt) {                        
211:      MainFrame f = new MainFrame();  
212:      f.setLocationRelativeTo(null);  
213:      f.getContentPane().setBackground(Color.WHITE);  
214:      f.setVisible(true);  
215:    
216:      this.dispose();  
217:    }                        
218:    
219:    private void formWindowOpened(java.awt.event.WindowEvent evt) {                   
220:      try {  
221:        prikazTa.setText(Zaposleni.prikazSvihZaposlenih());  
222:      } catch (ClassNotFoundException ex) {  
223:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
224:      }  
225:    }                   
226:    
227:    private void imeBtnActionPerformed(java.awt.event.ActionEvent evt) {                      
228:      String izbor = imeTf.getText();  
229:      try {  
230:        prikazTa.setText(Zaposleni.prikazNaOsnovuImena(izbor));  
231:        imeTf.setText("");  
232:      } catch (ClassNotFoundException ex) {  
233:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
234:      }  
235:    }                     
236:    
237:    private void sviBtnActionPerformed(java.awt.event.ActionEvent evt) {                      
238:      try {  
239:        prikazTa.setText(Zaposleni.prikazSvihZaposlenih());  
240:      } catch (ClassNotFoundException ex) {  
241:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
242:      }  
243:    }                     
244:    
245:    private void godineBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
246:      String izbor = godineTf.getText();  
247:      try {  
248:        prikazTa.setText(Zaposleni.prikazNaOsnovuGodina(izbor));  
249:        godineTf.setText("");  
250:      } catch (ClassNotFoundException ex) {  
251:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
252:      }      
253:    }                       
254:    
255:    private void adresaBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
256:      String izbor = adresaTf.getText();  
257:      try {  
258:        prikazTa.setText(Zaposleni.prikazNaOsnovuAdrese(izbor));  
259:        adresaTf.setText("");  
260:      } catch (ClassNotFoundException ex) {  
261:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
262:      }  
263:    }                       
264:    
265:    private void dohodakBtnActionPerformed(java.awt.event.ActionEvent evt) {                        
266:      String izbor = dohodakTf.getText();  
267:      try {  
268:        prikazTa.setText(Zaposleni.prikazNaOsnovuDohotka(izbor));  
269:        dohodakTf.setText("");  
270:      } catch (ClassNotFoundException ex) {  
271:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
272:      }  
273:    }                       
274:    
275:    /**  
276:     * @param args the command line arguments  
277:     */  
278:    public static void main(String args[]) {  
279:      /* Set the Nimbus look and feel */  
280:      //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">  
281:      /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.  
282:       * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html   
283:       */  
284:      try {  
285:        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {  
286:          if ("Nimbus".equals(info.getName())) {  
287:            javax.swing.UIManager.setLookAndFeel(info.getClassName());  
288:            break;  
289:          }  
290:        }  
291:      } catch (ClassNotFoundException ex) {  
292:        java.util.logging.Logger.getLogger(PrikazFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
293:      } catch (InstantiationException ex) {  
294:        java.util.logging.Logger.getLogger(PrikazFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
295:      } catch (IllegalAccessException ex) {  
296:        java.util.logging.Logger.getLogger(PrikazFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
297:      } catch (javax.swing.UnsupportedLookAndFeelException ex) {  
298:        java.util.logging.Logger.getLogger(PrikazFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
299:      }  
300:      //</editor-fold>  
301:    
302:      /* Create and display the form */  
303:      java.awt.EventQueue.invokeLater(new Runnable() {  
304:        public void run() {  
305:          new PrikazFrame().setVisible(true);  
306:        }  
307:      });  
308:    }  
309:      
310:      
311:    
312:    // Variables declaration - do not modify             
313:    private javax.swing.JButton adresaBtn;  
314:    private javax.swing.JLabel adresaLabel;  
315:    private javax.swing.JTextField adresaTf;  
316:    private javax.swing.JButton dohodakBtn;  
317:    private javax.swing.JLabel dohodakLabel;  
318:    private javax.swing.JTextField dohodakTf;  
319:    private javax.swing.JButton godineBtn;  
320:    private javax.swing.JLabel godineLabel;  
321:    private javax.swing.JTextField godineTf;  
322:    private javax.swing.JButton imeBtn;  
323:    private javax.swing.JLabel imeLabel;  
324:    private javax.swing.JTextField imeTf;  
325:    private javax.swing.JScrollPane jScrollPane1;  
326:    private javax.swing.JButton povratakBtn;  
327:    private javax.swing.JTextArea prikazTa;  
328:    private javax.swing.JButton sviBtn;  
329:    // End of variables declaration            
330:  }  
331:    

IzmenaFrame.java

1:    
2:  package zaposlenisistem;  
3:    
4:  import java.awt.Color;  
5:  import java.util.logging.Level;  
6:  import java.util.logging.Logger;  
7:    
8:  /**  
9:   *  
10:   * @author djordje  
11:   */  
12:  public class IzmenaFrame extends javax.swing.JFrame {  
13:    
14:    /**  
15:     * Creates new form IzmenaFrame  
16:     */  
17:    public IzmenaFrame() {  
18:      initComponents();  
19:    }  
20:    
21:    /**  
22:     * This method is called from within the constructor to initialize the form.  
23:     * WARNING: Do NOT modify this code. The content of this method is always  
24:     * regenerated by the Form Editor.  
25:     */  
26:    @SuppressWarnings("unchecked")  
27:    // <editor-fold defaultstate="collapsed" desc="Generated Code">               
28:    private void initComponents() {  
29:    
30:      jButton1 = new javax.swing.JButton();  
31:      jScrollPane1 = new javax.swing.JScrollPane();  
32:      prikazTa = new javax.swing.JTextArea();  
33:      jLabel1 = new javax.swing.JLabel();  
34:      rbTf = new javax.swing.JTextField();  
35:      jLabel2 = new javax.swing.JLabel();  
36:      jLabel3 = new javax.swing.JLabel();  
37:      jLabel4 = new javax.swing.JLabel();  
38:      jLabel5 = new javax.swing.JLabel();  
39:      jButton2 = new javax.swing.JButton();  
40:      imeTf = new javax.swing.JTextField();  
41:      godineTf = new javax.swing.JTextField();  
42:      adresaTf = new javax.swing.JTextField();  
43:      dohodakTf = new javax.swing.JTextField();  
44:      imeBtn = new javax.swing.JButton();  
45:      godineBtn = new javax.swing.JButton();  
46:      adresaBtn = new javax.swing.JButton();  
47:      dohodakBtn = new javax.swing.JButton();  
48:    
49:      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);  
50:      setTitle("IZMENA PODATAKA ZAPOSLENIH");  
51:      addWindowListener(new java.awt.event.WindowAdapter() {  
52:        public void windowOpened(java.awt.event.WindowEvent evt) {  
53:          formWindowOpened(evt);  
54:        }  
55:      });  
56:    
57:      jButton1.setBackground(new java.awt.Color(0, 93, 92));  
58:      jButton1.setForeground(new java.awt.Color(255, 254, 255));  
59:      jButton1.setText("Povratak u Meni");  
60:      jButton1.addActionListener(new java.awt.event.ActionListener() {  
61:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
62:          jButton1ActionPerformed(evt);  
63:        }  
64:      });  
65:    
66:      jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));  
67:    
68:      prikazTa.setEditable(false);  
69:      prikazTa.setBackground(new java.awt.Color(223, 222, 223));  
70:      prikazTa.setColumns(20);  
71:      prikazTa.setForeground(new java.awt.Color(0, 93, 92));  
72:      prikazTa.setRows(5);  
73:      prikazTa.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Zaposleni:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", 0, 12), new java.awt.Color(0, 93, 92))); // NOI18N  
74:      jScrollPane1.setViewportView(prikazTa);  
75:    
76:      jLabel1.setForeground(new java.awt.Color(0, 93, 92));  
77:      jLabel1.setText("Redni broj zaposlenog");  
78:    
79:      rbTf.setForeground(new java.awt.Color(0, 93, 92));  
80:    
81:      jLabel2.setForeground(new java.awt.Color(0, 93, 92));  
82:      jLabel2.setText("Ime i prezime");  
83:    
84:      jLabel3.setForeground(new java.awt.Color(0, 93, 92));  
85:      jLabel3.setText("Godine");  
86:    
87:      jLabel4.setForeground(new java.awt.Color(0, 93, 92));  
88:      jLabel4.setText("Adresa");  
89:    
90:      jLabel5.setForeground(new java.awt.Color(0, 93, 92));  
91:      jLabel5.setText("Dohodak");  
92:    
93:      jButton2.setBackground(new java.awt.Color(0, 93, 92));  
94:      jButton2.setForeground(new java.awt.Color(255, 254, 255));  
95:      jButton2.setText("Prikaz svih zaposlenih");  
96:      jButton2.addActionListener(new java.awt.event.ActionListener() {  
97:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
98:          jButton2ActionPerformed(evt);  
99:        }  
100:      });  
101:    
102:      imeTf.setForeground(new java.awt.Color(0, 93, 92));  
103:    
104:      godineTf.setForeground(new java.awt.Color(0, 93, 92));  
105:    
106:      adresaTf.setForeground(new java.awt.Color(0, 93, 92));  
107:    
108:      dohodakTf.setForeground(new java.awt.Color(0, 93, 92));  
109:    
110:      imeBtn.setBackground(new java.awt.Color(0, 93, 92));  
111:      imeBtn.setForeground(new java.awt.Color(255, 254, 255));  
112:      imeBtn.setText("Izmeni");  
113:      imeBtn.addActionListener(new java.awt.event.ActionListener() {  
114:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
115:          imeBtnActionPerformed(evt);  
116:        }  
117:      });  
118:    
119:      godineBtn.setBackground(new java.awt.Color(0, 93, 92));  
120:      godineBtn.setForeground(new java.awt.Color(255, 254, 255));  
121:      godineBtn.setText("Izmeni");  
122:      godineBtn.addActionListener(new java.awt.event.ActionListener() {  
123:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
124:          godineBtnActionPerformed(evt);  
125:        }  
126:      });  
127:    
128:      adresaBtn.setBackground(new java.awt.Color(0, 93, 92));  
129:      adresaBtn.setForeground(new java.awt.Color(255, 254, 255));  
130:      adresaBtn.setText("Izmeni");  
131:      adresaBtn.addActionListener(new java.awt.event.ActionListener() {  
132:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
133:          adresaBtnActionPerformed(evt);  
134:        }  
135:      });  
136:    
137:      dohodakBtn.setBackground(new java.awt.Color(0, 93, 92));  
138:      dohodakBtn.setForeground(new java.awt.Color(255, 254, 255));  
139:      dohodakBtn.setText("Izmeni");  
140:      dohodakBtn.addActionListener(new java.awt.event.ActionListener() {  
141:        public void actionPerformed(java.awt.event.ActionEvent evt) {  
142:          dohodakBtnActionPerformed(evt);  
143:        }  
144:      });  
145:    
146:      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());  
147:      getContentPane().setLayout(layout);  
148:      layout.setHorizontalGroup(  
149:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
150:        .addGroup(layout.createSequentialGroup()  
151:          .addContainerGap()  
152:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
153:            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()  
154:              .addGap(0, 0, Short.MAX_VALUE)  
155:              .addComponent(jButton1))  
156:            .addComponent(jScrollPane1))  
157:          .addContainerGap())  
158:        .addGroup(layout.createSequentialGroup()  
159:          .addGap(35, 35, 35)  
160:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
161:            .addComponent(jButton2)  
162:            .addGroup(layout.createSequentialGroup()  
163:              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
164:                .addComponent(jLabel1)  
165:                .addComponent(jLabel2)  
166:                .addComponent(jLabel3)  
167:                .addComponent(jLabel4)  
168:                .addComponent(jLabel5))  
169:              .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)  
170:              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)  
171:                .addComponent(rbTf, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)  
172:                .addComponent(imeTf)  
173:                .addComponent(godineTf)  
174:                .addComponent(adresaTf)  
175:                .addComponent(dohodakTf, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))  
176:              .addGap(50, 50, 50)  
177:              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
178:                .addComponent(imeBtn)  
179:                .addComponent(godineBtn)  
180:                .addComponent(adresaBtn)  
181:                .addComponent(dohodakBtn))))  
182:          .addContainerGap(330, Short.MAX_VALUE))  
183:      );  
184:      layout.setVerticalGroup(  
185:        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)  
186:        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()  
187:          .addGap(22, 22, 22)  
188:          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)  
189:          .addGap(29, 29, 29)  
190:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
191:            .addComponent(jLabel1)  
192:            .addComponent(rbTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))  
193:          .addGap(21, 21, 21)  
194:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
195:            .addComponent(jLabel2)  
196:            .addComponent(imeTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
197:            .addComponent(imeBtn))  
198:          .addGap(16, 16, 16)  
199:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
200:            .addComponent(jLabel3)  
201:            .addComponent(godineTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
202:            .addComponent(godineBtn))  
203:          .addGap(16, 16, 16)  
204:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
205:            .addComponent(jLabel4)  
206:            .addComponent(adresaTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
207:            .addComponent(adresaBtn))  
208:          .addGap(16, 16, 16)  
209:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
210:            .addComponent(jLabel5)  
211:            .addComponent(dohodakTf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)  
212:            .addComponent(dohodakBtn))  
213:          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)  
214:          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)  
215:            .addComponent(jButton1)  
216:            .addComponent(jButton2))  
217:          .addGap(21, 21, 21))  
218:      );  
219:    
220:      pack();  
221:    }// </editor-fold>              
222:    
223:    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                       
224:      MainFrame f = new MainFrame();  
225:      f.getContentPane().setBackground(Color.WHITE);  
226:      f.setLocationRelativeTo(null);  
227:      f.setVisible(true);  
228:        
229:      this.dispose();  
230:    }                      
231:    
232:    private void formWindowOpened(java.awt.event.WindowEvent evt) {                   
233:      try {  
234:        prikazTa.setText(Zaposleni.prikazSvihZaposlenih());  
235:      } catch (ClassNotFoundException ex) {  
236:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
237:      }  
238:    }                   
239:    
240:    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                       
241:      try {  
242:        prikazTa.setText(Zaposleni.prikazSvihZaposlenih());  
243:      } catch (ClassNotFoundException ex) {  
244:        Logger.getLogger(PrikazFrame.class.getName()).log(Level.SEVERE, null, ex);  
245:      }  
246:    }                      
247:    
248:    private void imeBtnActionPerformed(java.awt.event.ActionEvent evt) {                      
249:      String id = rbTf.getText();  
250:      String ime = imeTf.getText();  
251:      try {  
252:        Zaposleni.izmenaImena(id, ime);  
253:      } catch (ClassNotFoundException ex) {  
254:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
255:      }  
256:      try {  
257:        prikazTa.setText(Zaposleni.prikazNaOsnovuId(id));  
258:      } catch (ClassNotFoundException ex) {  
259:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
260:      }  
261:      rbTf.setText("");  
262:      imeTf.setText("");  
263:    }                     
264:    
265:    private void godineBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
266:      String id = rbTf.getText();  
267:      String godine = godineTf.getText();  
268:      try {  
269:        Zaposleni.izmenaGodina(id, godine);  
270:      } catch (ClassNotFoundException ex) {  
271:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
272:      }  
273:      try {  
274:        prikazTa.setText(Zaposleni.prikazNaOsnovuId(id));  
275:      } catch (ClassNotFoundException ex) {  
276:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
277:      }  
278:      rbTf.setText("");  
279:      godineTf.setText("");  
280:    }                       
281:    
282:    private void adresaBtnActionPerformed(java.awt.event.ActionEvent evt) {                       
283:      String id = rbTf.getText();  
284:      String adresa = adresaTf.getText();  
285:      try {  
286:        Zaposleni.izmenaAdrese(id, adresa);  
287:      } catch (ClassNotFoundException ex) {  
288:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
289:      }  
290:      try {  
291:        prikazTa.setText(Zaposleni.prikazNaOsnovuId(id));  
292:      } catch (ClassNotFoundException ex) {  
293:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
294:      }  
295:      rbTf.setText("");  
296:      adresaTf.setText("");  
297:    }                       
298:    
299:    private void dohodakBtnActionPerformed(java.awt.event.ActionEvent evt) {                        
300:      String id = rbTf.getText();  
301:      String dohodak = dohodakTf.getText();  
302:      try {  
303:        Zaposleni.izmenaDohotka(id, dohodak);  
304:      } catch (ClassNotFoundException ex) {  
305:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
306:      }  
307:      try {  
308:        prikazTa.setText(Zaposleni.prikazNaOsnovuId(id));  
309:      } catch (ClassNotFoundException ex) {  
310:        Logger.getLogger(IzmenaFrame.class.getName()).log(Level.SEVERE, null, ex);  
311:      }  
312:      rbTf.setText("");  
313:      dohodakTf.setText("");  
314:    }                       
315:    
316:    /**  
317:     * @param args the command line arguments  
318:     */  
319:    public static void main(String args[]) {  
320:      /* Set the Nimbus look and feel */  
321:      //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">  
322:      /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.  
323:       * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html   
324:       */  
325:      try {  
326:        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {  
327:          if ("Nimbus".equals(info.getName())) {  
328:            javax.swing.UIManager.setLookAndFeel(info.getClassName());  
329:            break;  
330:          }  
331:        }  
332:      } catch (ClassNotFoundException ex) {  
333:        java.util.logging.Logger.getLogger(IzmenaFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
334:      } catch (InstantiationException ex) {  
335:        java.util.logging.Logger.getLogger(IzmenaFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
336:      } catch (IllegalAccessException ex) {  
337:        java.util.logging.Logger.getLogger(IzmenaFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
338:      } catch (javax.swing.UnsupportedLookAndFeelException ex) {  
339:        java.util.logging.Logger.getLogger(IzmenaFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);  
340:      }  
341:      //</editor-fold>  
342:    
343:      /* Create and display the form */  
344:      java.awt.EventQueue.invokeLater(new Runnable() {  
345:        public void run() {  
346:          new IzmenaFrame().setVisible(true);  
347:        }  
348:      });  
349:    }  
350:    
351:    // Variables declaration - do not modify             
352:    private javax.swing.JButton adresaBtn;  
353:    private javax.swing.JTextField adresaTf;  
354:    private javax.swing.JButton dohodakBtn;  
355:    private javax.swing.JTextField dohodakTf;  
356:    private javax.swing.JButton godineBtn;  
357:    private javax.swing.JTextField godineTf;  
358:    private javax.swing.JButton imeBtn;  
359:    private javax.swing.JTextField imeTf;  
360:    private javax.swing.JButton jButton1;  
361:    private javax.swing.JButton jButton2;  
362:    private javax.swing.JLabel jLabel1;  
363:    private javax.swing.JLabel jLabel2;  
364:    private javax.swing.JLabel jLabel3;  
365:    private javax.swing.JLabel jLabel4;  
366:    private javax.swing.JLabel jLabel5;  
367:    private javax.swing.JScrollPane jScrollPane1;  
368:    private javax.swing.JTextArea prikazTa;  
369:    private javax.swing.JTextField rbTf;  
370:    // End of variables declaration            
371:  }  
372:    

ZaposleniDB.sql

1:  CREATE DATABASE IF NOT EXISTS `zaposleniDB` /*!40100 DEFAULT CHARACTER SET latin1 */;  
2:  USE `zaposleniDB`;  
3:  -- MySQL dump 10.13 Distrib 5.5.55, for debian-linux-gnu (i686)  
4:  --  
5:  -- Host: 127.0.0.1  Database: zaposleniDB  
6:  -- ------------------------------------------------------  
7:  -- Server version     5.5.55-0ubuntu0.14.04.1  
8:    
9:  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;  
10:  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;  
11:  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;  
12:  /*!40101 SET NAMES utf8 */;  
13:  /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;  
14:  /*!40103 SET TIME_ZONE='+00:00' */;  
15:  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;  
16:  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;  
17:  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;  
18:  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;  
19:    
20:  --  
21:  -- Table structure for table `zaposleni`  
22:  --  
23:    
24:  DROP TABLE IF EXISTS `zaposleni`;  
25:  /*!40101 SET @saved_cs_client   = @@character_set_client */;  
26:  /*!40101 SET character_set_client = utf8 */;  
27:  CREATE TABLE `zaposleni` (  
28:   `zaposleni_id` int(11) NOT NULL AUTO_INCREMENT,  
29:   `ime` varchar(45) NOT NULL,  
30:   `godine` int(11) NOT NULL,  
31:   `adresa` varchar(45) NOT NULL,  
32:   `dohodak` int(11) NOT NULL,  
33:   PRIMARY KEY (`zaposleni_id`)  
34:  ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;  
35:  /*!40101 SET character_set_client = @saved_cs_client */;  
36:    
37:  --  
38:  -- Dumping data for table `zaposleni`  
39:  --  
40:    
41:  LOCK TABLES `zaposleni` WRITE;  
42:  /*!40000 ALTER TABLE `zaposleni` DISABLE KEYS */;  
43:  INSERT INTO `zaposleni` VALUES (1,'Suzana Pavlovic',27,'Pobednicke 10',100000),(2,'Milica Gavrilovic',31,'Bulevar 53',80000),(3,'Ivan Dakic',35,'Bulevar 49',60000),(5,'Marko Dodic',35,'Bulevar 53',60000);  
44:  /*!40000 ALTER TABLE `zaposleni` ENABLE KEYS */;  
45:  UNLOCK TABLES;  
46:  /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;  
47:    
48:  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;  
49:  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;  
50:  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;  
51:  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;  
52:  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;  
53:  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;  
54:  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;  
55:    
56:  -- Dump completed on 2017-06-10 16:37:06  

Comments

  1. Informative and helpful Article. Really good work. Appreciate it. You might be looking for an IT Consultant like HR Payroll Management Software in Kolkata

    ReplyDelete

Post a Comment