Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package StudyPlanner;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.swing.BorderFactory;
- import javax.swing.BoxLayout;
- import javax.swing.Icon;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import javax.swing.SwingConstants;
- /**
- *
- * @author hgm14nau
- */
- // class
- //cd desktop , cd project2
- //git status
- //git add studyplanner/src (updates)
- //git commit -m 'Description'
- //git push -u origin master
- public class ModuleView extends JFrame{
- private BufferedImage image;
- public ModuleView(){
- this.setVisible(true);
- this.setLocationRelativeTo(null);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- /*
- * Images
- */
- /*
- * Adding JButtons
- */
- JButton home = new JButton();
- JButton select = new JButton();
- JButton modules = new JButton();
- JButton milestones = new JButton();
- JButton notes = new JButton();
- /*
- * Importing images from the "images" folder
- */
- ImageIcon homeButton = new ImageIcon("src/images/home.png");
- ImageIcon selectButton = new ImageIcon("src/images/select.png");
- ImageIcon moduleButton = new ImageIcon("src/images/modules.png");
- ImageIcon milestoneButton = new ImageIcon("src/images/milestones.png");
- ImageIcon noteButton = new ImageIcon("src/images/notes.png");
- /*
- * Setting html-styled 'hover text' for when the users mouse is hovered over
- * the respective JButtons
- */
- home.setToolTipText("<html>Home Button<br>Navigates to home</html>");
- modules.setToolTipText("<html>Module Button<br>Navigates to Module</html>");
- milestones.setToolTipText("<html>Milestone Button<br>Navigates to Milestone</html>");
- notes.setToolTipText("<html>Note Button<br>Navigates to Note</html>");
- /*
- * Assigning the imported images to the JButtons
- */
- home.setIcon(homeButton);
- select.setIcon(selectButton);
- modules.setIcon(moduleButton);
- milestones.setIcon(milestoneButton);
- notes.setIcon(noteButton);
- /*
- * Setting image border to null to enhance the aesthetic design
- */
- home.setBorder(null);
- select.setBorder(null);
- modules.setBorder(null);
- milestones.setBorder(null);
- notes.setBorder(null);
- home.setContentAreaFilled(false);
- /*
- * End of image related code
- */
- /*
- * The following code contains JPanel containers
- */
- //main container to store our panels
- JPanel mainContainer = new JPanel();
- mainContainer.setLayout(new BoxLayout(mainContainer,BoxLayout.Y_AXIS));
- //we need this panel because the header and body should be stored in different
- //panels. Where header should cover all of body's top area
- // And where body is going to have two elements within with Y axis layout
- JPanel headerAndBody = new JPanel();
- headerAndBody.setLayout(new BoxLayout(headerAndBody,BoxLayout.Y_AXIS));
- mainContainer.add(headerAndBody);
- //Every icon in the header goes into headerIcons JPanel
- JPanel headerIcons = new JPanel();
- headerIcons.setLayout(new BoxLayout(headerIcons,BoxLayout.X_AXIS));
- headerIcons.setPreferredSize(new Dimension(600,40));
- headerIcons.setMaximumSize(new Dimension(1600, 40));
- //Headers to be put into headerIcons
- JPanel header = new JPanel();
- JPanel header2 = new JPanel();
- JPanel header3 = new JPanel();
- JPanel header4 = new JPanel();
- // JPanel header5 = new JPanel();
- //footer
- JPanel footer = new JPanel();
- //Image check.
- File imageCheck = new File("src/images/modules.png");
- if(imageCheck.exists())
- System.out.println("Image file found!");
- else
- System.out.println("Image file not found!");
- //end of image check
- //header 1
- header.setPreferredSize(new Dimension(50,40));
- header.setBackground(Color.BLACK);
- header.setMaximumSize(new Dimension(1600, 40));
- header.add(home);
- headerIcons.add(header);
- //header 2
- header2.setPreferredSize(new Dimension(50,40));
- header2.setBackground(Color.BLACK);
- header2.setMaximumSize(new Dimension(1600, 40));
- header2.add(modules);
- headerIcons.add(header2);
- //header 3
- header3.setPreferredSize(new Dimension(50,40));
- header3.setBackground(Color.BLACK);
- header3.setMaximumSize(new Dimension(1600, 40));
- header3.add(milestones);
- headerIcons.add(header3);
- //header 4
- header4.setPreferredSize(new Dimension(50,40));
- header4.setBackground(Color.BLACK);
- header4.setMaximumSize(new Dimension(1600, 40));
- header4.add(notes);
- headerIcons.add(header4);
- //header 5
- /*
- header2.setPreferredSize(new Dimension(300,40));
- header2.setBackground(Color.BLACK);
- header2.setMaximumSize(new Dimension(1600, 40));
- header2.add(modules);
- headerIcons.add(header2);
- */
- //Add headers to headerIcons JPanel
- headerAndBody.add(headerIcons);
- JPanel body = new JPanel();
- body.setLayout(new BoxLayout(body,BoxLayout.Y_AXIS));
- headerAndBody.add(body);
- JPanel bodyTop = new JPanel();
- bodyTop.setBackground(Color.WHITE);
- bodyTop.setPreferredSize(new Dimension(1100, 200));
- JPanel bodyLeftSide = new JPanel();
- bodyLeftSide.setBackground(Color.WHITE);
- bodyLeftSide.setPreferredSize(new Dimension(1100,30));
- bodyLeftSide.add(new JLabel("<html>Modules</html>"));
- JPanel bodyUserName = new JPanel();
- bodyUserName.setBackground(Color.WHITE);
- bodyUserName.setPreferredSize(new Dimension(1100, 30));
- // bodyUserName.add(new JLabel("<html>Username</html>"));
- JTextField user = new JTextField();
- bodyUserName.add(user);
- user.setPreferredSize( new Dimension( 200, 24 ) );
- JPanel bodyPassword = new JPanel();
- bodyPassword.setBackground(Color.WHITE);
- bodyPassword.setPreferredSize(new Dimension(1100, 30));
- // bodyPassword.add(new JLabel("<html>Password</html>"));
- JTextField pass = new JTextField();
- bodyPassword.add(pass);
- pass.setPreferredSize( new Dimension( 200, 24 ) );
- JPanel bodySelect = new JPanel();
- bodySelect.setBackground(Color.WHITE);
- bodySelect.setPreferredSize(new Dimension(1100, 50));
- bodySelect.add(select);
- bodyLeftSide.setMaximumSize(new Dimension(1600, 30));
- bodyUserName.setMaximumSize(new Dimension(1600, 30));
- bodyPassword.setMaximumSize(new Dimension(1600,30));
- bodySelect.setMaximumSize(new Dimension(1600,50));
- body.add(bodyTop);
- body.add(bodyLeftSide);
- body.add(bodyUserName);
- body.add(bodyPassword);
- body.add(bodySelect);
- JPanel bodyRightSide = new JPanel();
- bodyRightSide.setPreferredSize(new Dimension(100,600));
- bodyRightSide.setBackground(Color.WHITE);
- bodyRightSide.setMaximumSize(new Dimension(1600, 3000));
- // bodyRightSide.setBorder(BorderFactory.createLineBorder(Color.black));
- // bodyRightSide.add(new JLabel("Dashboard"));
- body.add(bodyRightSide);
- footer.setLayout(new BoxLayout(footer,BoxLayout.X_AXIS));
- footer.add(new JLabel("<html><font color=white> <i>Study Planning Software for Software Engineering. Founders; Marc Adlington, Taylor Kern, Edvinus Gurinas and Justinas Druskis (2016).</html>"));
- footer.setPreferredSize(new Dimension(600,40));
- footer.setBackground(Color.GRAY);
- footer.setMaximumSize(new Dimension(1600, 40));
- body.add(footer);
- this.add(mainContainer);
- pack();
- }
- /*
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- new ModuleView();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement