📄 serverpanel.java
字号:
/*
* ServerPanel.java
*
* Created on 9 pa焏ziernik 2005, 09:53
*/
package net.sf.jawp.game.server.gui;
/**
*
* @author jarek
*/
public class ServerPanel extends javax.swing.JPanel
{
private static final long serialVersionUID = 1L;
private final ServerDataManager dataManager;
/** Creates new form ServerPanel */
public ServerPanel(final ServerDataManager dm)
{
initComponents();
this.dataManager = dm;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents()
{
java.awt.GridBagConstraints gridBagConstraints;
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
runningRadioButton = new javax.swing.JRadioButton();
stoppedRadioButton = new javax.swing.JRadioButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
usersTextField = new javax.swing.JTextField();
gamesTextField = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
startButton = new javax.swing.JButton();
stopButton = new javax.swing.JButton();
setLayout(new java.awt.GridBagLayout());
setPreferredSize(new java.awt.Dimension(300, 84));
jPanel1.setLayout(new java.awt.GridBagLayout());
jPanel1.setBorder(new javax.swing.border.TitledBorder("Status"));
runningRadioButton.setText("running");
runningRadioButton.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weighty = 0.2;
jPanel1.add(runningRadioButton, gridBagConstraints);
stoppedRadioButton.setSelected(true);
stoppedRadioButton.setText("stopped");
stoppedRadioButton.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weighty = 0.2;
jPanel1.add(stoppedRadioButton, gridBagConstraints);
jLabel1.setText("users");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 0.2;
jPanel1.add(jLabel1, gridBagConstraints);
jLabel2.setText("games");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.weightx = 0.5;
gridBagConstraints.weighty = 0.2;
jPanel1.add(jLabel2, gridBagConstraints);
usersTextField.setEditable(false);
usersTextField.setText("0");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 0.5;
jPanel1.add(usersTextField, gridBagConstraints);
gamesTextField.setEditable(false);
gamesTextField.setText("0");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanel1.add(gamesTextField, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.8;
gridBagConstraints.weighty = 1.0;
add(jPanel1, gridBagConstraints);
jPanel2.setLayout(new java.awt.GridBagLayout());
jPanel2.setBorder(new javax.swing.border.TitledBorder("Control"));
startButton.setText("Start");
startButton.setEnabled(false);
startButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
startButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
jPanel2.add(startButton, gridBagConstraints);
stopButton.setText("Stop");
stopButton.setEnabled(false);
stopButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
stopButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.weighty = 1.0;
jPanel2.add(stopButton, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 0.2;
add(jPanel2, gridBagConstraints);
}
// </editor-fold>//GEN-END:initComponents
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_stopButtonActionPerformed
{//GEN-HEADEREND:event_stopButtonActionPerformed
getDataManager().stop();
updateState();
FramesManager.getInstance().fireGameStateChanged();
}//GEN-LAST:event_stopButtonActionPerformed
private void startButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_startButtonActionPerformed
{//GEN-HEADEREND:event_startButtonActionPerformed
getDataManager().start();
updateState();
FramesManager.getInstance().fireGameStateChanged();
}//GEN-LAST:event_startButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JTextField gamesTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JRadioButton runningRadioButton;
private javax.swing.JButton startButton;
private javax.swing.JButton stopButton;
private javax.swing.JRadioButton stoppedRadioButton;
private javax.swing.JTextField usersTextField;
// End of variables declaration//GEN-END:variables
public final void updateState()
{
final boolean running = getDataManager().isRunning();
this.runningRadioButton.setSelected( running );
this.stoppedRadioButton.setSelected( !running );
this.startButton.setEnabled( !running);
this.stopButton.setEnabled( running);
this.usersTextField.setText( String.valueOf(
getDataManager().getGameController().getNumberOfUsers()));
this.gamesTextField.setText( String.valueOf(
getDataManager().getGameController().getNumberOfGames()));
}
private ServerDataManager getDataManager()
{
return this.dataManager;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -