?? door.java
字號:
package parkproject;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class door extends JPanel implements Runnable
{
int doorWidth=5,doorHeight=0;
volatile boolean moveFlag_on = false;
volatile boolean moveFlag_off = false;
boolean openFlag = false;
boolean completeFlag = true;
int dh = -1;
int width = 5,height;
public door(int h) {
doorHeight = h;
height = h;
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setBackground(UIManager.getColor("activeCaption"));
jLabel1.setForeground(Color.black);
jLabel1.setBorder(BorderFactory.createLineBorder(Color.black));
jLabel1.setText("");
jLabel1.setBounds(new Rectangle(0, 0, 5, 50));
this.setBackground(Color.pink);
this.setLayout(null);
this.add(jLabel1, null);
}
public void run()
{
while(true)
{
if(moveFlag_on)
{
openProcess();
}
if(moveFlag_off)
{
closeProcess();
}
try {
Thread.sleep(40);
}
catch (InterruptedException e) {
}
}
}
JLabel jLabel1 = new JLabel();
public void open()
{
moveFlag_on = true;
}
public void close()
{
moveFlag_off = true;
}
synchronized public void openProcess()
{
for(int i=0;i<50;i++)
{
jLabel1.setBounds(0, 0, 5, height);
try {
Thread.sleep(40);
}
catch (InterruptedException e) {
}
// System.out.println(height+"height:");
height = height -1;
if(height<=1) break;
}
openFlag = true;
moveFlag_on = false;
}
synchronized public void closeProcess()
{
openFlag = false;
for(int i=0;i<50;i++)
{
jLabel1.setBounds(0, 0, 5, height);
try {
Thread.sleep(40);
}
catch (InterruptedException e) {
}
// System.out.println(height+"height:");
height = height +1;
if(height>=49) break;
//break;
}
moveFlag_off = false;
}
public boolean getFlag()
{
return openFlag;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -