harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r611576 - /harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
Date Sun, 13 Jan 2008 13:44:40 GMT
Author: apetrenko
Date: Sun Jan 13 05:44:39 2008
New Revision: 611576

URL: http://svn.apache.org/viewvc?rev=611576&view=rev
Log:
Control menu has been added to applet frame

Modified:
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java?rev=611576&r1=611575&r2=611576&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
Sun Jan 13 05:44:39 2008
@@ -20,15 +20,23 @@
 import java.applet.Applet;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
+import java.awt.event.ActionEvent;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
+import java.beans.PropertyChangeListener;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.HashSet;
 
+import javax.swing.AbstractAction;
+import javax.swing.Action;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
 import javax.swing.JPanel;
+import javax.swing.JSeparator;
 import javax.swing.SwingConstants;
 
 class AppletFrame extends JFrame {
@@ -57,6 +65,9 @@
         add(appletPanel, BorderLayout.CENTER);
         applet.setPreferredSize(new Dimension(appletInfo.getWidth(), appletInfo.getHeight()));
         
+        // Create menu bar
+        setJMenuBar(createMenu());
+        
         // Create status pane
         JPanel panel = new JPanel();
         statusLabel = new JLabel();
@@ -73,9 +84,67 @@
         applet.init();
         setVisible(true);       
         applet.start();
-    }       
+    }
+    
+    private JMenuBar createMenu() {
+    	JMenuBar menuBar = new JMenuBar();
+    	
+    	// Create Control menu
+    	JMenu controlMenu = new JMenu("Control");
+    	controlMenu.add(new JMenuItem(new StartAction()));
+    	controlMenu.add(new JMenuItem(new StopAction()));
+    	controlMenu.add(new JSeparator());
+    	controlMenu.add(new JMenuItem(new CloseAction()));
+    	controlMenu.add(new JMenuItem(new ExitAction()));
+    	
+    	menuBar.add(controlMenu);
+    	
+    	return menuBar;
+    }
+    
+    private class StartAction extends  AbstractAction {
+    	public StartAction() {
+    		super("Start");
+    	}
+    	
+		public void actionPerformed(final ActionEvent e) {
+			applet.start();
+			applet.setEnabled(true);
+		}
+    }
+    
+    private class StopAction extends  AbstractAction {
+    	public StopAction() {
+    		super("Stop");
+    	}
+    	
+		public void actionPerformed(ActionEvent e) {
+			applet.stop();
+			applet.setEnabled(false);
+		}
+    }
+    
+    private class CloseAction extends  AbstractAction {
+    	public CloseAction() {
+    		super("Close");
+    	}
+    	
+		public void actionPerformed(ActionEvent e) {
+			setVisible(false);
+		}
+    }
+    
+    private class ExitAction extends  AbstractAction {
+    	public ExitAction() {
+    		super("Exit");
+    	}
+    	
+		public void actionPerformed(ActionEvent e) {
+			System.exit(0);
+		}
+    }
     
-    private  static class ShutdownHandler implements WindowListener {
+    private static class ShutdownHandler implements WindowListener {
         HashSet<JFrame> frameList = new HashSet<JFrame>();
 
         public void windowActivated(WindowEvent e) {



Mime
View raw message