Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.components.MessageBox.java

Here you can find all the information about the file org.dgpf.gui.components.MessageBox.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Alexander Podlich
 * 
 * E-Mail           : podlich@student.uni-kassel.de
 * Creation Date    : 22.06.2006 11:24:32
 * Original Filename: org.dgpf.gui.components.DGPFMessageBox.java
 * Version          : 1.0
 * Last modification: 22.06.2006
 * Last modified by : Alexander Podlich
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.dgpf.gui.components;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

import org.dgpf.gui.utils.LanguageSwitcher;

/**
 * This class represents a message box (for example: error messages).
 * 
 * @author Alexander Podlich.
 */

public class MessageBox extends JFrame implements ActionListener
  {

  /**
   * The serial version UID.
   */

  private static final long  serialVersionUID = 1L;

  /**
   * JFrame.
   */

  private JFrame          m_frame;

  /**
   * The message.
   */

  private String             m_message;

  /**
   * Layout manager.
   */

  private GridBagLayout      m_gridBagLayout;

  /**
   * Layout manager constraints.
   */

  private GridBagConstraints m_gridBagConstraints;

  /**
   * Default constructor.
   */

  public MessageBox()
    {
    super();
    }

  /**
   * Default constructor.
   * 
   * @param p_name
   *          The name of the message box.
   * @param p_msg
   *          The mesage.
   * @param p_frm
   *          The main DGPF frame.
   */

  public MessageBox(String p_name, String p_msg, JFrame p_frm)
    {
    
    super(p_name);
    this.m_message = p_msg;
    this.m_frame = p_frm;
    this.setVisible(true);
    this.m_gridBagLayout = new GridBagLayout();
    this.m_gridBagConstraints = new GridBagConstraints();
    this.setLayout(this.m_gridBagLayout);

    // JPanel panel = new JPanel();
    JLabel text = new JLabel(this.m_message);

    // panel.add(text);
    Button l_okButton = new Button(LanguageSwitcher
        .getString("btn_ok"), "ok"this, true);

    this.m_gridBagConstraints.weightx = 0.0;
    this.m_gridBagConstraints.weighty = 0.0;
    this.m_gridBagConstraints.insets = new Insets(20, 30, 20, 30);
    this.m_gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    // this.gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;

    this.m_gridBagLayout.setConstraints(text, this.m_gridBagConstraints);

    this.m_gridBagConstraints.insets = new Insets(0, 0, 20, 0);
    this.m_gridBagLayout.setConstraints(l_okButton, this.m_gridBagConstraints);

    this.add(text);
    this.add(l_okButton);
    this.pack();
    this.setLocationRelativeTo(this.m_frame);
    
    }

  /**
   * This method listens for actions.
   * 
   * @param p_e
   *          Action event.
   */

  public void actionPerformed(ActionEvent p_e)
    {
    String cmd = p_e.getActionCommand();
    if(cmd.equals("ok"))
      {
      this.dispose();
      }
    }

  }

File Information:

file name:MessageBox.java
package:org.dgpf.gui.components
qualified name:org.dgpf.gui.components.MessageBox.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/components/MessageBox.java
size:3.646 KB (3734 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-23 07:29:19 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-23 07:29:19 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo