/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package grades; import java.awt.event.ActionEvent; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; /** * * @author eleni */ public class Gui implements ActionListener{ JFrame window = new JFrame("Υπολογισμός Βαθμού Πτυχίου"); JButton okButton = new JButton("OK"); JButton cancelButton = new JButton("Ακύρωση"); JTextField courseTextField = new JTextField(); JRadioButton normalCourse = new JRadioButton("Απλό μάθημα", true); JRadioButton importantCourse = new JRadioButton("Μάθημα αυξημένης βαρύτητας", false); ButtonGroup buttonGroup = new ButtonGroup(); LayoutManager gridLayout =new GridLayout(3,2); public void Gui (){ /* μέγεθος παραθύρου, να εμφανίζεται στη μέση της οθόνης κ.α. */ Toolkit toolkit = window.getToolkit(); Dimension wndsize = toolkit.getScreenSize(); this.window.setBounds(wndsize.width/4, wndsize.height/4, wndsize.width/2, wndsize.height/2); this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* Listeners σε όλα τα components του gui */ this.cancelButton.addActionListener(this); this.okButton.addActionListener(this); this.cancelButton.setActionCommand("cancelButton"); this.okButton.setActionCommand("okButton"); /* Θέσεις - Ρύθμιση Layout */ Container container = this.window.getContentPane(); container.setLayout(this.gridLayout); /* Όλα visible */ this.window.setVisible(true); } public void actionPerformed(ActionEvent e) { throw new UnsupportedOperationException("Not supported yet."); if(e.getActionCommand().equalsIgnoreCase("okButton")) { System.out.println("dsf"); } else { if(e.getActionCommand().equalsIgnoreCase("cancelButton")){ System.out.println("dsfw"); } } } }