Пример #1
0
  /** this method is used to design Main UI of Rack manager */
  private void initComponents() {

    label2 = new JLabel();
    panel1 = new JPanel();
    label1 = new JLabel();
    separator1 = new JSeparator();
    comboBox1 = new JComboBox<Object>();
    textField1 = new JTextField();
    label4 = new JLabel();
    label3 = new JLabel();
    scrollPane1 = new JScrollPane();
    textArea1 = new JTextArea();
    button1 = new JButton();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    button5 = new JButton();
    button6 = new JButton();
    scrollPane2 = new JScrollPane();
    tableModel = new DefaultTableModel();
    table1 = new JTable(tableModel);

    // ======== this ========
    setResizable(false);
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    // ======== panel1 ========
    {
      panel1.setLayout(null);

      // ---- label1 ----
      label1.setText("Manage Rack");
      label1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 30));
      panel1.add(label1);
      label1.setBounds(200, 10, 400, 50);

      panel1.add(separator1);
      separator1.setBounds(0, 100, 600, 5);

      // ---- label2 ----
      label2.setText("Select Store");
      panel1.add(label2);
      label2.setBounds(100, 120, 150, 20);

      panel1.add(comboBox1);
      comboBox1.setBounds(250, 120, 200, 20);
      comboBox1.addItemListener(this);

      // ---- label3 ----
      label3.setText("<html>Rack Name <font color='red'><b>*</b></font></html>");
      panel1.add(label3);
      label3.setBounds(100, 160, 160, 20);

      panel1.add(textField1);
      textField1.setBounds(250, 160, 200, 20);

      // ---- label4 ----
      label4.setText("Description");
      panel1.add(label4);
      label4.setBounds(100, 200, 150, 20);

      // ======== scrollPane1 ========
      {
        scrollPane1.setViewportView(textArea1);
      }
      panel1.add(scrollPane1);
      scrollPane1.setBounds(250, 200, 200, 100);

      // ---- button1 ----
      button1.setText("Save");
      panel1.add(button1);
      button1.setBounds(100, 350, 100, 30);
      button1.addActionListener(this);

      // ---- button2 ----
      button2.setText("Refresh");
      panel1.add(button2);
      button2.setBounds(250, 350, 100, 30);
      button2.addActionListener(this);

      // ---- button3 ----
      button3.setText("Exit");
      panel1.add(button3);
      button3.setBounds(400, 350, 100, 30);
      button3.addActionListener(this);

      // ---- button4 ----
      button4.setText("View");
      panel1.add(button4);
      button4.setBounds(100, 400, 100, 30);
      button4.addActionListener(this);

      // ---- button5 ----
      button5.setText("Update");
      panel1.add(button5);
      button5.setBounds(250, 400, 100, 30);
      button5.addActionListener(this);

      // ---- button6 ----
      button6.setText("Delete");
      panel1.add(button6);
      button6.setBounds(400, 400, 100, 30);
      button6.addActionListener(this);

      tableModel.addColumn("Sr. No.");
      tableModel.addColumn("Rack Name");

      // ======== scrollPane2 ========
      {
        scrollPane2.setViewportView(table1);
      }
      panel1.add(scrollPane2);
      scrollPane2.setBounds(50, 460, 500, 170);
    }
    contentPane.add(panel1);
    panel1.setBounds(0, 0, 600, 700);

    setTitle("Rack Manager");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
    // setLocationRelativeTo(getOwner());
    setLocation(100, 10);
    setSize(600, 700);
  }
Пример #2
0
  private void initComponents() {

    panel1 = new JPanel();
    label1 = new JLabel();
    separator1 = new JSeparator();
    button3 = new JButton();
    button4 = new JButton();
    button5 = new JButton();
    scrollPane2 = new JScrollPane();
    tableModel1 = new DefaultTableModel();
    table1 = new JTable(tableModel1);
    panel2 = new JPanel();
    label5 = new JLabel();
    textField1 = new JTextField();
    label2 = new JLabel();
    label3 = new JLabel();
    textField2 = new JTextField();
    textField3 = new JTextField();
    button1 = new JButton();
    button2 = new JButton();

    // ======== this ========
    setResizable(false);
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    // ======== panel1 ========
    {
      panel1.setLayout(null);

      // ---- label1 ----
      label1.setText("Manage Vat %");
      panel1.add(label1);
      label1.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 30));
      label1.setBounds(200, 10, 400, 50);

      panel1.add(separator1);
      separator1.setBounds(0, 100, 600, 5);

      // ======== panel2 ========
      {
        panel2.setBorder(UIManager.getBorder("TitledBorder.border"));
        panel2.setLayout(null);

        // ---- label3 ----
        label3.setText("<html>Year    : <font color='red'><b>*</b></font></html>");
        panel2.add(label3);
        label3.setBounds(new Rectangle(new Point(25, 25), label3.getPreferredSize()));

        panel2.add(textField1);
        textField1.setBounds(95, 25, 100, textField1.getPreferredSize().height);

        // ---- label5 ----
        label5.setText("<html>To  : <font color='red'><b>*</b></font></html>");
        panel2.add(label5);
        label5.setBounds(new Rectangle(new Point(250, 25), label5.getPreferredSize()));

        panel2.add(textField2);
        textField2.setBounds(310, 25, 100, textField2.getPreferredSize().height);

        // ---- label2 ----
        label2.setText("<html>Vat %  : <font color='red'><b>*</b></font></html>");
        panel2.add(label2);
        label2.setBounds(new Rectangle(new Point(25, 85), label2.getPreferredSize()));

        panel2.add(textField3);
        textField3.setBounds(95, 85, 315, textField3.getPreferredSize().height);

        // ---- button1 ----
        button1.setText("Add");
        panel2.add(button1);
        button1.setBounds(70, 150, 100, 30);
        button1.addActionListener(this);

        // ---- button2 ----
        button2.setText("Clear");
        panel2.add(button2);
        button2.setBounds(280, 150, 100, 30);
        button2.addActionListener(this);
      }
      panel1.add(panel2);
      panel2.setBounds(50, 125, 500, 200);

      tableModel1.addColumn("Sr. No.");
      tableModel1.addColumn("vat %");
      tableModel1.addColumn("Year From");
      tableModel1.addColumn("Year To");

      // ======== scrollPane2 ========
      {
        scrollPane2.setViewportView(table1);
      }
      panel1.add(scrollPane2);
      scrollPane2.setBounds(50, 340, 500, 250);

      // ---- button3 ----
      button3.setText("Delete");
      panel1.add(button3);
      button3.setBounds(50, 610, 150, 30);
      button3.addActionListener(this);

      // ---- button4 ----
      button4.setText("Update");
      panel1.add(button4);
      button4.setBounds(225, 610, 150, 30);
      button4.addActionListener(this);
      button4.setEnabled(false);

      // ---- button5 ----
      button5.setText("Refresh");
      panel1.add(button5);
      button5.setBounds(400, 610, 150, 30);
      button5.addActionListener(this);
    }
    contentPane.add(panel1);
    panel1.setBounds(0, 0, 600, 700);

    pack();
    setVisible(true);
    setLocation(200, 10);
    setSize(600, 700);
  }