📄 worldobjecteditpanel.java
字号:
/*
* WorldObjectEditPanel.java
*
* Copyright (C) 2000 Jason M. Hanley
* Released under the GNU General Public License (GPL)
* See license.txt for additional information.
*
* Created on August 5, 2000, 12:19 AM
*/
package fate.world.edit;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import fate.ui.*;
import fate.util.*;
import fate.world.*;
/**
* UI for editing any type of {@link WorldObject} object.
* @author preylude@s3m.com
* @version 0.1.0
*/
public class WorldObjectEditPanel extends JPanel
implements ActionListener {
Box boxMain;
JPanel boxButtons;
JTextField editID, editName;
protected JButton buttonModify;
protected final WorldEditDialog parent;
WorldObject data;
/** Creates new OrbitingBodyEditPanel */
public WorldObjectEditPanel( final WorldEditDialog parent ) {
this.parent = parent;
this.data = null;
setLayout( new BorderLayout() );
boxMain = new Box( BoxLayout.Y_AXIS );
JPanel panel = new JPanel();
panel.add( boxMain );
add( panel, BorderLayout.CENTER );
boxButtons = new JPanel();
add( boxButtons, BorderLayout.SOUTH );
editID = SwingUtil.addTextField( boxMain, "Object ID", 10 );
editID.setEditable( false );
editName = SwingUtil.addTextField( boxMain, "Name", 32 );
buttonModify = SwingUtil.addButton( boxButtons, "Modify", 'm', "Modify", this );
buttonModify.setEnabled( false );
}
public void setData( WorldObject data ) {
this.data = data;
if( data != null ) {
buttonModify.setEnabled( true );
membersToControls();
} else {
buttonModify.setEnabled( false );
}
}
/** Transfers data from members to GUI controls */
public void membersToControls() {
editID.setText( Integer.toString( data.id ) );
editName.setText( data.name );
}
/** Transfers data from members to GUI controls */
public void controlsToMembers() {
data.name = editName.getText();
}
public void actionPerformed( ActionEvent e ) {
String strAction = e.getActionCommand();
Debug.trace( "WorldObjectEditPanel: Action: " + strAction );
if ( strAction.equals( "Modify" ) ) {
controlsToMembers();
}
// Update the object tree in the parent dialog
parent.updateTree();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -