📄 soundframe.java
字号:
/*
A basic extension of the java.awt.Frame class
*/
import java.awt.*;
public class SoundFrame extends Frame
{
Applet1 myApplet;
public SoundFrame()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setVisible(false);
setSize(insets().left + insets().right + 430,insets().top + insets().bottom + 270);
button1 = new java.awt.Button();
button1.setActionCommand("button");
button1.setLabel("Play it!");
button1.setBounds(insets().left + 120,insets().top + 48,100,29);
button1.setBackground(new Color(12632256));
add(button1);
setTitle("This is a frame!");
//}}
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymMouse aSymMouse = new SymMouse();
button1.addMouseListener(aSymMouse);
//}}
this.setVisible(true);
}
public SoundFrame(Applet1 myApplet)
{
this();
this.myApplet = myApplet;
}
public SoundFrame(String title)
{
this();
setTitle(title);
}
public synchronized void show()
{
move(50, 50);
super.show();
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets().left, insets().top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.Button button1;
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == SoundFrame.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
hide(); // hide the Frame
}
class SymMouse extends java.awt.event.MouseAdapter
{
public void mouseClicked(java.awt.event.MouseEvent event)
{
Object object = event.getSource();
if (object == button1)
button1_MouseClick(event);
}
}
void button1_MouseClick(java.awt.event.MouseEvent event)
{
// to do: code goes here.
// Here we play a sound using the parent applet!
this.myApplet.play(this.myApplet.getCodeBase(), "comptab.au");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -