Package com.talixa.steganos

Source Code of com.talixa.steganos.SteganographyToolkit

package com.talixa.steganos;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

import com.talixa.steganos.frames.FrameAbout;
import com.talixa.steganos.frames.FrameStegoOptions;
import com.talixa.steganos.listeners.ExitActionListener;
import com.talixa.steganos.shared.SteganosConstants;
import com.talixa.steganos.widgets.ImagePanel;

public class SteganographyToolkit {

  private static JFrame frame;
  private static ImagePanel imagePanel;
  private static JScrollPane scrollPane;
  private static JTextArea lblText;
 
  private static void createAndShowGUI() {
    // Create frame
    frame = new JFrame(SteganosConstants.TITLE_MAIN);   
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());

    // create image panel
    imagePanel = new ImagePanel()
    scrollPane = new JScrollPane(imagePanel);
    frame.add(scrollPane, BorderLayout.CENTER)
   
    lblText = new JTextArea();
    JScrollPane textPane = new JScrollPane(lblText)
    lblText.setRows(10);
    lblText.setLineWrap(true);
    frame.add(textPane, BorderLayout.SOUTH);

    // Create menus and toolbar
    addMenus();   
       
    // Set location and display
    Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
    frame.setPreferredSize(new Dimension(SteganosConstants.APP_WIDTH,SteganosConstants.APP_HEIGHT));
    int left = (screenSize.width/2) - (SteganosConstants.APP_WIDTH/2);
    int top  = (screenSize.height/2) - (SteganosConstants.APP_HEIGHT/2);
    frame.pack();
    frame.setLocation(left,top);
    frame.setVisible(true);       
 
   
  private static void addMenus() {
    // Setup file menu
    JMenu fileMenu = new JMenu(SteganosConstants.MENU_FILE);
    fileMenu.setMnemonic(KeyEvent.VK_F);
    JMenuItem openMenuItem = new JMenuItem(SteganosConstants.MENU_OPEN);
    openMenuItem.setMnemonic(KeyEvent.VK_O);
    openMenuItem.addActionListener(new ActionListener() {     
      @Override
      public void actionPerformed(ActionEvent e) {
        FrameStegoOptions.createAndShowGUI(imagePanel, scrollPane, lblText, true);                       
      }
    });
    fileMenu.add(openMenuItem);   
   
    JMenuItem saveMenuItem = new JMenuItem(SteganosConstants.MENU_ADD);
    saveMenuItem.setMnemonic(KeyEvent.VK_M);
    saveMenuItem.addActionListener(new ActionListener() {     
      @Override
      public void actionPerformed(ActionEvent e) {
        String msg = JOptionPane.showInputDialog(SteganosConstants.ENTER_MESSAGE);         
        if (msg != null) {
          lblText.setText(msg);
          FrameStegoOptions.createAndShowGUI(imagePanel, scrollPane, lblText, false);
        }                   
      }
    });
    fileMenu.add(saveMenuItem)
   
    JMenuItem exitMenuItem = new JMenuItem(SteganosConstants.MENU_EXIT);
    exitMenuItem.setMnemonic(KeyEvent.VK_X);
    exitMenuItem.addActionListener(new ExitActionListener(frame));
    fileMenu.add(exitMenuItem);     
   
    // Setup help menu
    JMenu helpMenu = new JMenu(SteganosConstants.MENU_HELP);
    helpMenu.setMnemonic(KeyEvent.VK_H);
    JMenuItem aboutMenuItem = new JMenuItem(SteganosConstants.MENU_ABOUT);
    aboutMenuItem.setMnemonic(KeyEvent.VK_A);
    aboutMenuItem.addActionListener(new ActionListener() {     
      @Override
      public void actionPerformed(ActionEvent e) {
        FrameAbout.createAndShowGUI();
      }
    });
    helpMenu.add(aboutMenuItem);
   
    // Add menus to menubar
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu)
    menuBar.add(helpMenu);
    frame.setJMenuBar(menuBar);
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        createAndShowGUI();
      }
    });       
 
}
TOP

Related Classes of com.talixa.steganos.SteganographyToolkit

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.