急!!!!!SOS,要考试,求详细的注释,100分~~~

wuhuajieicebite 2004-06-10 10:02:04
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class MaceGUI extends JFrame implements ActionListener {
public MaceGUI() {
super( "Midwest Association for Charisma Enhancement" );
pane = getContentPane();
buttons = new JPanel( new FlowLayout() );
misc = new JPanel( new FlowLayout() );
stList = new JPanel();
married = new JRadioButton( "Married", false );
email = new JTextField( promptE );
name = new JTextField( promptN );
reasons = new JTextArea( promptR );
list = new JList( states ); //** Midwest state names
init();
setVisible( true );
}
public void actionPerformed( ActionEvent e ) {
String cmd = e.getActionCommand();
if ( cmd.equals( submit ) )
submitForm();
else if ( cmd.equals( clear ) )
clearForm();
else if ( cmd.equals( exit ) )
System.exit( 0 );
}
private void submitForm() {
String t = (list.getSelectedValue() == null) ? "none" :
list.getSelectedValue().toString();
post( name.getText(), email.getText(), t,
(married.isSelected()) ? "married" : "not maried",
reasons.getText() );
}
private void clearForm() {
reasons.setText( promptR );
name.setText( promptN );
email.setText( promptE );
married.setSelected( false );
list.getSelectionModel().clearSelection();
}
//*** For now, a stub function that prints to the standard error.
private void post( String n, String e, String s,
String m, String r ) {
System.err.println( n + " " + e + " " + s + "\n" + m + "\n" + r );
}
private void init() {
JLabel j;
Font f = null;
pane.setLayout( new BorderLayout() );
buttons.setBackground( Color.gray );
email.setFont( f = new Font( "Dialog", Font.BOLD, 12 ) );
name.setFont( f );
reasons.setFont( f );
reasons.setLineWrap( true );
misc.add( name ); misc.add( email ); misc.add( married );
list.setFont( f );
list.setBackground( Color.cyan );
list.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_SELECTION );
stList.setLayout( new BoxLayout( stList, BoxLayout.Y_AXIS ) );
stList.add( j = new JLabel( "Home state " ) );
j.setFont( f );
j.setForeground( Color.black );
stList.add( list );
addButton( submit ); addButton( clear ); addButton( exit );
pane.add( buttons, BorderLayout.NORTH );
pane.add( reasons, BorderLayout.CENTER );
pane.add( stList, BorderLayout.WEST );
pane.add( misc, BorderLayout.SOUTH );
pack();
}
private void addButton( String name ) {
JButton b = new JButton( name );
b.setFont( new Font( "Dialog", Font.BOLD, 14 ) );
b.addActionListener( this );
buttons.add( b );
}
//*** instance fields
private Container pane;
private JPanel buttons, misc, stList;
private JList list;
private JRadioButton married;
private JTextField email, name;
private JTextArea reasons;
//*** class fileds
private final static String submit = " Submit ";
private final static String clear = " Clear ";
private final static String exit = " Exit ";
private final static String promptN =
"First and last name ";
private final static String promptE =
"E-mail address ";
private final static String promptR =
" My charisma needs enhancement because";
private final static String[ ] states =
{ "Illinois", "Indiana", "Iowa", "Kansas", "Minnesota",
"Michigan", "Missouri", "Nebraska", "Ohio", "Wisconsin" };
}
要考试,请各位高手帮帮忙,谢谢先!!!
...全文
58 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hq1305018 2004-06-10
  • 打赏
  • 举报
回复
这里也有啊?可和那个一样啊?
tnt_tnt 2004-06-10
  • 打赏
  • 举报
回复
晕倒,早知道你是要考试,我还是不要帮你写出来了!!!!!!
居然发了多个帖子!!!
还是多努点力吧

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧