当前位置: 代码迷 >> Eclipse >> 有艰难,找大神嘿嘿
  详细解决方案

有艰难,找大神嘿嘿

热度:389   发布时间:2016-04-22 23:41:43.0
有困难,找大神嘿嘿
import javax.swing.*;

//import java.awt.event.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.BorderLayout;
public class MyFrame extends JFrame {
private JMenuBar menuBar;
private JMenu filemenu;
private JMenuItem newItem,openItem,saveItem,exit;
private JPanel mypanel;
private JPanel panelsouth;
private JPanel panelcenter;
// private JPanel paneleast;
// private JPanel panelwest;
private JPanel panelnorth;
private JLabel labF,labT,labname,labkeyword,labintroduction,labhobby,labSex,labmonth,labyear,labcard;
private JTextField tf;
private JPasswordField pwf;
private JTextArea ta;
private JButton btn1;
private JButton btn2;
private JCheckBox chkMusic;
private JCheckBox chkSports;
private JCheckBox chkRead;
private JCheckBox chkTravel;
private JRadioButton rbtMale;
private JRadioButton rbtFamale;
private ButtonGroup grp;
private JComboBox cmbYear;
private JComboBox cmbMonth;
private JComboBox cmbcard;

public MyFrame(String s){
super(s);
setSize(350,450);
setLocation(400,200);

menuBar=new JMenuBar();
filemenu=new JMenu("文件");
newItem=new JMenuItem("新建");
openItem=new JMenuItem("打开");
saveItem=new JMenuItem("保存");
exit=new JMenuItem("退出");

frm.setJMenuBar(menuBar);
menuBar.add(filemenu);
filemenu.add(newItem);
filemenu.add(openItem);
filemenu.add(saveItem);
filemenu.addSeparator();
filemenu.add(exit);


mypanel=new JPanel();
setContentPane(mypanel);
mypanel.setBackground(Color.blue);
mypanel.setLayout(new BorderLayout());
panelsouth=new JPanel();
//panelsouth.setBackground(Color.blue);
panelcenter=new JPanel();
//panelcenter.setBackground(Color.blue);
// paneleast=new JPanel();
//paneleast.setBackground(Color.blue);
// panelwest=new JPanel();
//panelwest.setBackground(Color.blue);
panelnorth=new JPanel();
//panelnorth.setBackground(Color.blue);


Icon icon=new ImageIcon("160037.jpg");
btn1=new JButton("确定",icon);
btn1.setIcon(icon);
btn1.setBackground(Color.YELLOW);
btn1.setForeground(Color.RED);
Font font1=new Font("华文彩云",Font.BOLD+Font.ITALIC,20);
btn1.setFont(font1);
btn2=new JButton("取消");
btn2.setBackground(Color.YELLOW);
btn2.setForeground(Color.RED);
Font font2=new Font("华文彩云",Font.BOLD+Font.ITALIC,20);
btn2.setFont(font2);

labF=new JLabel("请按取消!");
labF.setForeground(Color.BLACK);
labT=new JLabel("请按确定!");
labT.setForeground(Color.BLACK);
labname=new JLabel("用户名:");
labname.setForeground(Color.BLACK);
tf=new JTextField(20);
labkeyword=new JLabel("密    码 :");
labkeyword.setForeground(Color.BLACK);
pwf=new  JPasswordField(20);
labintroduction=new JLabel("简    介 :");
labintroduction.setForeground(Color.BLACK);
ta=new JTextArea(10,20); 

labhobby=new JLabel("爱    好:");
labhobby.setForeground(Color.BLACK);
chkMusic=new JCheckBox("音乐");
chkMusic.setBackground(Color.ORANGE);
chkSports=new JCheckBox("体育");
chkSports.setBackground(Color.ORANGE);
chkRead=new JCheckBox("阅读");
chkRead.setBackground(Color.ORANGE);
chkTravel=new JCheckBox ("旅游");
chkTravel.setBackground(Color.ORANGE);

labSex=new JLabel("性    别:");
labSex.setForeground(Color.BLACK);
rbtMale=new JRadioButton("男");
rbtMale.setBackground(Color.RED);
rbtFamale=new JRadioButton("女"); 
rbtFamale.setBackground(Color.RED);
grp=new ButtonGroup();
grp.add(rbtMale);
grp.add(rbtFamale);

labyear=new JLabel("年          份");
labyear.setForeground(Color.BLACK);
String[]  year=new String[20];
for(int i=1993;i<=2014;i++)
year[i-1]=i+"年";
cmbYear=new JComboBox(year);
labmonth=new JLabel("月          份:");
labmonth.setForeground(Color.BLACK);
String month[]=new String[12];
for(int i=1;i<=12;i++)
month[i-1]=i+"月";
cmbMonth=new JComboBox(month);

labcard=new JLabel("证件类型:");
labcard.setForeground(Color.BLACK);
String card[]={"身份证","驾驶证","学生证","护照","军官证","其他"};
cmbcard=new JComboBox(card);


panelsouth.add(labT);
panelsouth.add(btn1);
panelsouth.add(labF);
panelsouth.add(btn2);
panelcenter.add(labname);
panelcenter.add(tf);
panelcenter.add(labkeyword);
panelcenter.add(pwf);
panelcenter.add(labintroduction);
panelcenter.add(ta);
panelcenter.add(labhobby);
panelcenter.add(chkMusic);
panelcenter.add(chkSports);
panelcenter.add(chkRead);
panelcenter.add(chkTravel);

panelcenter.add(labSex);
panelcenter.add(rbtMale);
panelcenter.add(rbtFamale);
panelcenter.add(labcard);
panelcenter.add(cmbcard);
panelnorth.add(labmonth);
panelnorth.add(cmbMonth);
panelnorth.add(labyear);
panelnorth.add(cmbYear);

mypanel.add(panelsouth,BorderLayout.SOUTH);
mypanel.add(panelcenter,BorderLayout.CENTER);
// mypanel.add(paneleast,BorderLayout.EAST);
// mypanel.add(panelwest,BorderLayout.WEST);
mypanel.add(panelnorth,BorderLayout.NORTH);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}

------解决思路----------------------
没看代码具体在干嘛,不过我帮你改了一下错误现在能正常运行了。
代码框在表情的左边,选择正确语言,将代码复制到“[code]”与“[/code]”之间就可以了,这么简单不会用?
另外回复楼层请使用楼层右下角的“引用了。


import java.awt.*;
import javax.swing.*;

public class MyFrame extends JFrame {
private static final long serialVersionUID = 2338018319707531329L;

private JMenuBar menuBar;
private JMenu filemenu;
private JMenuItem newItem, openItem, saveItem, exit;
private JPanel mypanel;
private JPanel panelsouth;
private JPanel panelcenter;
private JPanel panelnorth;
private JLabel labF, labT, labname, labkeyword,
labintroduction, labhobby, labSex, labmonth, labyear, labcard;
private JTextField tf;
private JPasswordField pwf;
private JTextArea ta;
private JButton btn1;
private JButton btn2;
private JCheckBox chkMusic;
private JCheckBox chkSports;
private JCheckBox chkRead;
private JCheckBox chkTravel;
private JRadioButton rbtMale;
private JRadioButton rbtFamale;
private ButtonGroup grp;
private JComboBox cmbYear;
private JComboBox cmbMonth;
private JComboBox cmbcard;

public MyFrame(String s) {
super(s);
setSize(350, 450);
setLocation(400, 200);

menuBar = new JMenuBar();
filemenu = new JMenu("文件");
newItem = new JMenuItem("新建");
openItem = new JMenuItem("打开");
saveItem = new JMenuItem("保存");
exit = new JMenuItem("退出");

setJMenuBar(menuBar);
menuBar.add(filemenu);
filemenu.add(newItem);
filemenu.add(openItem);
filemenu.add(saveItem);
filemenu.addSeparator();
filemenu.add(exit);

mypanel = new JPanel();
setContentPane(mypanel);
mypanel.setBackground(Color.blue);
mypanel.setLayout(new BorderLayout());
panelsouth = new JPanel();
panelcenter = new JPanel();
panelnorth = new JPanel();

Icon icon = new ImageIcon("160037.jpg");
btn1 = new JButton("确定", icon);
btn1.setIcon(icon);
btn1.setBackground(Color.YELLOW);
btn1.setForeground(Color.RED);
Font font1 = new Font("华文彩云", Font.BOLD + Font.ITALIC, 20);
btn1.setFont(font1);
btn2 = new JButton("取消");
btn2.setBackground(Color.YELLOW);
btn2.setForeground(Color.RED);
Font font2 = new Font("华文彩云", Font.BOLD + Font.ITALIC, 20);
btn2.setFont(font2);

labF = new JLabel("请按取消!");
labF.setForeground(Color.BLACK);
labT = new JLabel("请按确定!");
labT.setForeground(Color.BLACK);
labname = new JLabel("用户名:");
labname.setForeground(Color.BLACK);
tf = new JTextField(20);
labkeyword = new JLabel("密    码 :");
labkeyword.setForeground(Color.BLACK);
pwf = new JPasswordField(20);
labintroduction = new JLabel("简    介 :");
labintroduction.setForeground(Color.BLACK);
ta = new JTextArea(10, 20);

labhobby = new JLabel("爱    好:");
labhobby.setForeground(Color.BLACK);
chkMusic = new JCheckBox("音乐");
chkMusic.setBackground(Color.ORANGE);
chkSports = new JCheckBox("体育");
chkSports.setBackground(Color.ORANGE);
chkRead = new JCheckBox("阅读");
chkRead.setBackground(Color.ORANGE);
chkTravel = new JCheckBox("旅游");
chkTravel.setBackground(Color.ORANGE);

labSex = new JLabel("性    别:");
labSex.setForeground(Color.BLACK);
rbtMale = new JRadioButton("男");
rbtMale.setBackground(Color.RED);
rbtFamale = new JRadioButton("女");
rbtFamale.setBackground(Color.RED);
grp = new ButtonGroup();
grp.add(rbtMale);
grp.add(rbtFamale);

labyear = new JLabel("年          份");
labyear.setForeground(Color.BLACK);
String[] year = new String[22];
for (int i = 1993; i <= 2014; i++)
year[i - 1993] = i + "年";
cmbYear = new JComboBox(year);
labmonth = new JLabel("月          份:");
labmonth.setForeground(Color.BLACK);
String month[] = new String[12];
for (int i = 1; i <= 12; i++)
month[i - 1] = i + "月";
cmbMonth = new JComboBox(month);

labcard = new JLabel("证件类型:");
labcard.setForeground(Color.BLACK);
String card[] = {"身份证", "驾驶证", "学生证", "护照", "军官证", "其他"};
cmbcard = new JComboBox(card);

panelsouth.add(labT);
panelsouth.add(btn1);
panelsouth.add(labF);
panelsouth.add(btn2);
panelcenter.add(labname);
panelcenter.add(tf);
panelcenter.add(labkeyword);
panelcenter.add(pwf);
panelcenter.add(labintroduction);
panelcenter.add(ta);
panelcenter.add(labhobby);
panelcenter.add(chkMusic);
panelcenter.add(chkSports);
panelcenter.add(chkRead);
panelcenter.add(chkTravel);

panelcenter.add(labSex);
panelcenter.add(rbtMale);
panelcenter.add(rbtFamale);
panelcenter.add(labcard);
panelcenter.add(cmbcard);
panelnorth.add(labmonth);
panelnorth.add(cmbMonth);
panelnorth.add(labyear);
panelnorth.add(cmbYear);

mypanel.add(panelsouth, BorderLayout.SOUTH);
mypanel.add(panelcenter, BorderLayout.CENTER);
mypanel.add(panelnorth, BorderLayout.NORTH);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {
new MyFrame("");
}
}
  相关解决方案