Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.99 KB | None | 0 0
  1. package UILayer;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.EventQueue;
  6. import java.awt.Insets;
  7. import java.awt.Window;
  8.  
  9. import javax.swing.JFrame;
  10. import javax.swing.JPanel;
  11. import javax.swing.border.EmptyBorder;
  12. import javax.swing.JLayeredPane;
  13. import java.awt.CardLayout;
  14. import javax.swing.GroupLayout;
  15. import javax.swing.GroupLayout.Alignment;
  16. import javax.swing.JButton;
  17. import javax.swing.LayoutStyle.ComponentPlacement;
  18. import java.awt.event.ActionListener;
  19. import java.awt.event.ActionEvent;
  20. import javax.swing.SpringLayout;
  21. import javax.swing.JList;
  22. import javax.swing.JComboBox;
  23. import javax.swing.JTextField;
  24. import javax.swing.JRadioButton;
  25. import javax.swing.JSplitPane;
  26. import javax.swing.JSeparator;
  27. import javax.swing.SwingConstants;
  28. import javax.swing.*;
  29. import java.awt.Font;
  30.  
  31. public class MainGUI extends JFrame {
  32.  
  33.     private JPanel contentPane;
  34.     private JTextField textField;
  35.  
  36.     /**
  37.      * Launch the application.
  38.      */
  39.     public static void main(String[] args) {
  40.         EventQueue.invokeLater(new Runnable() {
  41.             public void run() {
  42.                 try {
  43.                     MainGUI frame = new MainGUI();
  44.                     frame.setVisible(true);
  45.                 } catch (Exception e) {
  46.                     e.printStackTrace();
  47.                 }
  48.             }
  49.         });
  50.     }
  51.  
  52.     /**
  53.      * Create the frame.
  54.      */
  55.     public MainGUI() {
  56.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  57.         setBounds(100, 100, 1280, 720);
  58.         contentPane = new JPanel();
  59.         contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
  60.         contentPane.setLayout(new BorderLayout(0, 0));
  61.         setContentPane(contentPane);
  62.        
  63.         JLayeredPane layeredPane = new JLayeredPane();
  64.         contentPane.add(layeredPane, BorderLayout.CENTER);
  65.         layeredPane.setLayout(new CardLayout(0, 0));
  66.        
  67.         JPanel panel = new JPanel();
  68.         layeredPane.add(panel, "name_181804389288300");
  69.         //Color color = new Color(0,0,0);
  70.         //panel.setBackground(color);
  71.        
  72.         Icon icon = new ImageIcon("C:\\Users\\Lenovo\\Desktop\\group project 1st semester\\files for SVN\\icons\\customer.PNG");
  73.         JButton button = new JButton(icon);
  74.         //button.setBorder(new EmptyBorder(0, 0, 0, 0));
  75.         button.addActionListener(new ActionListener() {
  76.             public void actionPerformed(ActionEvent e) {
  77.                 CardLayout cardLayout = (CardLayout) layeredPane.getLayout();
  78.                 cardLayout.next(layeredPane);
  79.             }
  80.             });
  81.        
  82.         JButton btnNewButton = new JButton("New button");
  83.         btnNewButton.addActionListener(new ActionListener() {
  84.             public void actionPerformed(ActionEvent e) {
  85.                 panel.setVisible(false);
  86.             }
  87.         });
  88.         //button.setBorder(new EmptyBorder(0, 0, 0, 0));
  89.        
  90.         GroupLayout gl_panel = new GroupLayout(panel);
  91.         gl_panel.setHorizontalGroup(
  92.             gl_panel.createParallelGroup(Alignment.LEADING)
  93.                 .addGroup(gl_panel.createSequentialGroup()
  94.                     .addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 644, GroupLayout.PREFERRED_SIZE)
  95.                     .addPreferredGap(ComponentPlacement.RELATED)
  96.                     .addComponent(button, GroupLayout.PREFERRED_SIZE, 668, GroupLayout.PREFERRED_SIZE)
  97.                     .addContainerGap(423, Short.MAX_VALUE))
  98.         );
  99.         gl_panel.setVerticalGroup(
  100.             gl_panel.createParallelGroup(Alignment.LEADING)
  101.                 .addGroup(gl_panel.createSequentialGroup()
  102.                     .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
  103.                         .addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 681, GroupLayout.PREFERRED_SIZE)
  104.                         .addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
  105.                             .addContainerGap()
  106.                             .addComponent(button, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
  107.                     .addContainerGap())
  108.         );
  109.         panel.setLayout(gl_panel);
  110.        
  111.         JPanel panel_1 = new JPanel();
  112.         layeredPane.add(panel_1, "name_181808694829500");
  113.        
  114.         JButton btnNewButton_1 = new JButton("New button");
  115.         btnNewButton_1.addActionListener(new ActionListener() {
  116.             public void actionPerformed(ActionEvent e) {
  117.                 CardLayout cardLayout = (CardLayout) layeredPane.getLayout();
  118.                 cardLayout.next(layeredPane);
  119.             }
  120.         });
  121.        
  122.         JButton button_1 = new JButton("New button");
  123.        
  124.         JButton button_2 = new JButton("New button");
  125.         SpringLayout sl_panel_1 = new SpringLayout();
  126.         sl_panel_1.putConstraint(SpringLayout.NORTH, button_1, 211, SpringLayout.NORTH, panel_1);
  127.         sl_panel_1.putConstraint(SpringLayout.WEST, button_1, 497, SpringLayout.WEST, panel_1);
  128.         sl_panel_1.putConstraint(SpringLayout.SOUTH, button_1, 464, SpringLayout.NORTH, panel_1);
  129.         sl_panel_1.putConstraint(SpringLayout.EAST, button_1, -86, SpringLayout.WEST, button_2);
  130.         sl_panel_1.putConstraint(SpringLayout.WEST, button_2, 846, SpringLayout.WEST, panel_1);
  131.         sl_panel_1.putConstraint(SpringLayout.EAST, button_2, -150, SpringLayout.EAST, panel_1);
  132.         sl_panel_1.putConstraint(SpringLayout.WEST, btnNewButton_1, 150, SpringLayout.WEST, panel_1);
  133.         sl_panel_1.putConstraint(SpringLayout.NORTH, button_2, 211, SpringLayout.NORTH, panel_1);
  134.         sl_panel_1.putConstraint(SpringLayout.SOUTH, button_2, 464, SpringLayout.NORTH, panel_1);
  135.         sl_panel_1.putConstraint(SpringLayout.NORTH, btnNewButton_1, 211, SpringLayout.NORTH, panel_1);
  136.         sl_panel_1.putConstraint(SpringLayout.SOUTH, btnNewButton_1, 464, SpringLayout.NORTH, panel_1);
  137.         sl_panel_1.putConstraint(SpringLayout.EAST, btnNewButton_1, 410, SpringLayout.WEST, panel_1);
  138.         panel_1.setLayout(sl_panel_1);
  139.         panel_1.add(btnNewButton_1);
  140.         panel_1.add(button_1);
  141.         panel_1.add(button_2);
  142.        
  143.         JButton btnNewButton_4 = new JButton("BACK");
  144.         btnNewButton_4.addActionListener(new ActionListener() {
  145.             public void actionPerformed(ActionEvent e) {
  146.                 CardLayout cardLayout = (CardLayout) layeredPane.getLayout();
  147.                 cardLayout.previous(layeredPane);
  148.             }
  149.         });
  150.         sl_panel_1.putConstraint(SpringLayout.NORTH, btnNewButton_4, 21, SpringLayout.NORTH, panel_1);
  151.         sl_panel_1.putConstraint(SpringLayout.WEST, btnNewButton_4, 10, SpringLayout.WEST, panel_1);
  152.         panel_1.add(btnNewButton_4);
  153.        
  154.         JPanel panel_2 = new JPanel();
  155.         layeredPane.add(panel_2, "name_181820611698800");
  156.        
  157.         JList list = new JList();
  158.        
  159.         class ComboItem
  160.         {
  161.             private String key;
  162.             private String value;
  163.  
  164.             public ComboItem(String key, String value)
  165.             {
  166.                 this.key = key;
  167.                 this.value = value;
  168.             }
  169.  
  170.             @Override
  171.             public String toString()
  172.             {
  173.                 return key;
  174.             }
  175.  
  176.             public String getKey()
  177.             {
  178.                 return key;
  179.             }
  180.  
  181.             public String getValue()
  182.             {
  183.                 return value;
  184.             }
  185.            
  186.         }
  187.        
  188.         JComboBox comboBox = new JComboBox();
  189.         comboBox.addItem(new ComboItem("barcode", "barcode"));
  190.         comboBox.addItem(new ComboItem("item name", "item name"));
  191.         comboBox.addItem(new ComboItem("location", "location"));
  192.         comboBox.addItem(new ComboItem("supplier", "supplier"));
  193.        
  194.         Object item = comboBox.getSelectedItem();
  195.         String value = ((ComboItem)item).getValue();
  196.        
  197.         textField = new JTextField();
  198.         textField.setColumns(10);
  199.        
  200.         JTextArea textArea = new JTextArea();
  201.        
  202.         JCheckBox chckbxProductsforPurchases = new JCheckBox("PRODUCTS FOR PURCHASES");
  203.         chckbxProductsforPurchases.setFont(new Font("Tahoma", Font.PLAIN, 13));
  204.        
  205.         JCheckBox chckbxProductsForLeases = new JCheckBox("PRODUCTS FOR LEASES");
  206.         chckbxProductsForLeases.setFont(new Font("Tahoma", Font.PLAIN, 13));
  207.        
  208.         JCheckBox chckbxPackages = new JCheckBox("PACKAGES");
  209.         chckbxPackages.setFont(new Font("Tahoma", Font.PLAIN, 13));
  210.        
  211.         JButton btnNewButton_2 = new JButton("\uD83D\uDD0D");
  212.         btnNewButton_2.addActionListener(new ActionListener() {
  213.             public void actionPerformed(ActionEvent e) {
  214.                 /*searchText String stores the text you insert in the searchbar*/
  215.                 String searchText = textField.getText();
  216.                 /*searchFilter String stores the option you pick from the dropbox*/
  217.                 String searchFilter = comboBox.getSelectedItem().toString();
  218.                 /*checks if the checkbox(PRODUCTS FOR PURCHASES) is checked*/
  219.                 boolean checkPProduct = chckbxProductsforPurchases.isSelected();
  220.             }
  221.         });
  222.        
  223.         JButton btnNewButton_3 = new JButton("Create new product");
  224.         btnNewButton_3.addActionListener(new ActionListener() {
  225.             public void actionPerformed(ActionEvent e) {
  226. //              CreateProductGUI createProductGUI = new CreateProductGUI();
  227. //              createProductGUI.setVisible(true);
  228.             }
  229.         });
  230.        
  231.        
  232.         JButton button_3 = new JButton("Update product");
  233.         button_3.setEnabled(false);
  234.        
  235.         JButton button_4 = new JButton("Delete product");
  236.         button_4.setEnabled(false);
  237.        
  238.         JButton button_5 = new JButton("Change stock");
  239.         button_5.setEnabled(false);
  240.        
  241.         JButton button_6 = new JButton("Move product");
  242.         button_6.setEnabled(false);
  243.        
  244.         JButton button_7 = new JButton("Print sale");
  245.         button_7.setEnabled(false);
  246.        
  247.         JSeparator separator = new JSeparator();
  248.        
  249.         JSeparator separator_1 = new JSeparator();
  250.        
  251.         JButton button_8 = new JButton("\uD83D\uDD19");
  252.         button_8.setFont(new Font("Tahoma", Font.PLAIN, 16));
  253.         button_8.addActionListener(new ActionListener() {
  254.             public void actionPerformed(ActionEvent e) {
  255.                 CardLayout cardLayout = (CardLayout) layeredPane.getLayout();
  256.                 cardLayout.previous(layeredPane);
  257.             }
  258.         });
  259.        
  260.        
  261.         GroupLayout gl_panel_2 = new GroupLayout(panel_2);
  262.         gl_panel_2.setHorizontalGroup(
  263.             gl_panel_2.createParallelGroup(Alignment.LEADING)
  264.                 .addGroup(gl_panel_2.createSequentialGroup()
  265.                     .addGap(43)
  266.                     .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
  267.                         .addGroup(gl_panel_2.createSequentialGroup()
  268.                             .addComponent(btnNewButton_3, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  269.                             .addGap(30)
  270.                             .addComponent(button_3, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  271.                             .addGap(30)
  272.                             .addComponent(button_4, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  273.                             .addGap(30)
  274.                             .addComponent(button_5, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  275.                             .addPreferredGap(ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
  276.                             .addComponent(button_6, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))
  277.                         .addGroup(gl_panel_2.createSequentialGroup()
  278.                             .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 288, GroupLayout.PREFERRED_SIZE)
  279.                             .addGap(30)
  280.                             .addComponent(textField, GroupLayout.PREFERRED_SIZE, 248, GroupLayout.PREFERRED_SIZE)
  281.                             .addGap(8)))
  282.                     .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
  283.                         .addGroup(gl_panel_2.createSequentialGroup()
  284.                             .addGap(30)
  285.                             .addComponent(button_7, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))
  286.                         .addGroup(gl_panel_2.createSequentialGroup()
  287.                             .addGap(18)
  288.                             .addComponent(btnNewButton_2)
  289.                             .addGap(70)
  290.                             .addComponent(textArea, GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)))
  291.                     .addPreferredGap(ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
  292.                     .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
  293.                         .addComponent(separator_1, GroupLayout.PREFERRED_SIZE, 1, GroupLayout.PREFERRED_SIZE)
  294.                         .addComponent(separator, GroupLayout.PREFERRED_SIZE, 1, GroupLayout.PREFERRED_SIZE)
  295.                         .addComponent(chckbxProductsForLeases, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE)
  296.                         .addComponent(chckbxProductsForLeases, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE)
  297.                         .addComponent(chckbxPackages, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE))
  298.                     .addGap(18))
  299.                 .addGroup(gl_panel_2.createSequentialGroup()
  300.                     .addContainerGap()
  301.                     .addComponent(button_8, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
  302.                     .addContainerGap(1195, Short.MAX_VALUE))
  303.                 .addComponent(list, GroupLayout.DEFAULT_SIZE, 1268, Short.MAX_VALUE)
  304.         );
  305.         gl_panel_2.setVerticalGroup(
  306.             gl_panel_2.createParallelGroup(Alignment.LEADING)
  307.                 .addGroup(gl_panel_2.createSequentialGroup()
  308.                     .addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  309.                     .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
  310.                         .addGroup(gl_panel_2.createSequentialGroup()
  311.                             .addPreferredGap(ComponentPlacement.RELATED)
  312.                             .addComponent(button_8, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)
  313.                             .addGap(18)
  314.                             .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING)
  315.                                 .addComponent(button_3, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  316.                                 .addComponent(btnNewButton_3, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  317.                                 .addComponent(button_4, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  318.                                 .addGroup(gl_panel_2.createParallelGroup(Alignment.BASELINE)
  319.                                     .addComponent(button_5, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  320.                                     .addComponent(button_6, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
  321.                                     .addComponent(button_7, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))
  322.                             .addGap(72)
  323.                             .addGroup(gl_panel_2.createParallelGroup(Alignment.BASELINE)
  324.                                 .addComponent(comboBox, GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
  325.                                 .addComponent(textField, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
  326.                                 .addComponent(btnNewButton_2, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
  327.                                 .addComponent(textArea, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE))
  328.                             .addGap(55))
  329.                         .addGroup(gl_panel_2.createSequentialGroup()
  330.                             .addGap(191)
  331.                             .addComponent(chckbxProductsforPurchases, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
  332.                             .addPreferredGap(ComponentPlacement.RELATED)
  333.                             .addComponent(chckbxProductsForLeases, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
  334.                             .addPreferredGap(ComponentPlacement.RELATED)
  335.                             .addComponent(chckbxPackages, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)))
  336.                     .addGap(15)
  337.                     .addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
  338.                     .addPreferredGap(ComponentPlacement.UNRELATED)
  339.                     .addComponent(list, GroupLayout.PREFERRED_SIZE, 319, GroupLayout.PREFERRED_SIZE)
  340.                     .addContainerGap())
  341.         );
  342.         panel_2.setLayout(gl_panel_2);
  343.     }
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement