001: /**********************************************************************************
002: * $URL$
003: * $Id$
004: ***********************************************************************************
005: *
006: * Copyright (c) 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.audio;
021:
022: import java.util.Locale;
023: import java.util.ResourceBundle;
024:
025: import java.awt.Dimension;
026: import java.awt.Toolkit;
027: import java.awt.event.WindowAdapter;
028: import java.awt.event.WindowEvent;
029: import javax.swing.JApplet;
030: import javax.swing.JFrame;
031:
032: public class AudioRecorderApplet extends JApplet {
033: static ResourceBundle res;
034:
035: boolean isStandalone = false;
036:
037: // Get a parameter value
038: public String getParameter(String key, String def) {
039: return isStandalone ? System.getProperty(key, def)
040: : (getParameter(key) != null ? getParameter(key) : def);
041: }
042:
043: // Construct the applet
044: public AudioRecorderApplet() {
045: }
046:
047: // Initialize the applet
048: static AudioRecorderApplet applet;
049:
050: private AudioPanel demo;
051:
052: private AudioRecorderParams params;
053:
054: public void init() {
055: applet = this ;
056: if (isStandalone) {
057: params = new AudioRecorderParams();
058: } else {
059: params = new AudioRecorderParams(applet);
060: }
061: res = AudioUtil.getInstance().getResourceBundle();
062:
063: String media = res.getString("_audio");
064: String param = null;
065:
066: //"Center" means center position
067: getContentPane().add("Center",
068: demo = new AudioPanel(media, params));
069: }
070:
071: private void initAppletParams() {
072: AudioRecorderParams params = this .params;
073: }
074:
075: // Component initialization
076: private void jbInit() throws Exception {
077: }
078:
079: // Start the applet
080: public void start() {
081: }
082:
083: // Stop the applet
084: public void stop() {
085: }
086:
087: // Destroy the applet
088: public void destroy() {
089: }
090:
091: // Get Applet information
092: public String getAppletInfo() {
093: return (res.getString("Applet_Information"));
094: }
095:
096: // Get parameter info
097: public String[][] getParameterInfo() {
098: return null;
099: }
100:
101: /**
102: * Main method. Run as an application.
103: *
104: * @param args
105: */
106: public static void main(String[] args) {
107: AudioRecorderApplet applet = new AudioRecorderApplet();
108: applet.isStandalone = true;
109: JFrame f = new JFrame(res.getString("Audio_Recorder"));
110: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
111: /*
112: * old way to exit program when window is closed - daisyf, 04/06/06
113: * f.addWindowListener(new WindowAdapter() { public void
114: * windowClosing(WindowEvent e) { System.exit(0); } });
115: */
116: f.getContentPane().add("Center", applet);
117: f.pack();
118: Dimension screenSize = Toolkit.getDefaultToolkit()
119: .getScreenSize();
120: int w = 450;
121: int h = 450;
122: f.setLocation(screenSize.width / 2 - w / 2, screenSize.height
123: / 2 - h / 2);
124: applet.init();
125: applet.start();
126: f.setSize(w, h);
127: f.show();
128: }
129:
130: public AudioRecorderParams getParams() {
131: return params;
132: }
133:
134: }
|