Package com.commander4j.app

Source Code of com.commander4j.app.JInternalFrameMHNReasonProperties

package com.commander4j.app;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;

import com.commander4j.db.JDBLanguage;
import com.commander4j.db.JDBMHNReasons;
import com.commander4j.gui.JButton4j;
import com.commander4j.gui.JLabel4j_std;
import com.commander4j.gui.JTextField4j;
import com.commander4j.sys.Common;
import com.commander4j.util.JHelp;
import com.commander4j.util.JUtility;

public class JInternalFrameMHNReasonProperties extends JInternalFrame
{
  private static final long serialVersionUID = 1;
  private JDesktopPane jDesktopPane1;
  private JButton4j jButtonClose;
  private JButton4j jButtonHelp;
  private JButton4j jButtonUpdate;
  private JTextField4j jTextFieldDescription;
  private JLabel4j_std jLabel3;
  private JTextField4j jTextFieldReason;
  private JLabel4j_std jLabel1;
  private JDBMHNReasons reas = new JDBMHNReasons(Common.selectedHostID, Common.sessionID);
  private String ltype;
  private JDBLanguage lang = new JDBLanguage(Common.selectedHostID, Common.sessionID);

  public JInternalFrameMHNReasonProperties()
  {
    super();
    initGUI();
    final JHelp help = new JHelp();
    help.enableHelpOnButton(jButtonHelp, JUtility.getHelpSetIDforModule("FRM_ADMIN_REASON"));

    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        jTextFieldDescription.requestFocus();
        jTextFieldDescription.setCaretPosition(jTextFieldDescription.getText().length());
      }
    });
  }

  public JInternalFrameMHNReasonProperties(String reason)
  {

    this();

    jTextFieldReason.setText(reason);
    setTitle(getTitle() + " - " + reason);
    ltype = reason;

    reas.setReason(ltype);
    reas.getReasonProperties();

    jTextFieldReason.setText(reas.getReason());
    jTextFieldDescription.setText(reas.getDescription());
  }

  private void initGUI() {
    try
    {
      this.setPreferredSize(new java.awt.Dimension(389, 143));
      this.setBounds(0, 0, 399, 160);
      setVisible(true);
      this.setIconifiable(true);
      this.setClosable(true);
      {
        jDesktopPane1 = new JDesktopPane();
        jDesktopPane1.setBackground(Common.color_edit_properties);
        getContentPane().add(jDesktopPane1, BorderLayout.CENTER);
        {
          jLabel1 = new JLabel4j_std();
          jDesktopPane1.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jLabel1.setText(lang.get("lbl_Reason"));
          jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
          jLabel1.setHorizontalTextPosition(SwingConstants.RIGHT);
          jLabel1.setBounds(0, 7, 98, 21);
        }
        {
          jTextFieldReason = new JTextField4j();
          jDesktopPane1.add(jTextFieldReason, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jTextFieldReason.setHorizontalAlignment(SwingConstants.LEFT);
          jTextFieldReason.setEditable(false);
          jTextFieldReason.setEnabled(false);
          jTextFieldReason.setBounds(105, 7, 80, 21);
        }
        {
          jLabel3 = new JLabel4j_std();
          jDesktopPane1.add(jLabel3, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jLabel3.setText(lang.get("lbl_Description"));
          jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
          jLabel3.setHorizontalTextPosition(SwingConstants.RIGHT);
          jLabel3.setBounds(0, 35, 98, 21);
        }
        {
          jTextFieldDescription = new JTextField4j();
          jDesktopPane1.add(jTextFieldDescription, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jTextFieldDescription.setBounds(105, 35, 238, 21);
          jTextFieldDescription.addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent evt) {
              jButtonUpdate.setEnabled(true);
            }
          });
          jTextFieldDescription.setFocusCycleRoot(true);
        }
        {
          jButtonUpdate = new JButton4j(Common.icon_update);
          jDesktopPane1.add(jButtonUpdate, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jButtonUpdate.setEnabled(false);
          jButtonUpdate.setText(lang.get("btn_Save"));
          jButtonUpdate.setMnemonic(lang.getMnemonicChar());
          jButtonUpdate.setHorizontalTextPosition(SwingConstants.RIGHT);
          jButtonUpdate.setBounds(14, 70, 112, 32);
          jButtonUpdate.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              reas.setDescription(jTextFieldDescription.getText());
              reas.update();
              jButtonUpdate.setEnabled(false);
            }
          });
        }
        {
          jButtonHelp = new JButton4j(Common.icon_help);
          jDesktopPane1.add(jButtonHelp);
          jButtonHelp.setText(lang.get("btn_Help"));
          jButtonHelp.setMnemonic(lang.getMnemonicChar());
          jButtonHelp.setBounds(133, 70, 112, 32);
        }
        {
          jButtonClose = new JButton4j(Common.icon_close);
          jDesktopPane1.add(jButtonClose, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
          jButtonClose.setText(lang.get("btn_Close"));
          jButtonClose.setMnemonic(lang.getMnemonicChar());
          jButtonClose.setBounds(252, 70, 112, 32);
          jButtonClose.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              dispose();
            }
          });
        }
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

}
TOP

Related Classes of com.commander4j.app.JInternalFrameMHNReasonProperties

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.