mainapplet.java
来自「Rapla是一个灵活的多用户资源管理系统。它提供的一些功能有:日历GUI」· Java 代码 · 共 136 行
JAVA
136 行
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by the |
| Free Software Foundation. A copy of the license has been included with |
| these distribution in the COPYING file, if not go to www.fsf.org |
| |
| As a special exception, you are granted the permissions to link this |
| program with every library, which license fulfills the Open Source |
| Definition as published by the Open Source Initiative (OSI). |
*--------------------------------------------------------------------------*/
package org.rapla;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.rapla.framework.StartupEnvironment;
/** The applet-encapsulation of the Main.class reads the configuration
* from the document-base of the applet and displays
* an applet with a start button.
* @author Christopher Kohlhaas
* @see Main
*/
final public class MainApplet extends JApplet
{
private static final long serialVersionUID = 1L;
JPanel dlg = new JPanel();
JButton button;
JLabel label;
boolean startable = false;
public MainApplet()
{
JPanel panel1 = new JPanel();
panel1.setBackground( new Color( 255, 255, 204 ) );
GridLayout gridLayout1 = new GridLayout();
gridLayout1.setColumns( 1 );
gridLayout1.setRows( 3 );
gridLayout1.setHgap( 10 );
gridLayout1.setVgap( 10 );
panel1.setLayout( gridLayout1 );
label = new JLabel( "Rapla-Applet loading" );
panel1.add( label );
button = new JButton( "StartRapla" );
button.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
startThread();
}
} );
panel1.add( button );
dlg.setBackground( new Color( 255, 255, 204 ) );
dlg.setBorder( BorderFactory.createMatteBorder( 1, 1, 2, 2, Color.black ) );
dlg.add( panel1 );
}
public void start()
{
getRootPane().putClientProperty( "defeatSystemEventQueueCheck", Boolean.TRUE );
try
{
setContentPane( dlg );
button.setEnabled( startable );
startable = true;
button.setEnabled( startable );
}
catch ( Exception ex )
{
ex.printStackTrace();
}
}
private void updateStartable()
{
javax.swing.SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
button.setEnabled( startable );
}
} );
}
private void startThread()
{
( new Thread()
{
public void run()
{
try
{
startable = false;
updateStartable();
Main main = new Main();
URL configURL = new URL( getDocumentBase(), "webclient/" + Main.DEFAULT_CLIENT_CONFIG_NAME );
main.init( configURL, StartupEnvironment.APPLET );
main.env.setDownloadURL( getDocumentBase() );
System.out.println( "Docbase " + getDocumentBase() );
main.startRapla();
}
catch ( Exception ex )
{
ex.printStackTrace();
}
finally
{
startable = true;
updateStartable();
}
}
} ).start();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?