Forráskód Böngészése

GUI class created

Just the backbone of tha GUI
Supermaniac101 11 éve
szülő
commit
d42eb17d3e

+ 1 - 1
.project

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>Agenda</name>
+	<name>AgendaGUI</name>
 	<comment></comment>
 	<projects>
 	</projects>

+ 0 - 11
.settings/org.eclipse.jdt.core.prefs

@@ -1,11 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7

BIN
bin/GUI$1.class


BIN
bin/GUI$2.class


BIN
bin/GUI$3.class


BIN
bin/GUI$4.class


BIN
bin/GUI$5.class


BIN
bin/GUI.class


BIN
bin/frames/MainFrame.class


BIN
bin/frames/MenuBar$1.class


BIN
bin/frames/MenuBar$2.class


BIN
bin/frames/MenuBar$3.class


BIN
bin/frames/MenuBar$4.class


BIN
bin/frames/MenuBar$5.class


BIN
bin/frames/MenuBar$6.class


BIN
bin/frames/MenuBar.class


BIN
bin/main/Main.class


BIN
bin/panels/AgendaPane.class


BIN
bin/panels/InfoPane.class


BIN
bin/panels/MainPanel.class


BIN
res/img/Xicon.png


BIN
res/img/_icon.png


+ 0 - 122
src/GUI/GUI.java

@@ -1,122 +0,0 @@
-package src.GUI;
-
-import src.agenda.*;
-
-import java.awt.Color;
-import java.awt.EventQueue;
-import java.awt.Frame;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-
-public class GUI {
-
-	private JFrame frame;
-
-	int posX=0,posY=0;
-	/**
-	 * Launch the application.
-	 */
-	public static void main(String[] args) {
-		EventQueue.invokeLater(new Runnable() {
-			public void run() {
-				try {
-					GUI window = new GUI();
-					window.frame.setVisible(true);
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-			}
-		});
-	}
-
-	/**
-	 * Create the application.
-	 */
-	public GUI() {
-		initialize();
-        
-        //test agenda.
-        Agenda agenda = new Agenda();
-        
-//        agenda.addArtist(new Artist("Iron Maiden", "Heavy metal"));
-//        agenda.addStage(new Stage("Mainstage"));
-//        agenda.addAct(new Act(agenda.getStages().get(0), "Heavy metal", agenda.getArtists().get(0)));
-//
-//        System.out.println(agenda);
-//
-//        //test time
-//        System.out.println(new ActTime(new Time(10, 30), new Time(11, 20)).getLength());
-	}
-
-	/**
-	 * Initialize the contents of the frame.
-	 */
-	private void initialize() {
-		frame = new JFrame();
-		frame.setResizable(false);
-		frame.setBounds(100, 100, 1020, 700);
-		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-		frame.setUndecorated(true);
-		frame.getContentPane().setLayout(null);
-		
-		
-		
-		JPanel menuBarPanel = new JPanel();
-		menuBarPanel.setBackground(new Color(0, 128, 128));
-		menuBarPanel.setBounds(0, 0, 1020, 45);
-		frame.getContentPane().add(menuBarPanel);
-		menuBarPanel.addMouseListener(new MouseAdapter()
-		{
-			   public void mousePressed(MouseEvent e)
-			   {
-			      posX=e.getX();
-			      posY=e.getY();
-			   }
-			});
-		menuBarPanel.addMouseMotionListener(new MouseAdapter()
-		{
-		     public void mouseDragged(MouseEvent evt)
-		     {
-				//sets frame position when mouse dragged			
-				setLocation(evt.getXOnScreen()-posX,evt.getYOnScreen()-posY);
-							
-		     }
-		});
-		ImageIcon closeIcon = new ImageIcon("res/img/Xicon.png");
-	    JLabel closeLabel = new JLabel(closeIcon);
-	    closeLabel.setBounds(983, 11, 18, 18);
-	    closeLabel.addMouseListener(new MouseAdapter() {
-	      public void mouseClicked(MouseEvent me) {
-	    	  frame.dispose();
-	      }
-	    });
-	    ImageIcon min = new ImageIcon("res/img/_icon.png");
-	    JLabel minLabel = new JLabel(min);
-	    minLabel.setBounds(948, 11, 18, 18);
-	    minLabel.addMouseListener(new MouseAdapter() {
-	      public void mouseClicked(MouseEvent me) {
-	    	  frame.setState(Frame.ICONIFIED);
-	      }
-	    });
-	    menuBarPanel.setLayout(null);
-	    menuBarPanel.add(closeLabel);
-	    menuBarPanel.add(minLabel);
-	    
-		
-		
-		JPanel contentPanel = new JPanel();
-		contentPanel.setBackground(new Color(51, 160, 160));
-		contentPanel.setBounds(0, 45, 1020, 655);
-		frame.getContentPane().add(contentPanel);
-	}
-
-	protected void setLocation(int i, int j) {
-		frame.setLocation(i,j);
-	}
-}

+ 0 - 71
src/agenda/Act.java

@@ -1,71 +0,0 @@
-package src.agenda;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by gjoosen on 06/02/15.
- */
-public class Act {
-    
-    private List<Artist> artists;
-    private Stage stage;
-    private String genre;
-    private ActTime actTime;
-
-    public Act(Stage stage, String genre, Time startTime, Time endTime, Artist... artists){
-        this.stage = stage; 
-        this.genre = genre;
-        this.actTime = new ActTime(startTime, endTime);
-
-        this.artists = new ArrayList<Artist>();
-        for(Artist artist: artists) {
-            this.artists.add(artist);
-        }
-    }
-
-    /**
-     * * returns a list with all the artists that are in the act.
-     * @return all artists.
-     */
-    public List<Artist> getArtists() {
-        return artists;
-    }
-
-    /**
-     * * returns the stage the act plays on.
-     * @return stage
-     */
-    public Stage getStage() {
-        return stage;
-    }
-
-    /**
-     * * returns the genre of the act.
-     * @return the genre of the act.
-     */
-    public String getGenre() {
-        return genre;
-    }
-
-    /**
-     * * return the act time.
-     * @return the act time in minutes
-     */
-    public int getActTime() {
-        return this.actTime.getLength();
-    }
-    
-    @Override
-    public String toString(){
-        String string = "";
-        string+="Artists: ";
-        for(Artist artist: this.artists){
-            string += artist.getName() + "\n";
-        }
-        string+= "genre: " + this.genre + "\n";
-        string+= "stage: " + this.stage.getName() + "\n";
-        string+= this.actTime;
-        return string;
-    }
-}

+ 0 - 37
src/agenda/ActTime.java

@@ -1,37 +0,0 @@
-package src.agenda;
-
-/**
- * Created by gjoosen on 06/02/15.
- */
-public class ActTime {
-    
-    private Time beginTime, endTime;
-    
-    public ActTime(Time beginTime, Time endTime){
-        this.beginTime = beginTime;
-        this.endTime = endTime;
-    }
-
-    /**
-     * *
-     * @return the length of the act in minutes.
-     */
-    public int getLength(){
-        int difHours = this.endTime.getHours() - this.beginTime.getHours();
-        int difMinutes = this.endTime.getMinutes() - this.beginTime.getMinutes();
-        return difHours  * 60 + difMinutes;
-    }
-
-    public Time getBeginTime() {
-        return beginTime;
-    }
-
-    public Time getEndTime() {
-        return endTime;
-    }
-    
-    @Override
-    public String toString(){
-        return "start time: " + this.beginTime + "\nend time: " + this.endTime;
-    }
-}

+ 0 - 73
src/agenda/Agenda.java

@@ -1,73 +0,0 @@
-package src.agenda;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by gjoosen on 06/02/15.
- */
-public class Agenda {
-    
-    private List<Stage> stages;
-    private List<Artist> artists;
-    private List<Act> acts;
-    
-    public Agenda() {
-        this.stages = new ArrayList<Stage>();
-        this.artists = new ArrayList<Artist>();
-        this.acts = new ArrayList<Act>();
-        
-        this.testAgenda();
-    }
-
-    private void testAgenda(){
-        //stages
-        this.stages.add(new Stage("Main stage"));
-        this.stages.add(new Stage("Tent stage"));
-        
-        //artiesten
-        this.artists.add(new Artist("Iron Maiden", "Heavy metal"));
-        this.artists.add(new Artist("Slayer", "Tresh metal"));
-        this.artists.add(new Artist("Sabaton", "Power metal"));
-
-        //acts
-        this.acts.add(new Act(this.stages.get(0), "Heavy metal", new Time(21, 00), new Time(23, 00), this.artists.get(0)));
-        this.acts.add(new Act(this.stages.get(1), "Test metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(1)));
-        this.acts.add(new Act(this.stages.get(0), "Power metal" ,new Time(10, 10), new Time(10, 50), this.artists.get(2)));
-        
-        System.out.println(this);
-    }
-    
-    public List<Stage> getStages() {
-        return stages;
-    }
-
-    public void addStage(Stage stage){
-        this.stages.add(stage);
-    }
-    
-    public void addArtist(Artist artist){
-        this.artists.add(artist);
-    }
-    
-    public void addAct(Act act){
-        this.acts.add(act);
-    }
-    
-    public List<Artist> getArtists() {
-        return artists;
-    }
-
-    public List<Act> getActs() {
-        return acts;
-    }
-    
-    @Override
-    public String toString(){
-        String string = "";
-        for(Act act: this.acts){
-            string += act + "\n\n";
-        }
-        return string;
-    }
-}

+ 0 - 22
src/agenda/Artist.java

@@ -1,22 +0,0 @@
-package src.agenda;
-
-/**
- * Created by gjoosen on 06/02/15.
- */
-public class Artist {
-    
-    private String name, genre;
-    
-    public Artist(String name, String genre){
-        this.name = name;
-        this.genre = genre;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getGenre() {
-        return genre;
-    }
-}

+ 0 - 17
src/agenda/Stage.java

@@ -1,17 +0,0 @@
-package src.agenda;
-
-/**
- * Created by gjoosen on 06/02/15.
- */
-public class Stage {
-    
-    private String name;
-    
-    public Stage(String name){
-        this.name = name;
-    }
-    
-    public String getName(){
-        return this.name;
-    }
-}

+ 0 - 37
src/agenda/Time.java

@@ -1,37 +0,0 @@
-package src.agenda;
-
-/**
- * Created by gjoosen on 07/02/15.
- */
-public class Time {
-    
-    private int hours, minutes;
-    
-    public Time(int hours, int minutes){
-        this.hours = hours;
-        this.minutes = minutes;
-    }
-
-    public int getHours() {
-        return hours;
-    }
-
-    public int getMinutes() {
-        return minutes;
-    }
-    
-    @Override
-    public String toString(){
-        return this.numberToTimeDigits(this.hours) + ":" + this.numberToTimeDigits(this.minutes);
-    }
-    
-    private String numberToTimeDigits(int h){
-        String hours;
-        if(h == 0 || h == 1 || h == 2 || h == 3 || h == 4 || h == 5 || h == 6 || h == 7 || h == 8 || h == 9){
-            hours = "0" + h;
-        }else {
-            hours = String.valueOf(h);
-        }
-        return hours;
-    }
-}

+ 22 - 0
src/frames/MainFrame.java

@@ -0,0 +1,22 @@
+package frames;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+@SuppressWarnings("serial")
+public class MainFrame extends JFrame{
+	
+		public MainFrame(JPanel panel){
+		this.add(panel);
+		this.setResizable(false);
+		this.setBounds(100,100,1440,900);
+		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		this.setUndecorated(false);
+		this.setJMenuBar(new MenuBar());
+		this.setVisible(true);
+		}
+		
+		
+		
+		
+}

+ 73 - 0
src/frames/MenuBar.java

@@ -0,0 +1,73 @@
+package frames;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+
+@SuppressWarnings("serial")
+public class MenuBar extends JMenuBar{
+
+	public MenuBar(){
+		initialize();
+	}
+	
+	private void initialize(){
+		JMenu fileMenu = new JMenu("File");
+        JMenu editMenu = new JMenu("Edit");
+        JMenu viewMenu = new JMenu("View");
+        JMenu helpMenu = new JMenu("Help");
+        this.add(fileMenu);
+        this.add(editMenu);
+        this.add(viewMenu);
+        this.add(helpMenu);
+        
+        JMenuItem newAction = new JMenuItem("New");
+        JMenuItem openAction = new JMenuItem("Open");
+        JMenuItem exitAction = new JMenuItem("Exit");
+        JMenuItem cutAction = new JMenuItem("Cut");
+        JMenuItem copyAction = new JMenuItem("Copy");
+        JMenuItem pasteAction = new JMenuItem("Paste");
+        
+        fileMenu.add(newAction);
+        newAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the new action");
+            }
+        });
+        fileMenu.add(openAction);
+        openAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the open action");
+            }
+        });
+        fileMenu.addSeparator();
+        fileMenu.add(exitAction);
+        exitAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.exit(0);
+            }
+        });
+        editMenu.add(cutAction);
+        cutAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the cut action");
+            }
+        });
+        editMenu.add(copyAction);
+        copyAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the copy action");
+            }
+        });
+        editMenu.add(pasteAction);
+        pasteAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the paste action");
+            }
+        });
+	}
+	
+}

+ 13 - 0
src/main/Main.java

@@ -0,0 +1,13 @@
+package main;
+
+import panels.MainPanel;
+import frames.MainFrame;
+
+
+public class Main {
+	
+	public static void main(String[] args){
+		new MainFrame(new MainPanel());
+	}
+}
+	

+ 8 - 0
src/panels/AgendaPane.java

@@ -0,0 +1,8 @@
+package panels;
+
+import javax.swing.JPanel;
+
+@SuppressWarnings("serial")
+public class AgendaPane extends JPanel {
+
+}

+ 10 - 0
src/panels/InfoPane.java

@@ -0,0 +1,10 @@
+package panels;
+
+import javax.swing.JPanel;
+
+@SuppressWarnings("serial")
+public class InfoPane extends JPanel{
+	public InfoPane(){
+		
+	}
+}

+ 11 - 0
src/panels/MainPanel.java

@@ -0,0 +1,11 @@
+package panels;
+
+import javax.swing.JPanel;
+
+@SuppressWarnings("serial")
+public class MainPanel extends JPanel{
+	public MainPanel(){
+		new InfoPane();
+		new AgendaPane();
+	}
+}

+ 0 - 17
test/src/agenda/ActTimeTest.java

@@ -1,17 +0,0 @@
-package src.agenda;
-
-import junit.framework.TestCase;
-
-public class ActTimeTest extends TestCase{
-
-    @org.junit.Before
-    public void setUp() throws Exception {
-        
-    }
-
-    @org.junit.Test
-    public void testGetLength() throws Exception {
-        ActTime actTime = new ActTime(new Time(10, 10), new Time(10, 20));
-        assert(actTime.getLength() == 10);
-    }
-}