📄 radiogui.java
字号:
/* Stream-2-Stream - Peer to peer television and radio
* October 13, 2005 - This file has been modified from the original P2P-Radio source
* Project homepage: http://s2s.sourceforge.net/
* Copyright (C) 2005-2006 Jason Hooks
*/
/*
* P2P-Radio - Peer to peer streaming system
* Project homepage: http://p2p-radio.sourceforge.net/
* Copyright (C) 2003-2004 Michael Kaufmann <hallo@michael-kaufmann.ch>
*
* ---------------------------------------------------------------------------
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------------
*/
package p2pradio.gui;
import java.net.*;
import java.awt.EventQueue;
import java.util.logging.Handler;
import javax.swing.*;
import p2pradio.*;
import p2pradio.logging.*;
import p2pradio.sources.*;
import p2pradio.players.*;
import p2pradio.webinterface.*;
/**
* Starts the GUI and allows the user to enter all necessary
* information like the server address.
*
* @author Michael Kaufmann
*/
public class RadioGUI
{
private MainFrame mainFrame;
private boolean isServer;
/**
* Starts the GUI.
*
* @param portSet Determines if the GUI should use <code>port</code>
* as the port number or ask the user
* @param port The port number of the peer
* @param maxUploadBandwidthSet Determines if the GUI should use <code>maxUploadBandwidth</code>
* as the maximal upload bandwidth or ask the user
* @param maxUploadBandwidth The maximal upload bandwidth that the peer can use
* @param logHandlerToClose This log handler will be closed after the GUI is visible. Can be <TT>null</TT>
*/
public RadioGUI(Handler logHandlerToClose, boolean isServer)
{
this.isServer = isServer;
showMainFrame();
if (logHandlerToClose != null)
{
logHandlerToClose.close();
}
}
/**
* Starts the GUI, but doesn't ask the user anything and doesn't
* create the {@link Peer} object itself.
* This method is used by the command line interface.
*
* @param logHandlerToClose This log handler will be closed after the GUI is visible. Can be <TT>null</TT>
*/
public RadioGUI(Handler logHandlerToClose)
{
// Manueller Modus
showMainFrame();
if (logHandlerToClose != null)
{
logHandlerToClose.close();
}
}
private void showMainFrame()
{
setLookAndFeel();
mainFrame = new MainFrame(this);
if (Radio.startMinimized)
{
mainFrame.setState(JFrame.ICONIFIED);
}
mainFrame.setVisible(true);
mainFrame.doBandwidthTest();
}
public static void setLookAndFeel()
{
try
{
/*
javax.swing.UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
for (int i=0; i < lookAndFeels.length; i++)
{
System.out.println(lookAndFeels[i].getName() + " (" + lookAndFeels[i].getClassName() + ")");
}
*/
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
Logger.severe("RadioGUI", "INTERNAL_ERROR", e); //$NON-NLS-1$ //$NON-NLS-2$
}
catch (Throwable t)
{
// InternalError, weil nicht auf X11 zugegriffen werden kann
System.out.println(t.getMessage());
System.out.println(Messages.getString("RadioGUI.HINT_USE_CONSOLEUI_PARAMETER")); //$NON-NLS-1$
System.exit(1);
}
}
public boolean getIsServer()
{return isServer;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -