導航:首頁 > 編程語言 > javabm

javabm

發布時間:2022-04-24 22:07:29

java 高分 求代碼注釋

天天都來啊.
1、else if(method.equals("addKh")){
String xm=request.getParameter("xm");
String gsmc=request.getParameter("gsmc");
String dh=request.getParameter("dh");
String cz=request.getParameter("cz");
String bm=request.getParameter("bm");
String zw=request.getParameter("zw");
String lxr=request.getParameter("lxr");
String yjr=request.getParameter("yjr");
String jx=request.getParameter("jx");
String hmrq=request.getParameter("hmrq");
String hzqk=request.getParameter("hzqk");
String username=(String)session.getAttribute("user");
int flag=yb.addKh(xm, gsmc, dh, cz, bm, zw, lxr, yjr, jx, hmrq, hzqk, username);

///\上面是從前台得到值,然後把得到的值傳給addKh方法添加
if(flag==Constant.SUCCESS){ //如果添加結果成功了
request.setAttribute("message", "操作成功!"); //保存成功信息
request.getRequestDispatcher("admin/yao/leibie.jsp").forward(request, response); //跳到leibie.jsp頁面
}
else{ //如果添加失敗
request.setAttribute("message", "系統維護中,請稍後再試!"); //保存失敗信息
request.getRequestDispatcher("admin/yao/leibie.jsp").forward(request, response); //跳到leibie.jsp頁面
}
}

2、 //這個是也是添加和1不同的是這個是從上傳的文件中取得信息的.
try{
mySmartUpload.initialize(config,request,response); //初始化上傳組件
mySmartUpload.upload(); //上傳
method = mySmartUpload.getRequest().getParameter("method").trim(); //得到方法名,判斷是是不是要新增合同
if(method.equals("addHt")){//增加合同 如果是要增加合同
String kid =mySmartUpload.getRequest().getParameter("kid");
String lxfs =mySmartUpload.getRequest().getParameter("lxfs");
String qyrq =mySmartUpload.getRequest().getParameter("qyrq");
String hwmc =mySmartUpload.getRequest().getParameter("hwmc");
String sl =mySmartUpload.getRequest().getParameter("sl");
String jg =mySmartUpload.getRequest().getParameter("jg");
String ghq =mySmartUpload.getRequest().getParameter("ghq");
String bz =mySmartUpload.getRequest().getParameter("bz");
String remark =mySmartUpload.getRequest().getParameter("remark");
String username=(String)session.getAttribute("user");
//上面的值是從客戶上傳的文件中得到的.和1有點相似.只不過1的信息是從頁面上的輸入框中得到的.
SmartFile file = mySmartUpload.getFiles().getFile(0); String fileExt=file.getFileExt();
String path="/upload_file/file";
count = mySmartUpload.save(path);
//把從文件中得到的信息傳給addHt方法.和1是一樣的了.
int flag = yb.addHt(kid, lxfs, qyrq, hwmc, sl, jg, ghq, bz,remark, path+"/"+file.getFileName(), username);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加成功!");
request.getRequestDispatcher("admin/ht/index.jsp").forward(request, response);
} //如果成功--保存成功信息--跳轉頁面
else{
request.setAttribute("message", "系統維護中,請稍後再試!");
request.getRequestDispatcher("admin/ht/index.jsp").forward(request, response);//如果失敗--保存失敗信息--跳轉頁面

② java 編寫一個學生和教師數據輸入和顯示程序,

classPerson{
publicStringBh;//編號
publicStringXm;//姓名
publicPerson(){}
publicPerson(Stringbh,Stringxm){
this.Bh=bh;
this.Xm=xm;
}
publicvoidtalk(){
System.out.println("我是:"+Xm+",我的編號是:"+Bh);
}
}
classTeacherextendsPerson{
publicStringZc;//職稱
publicStringBm;//部門
publicTeacher(){}
publicTeacher(Stringbh,Stringxm,Stringzc,Stringbm){
super(bh,xm);
this.Zc=zc;
this.Bm=bm;
}
publicvoidtalk(){
super.talk();
System.out.println("現在的職稱是:"+Zc+",正在"+Bm+"工作");
}
}
classStudentextendsPerson{
publicStringBj;//班級
publicintCj;//成績
publicStudent(){}
publicStudent(Stringbh,Stringxm,Stringbj,intcj){
super(bh,xm);
this.Bj=bj;
this.Cj=cj;
}
publicvoidtalk(){
super.talk();
System.out.println("所在的班號是:"+Bj+",成績="+Cj);
}
}
publicclassTest1{
publicstaticvoidmain(Stringargs[]){

//Person類的測試
System.out.println("Person類的測試");
Personp1=newPerson();
Personp2=newPerson("P002","第二人");
p1.Bh="P001";
p1.Xm="第一人";
p1.talk();
p2.talk();

//Teacher類的測試
System.out.println(" Teacher類的測試");
Teachert1=newTeacher();
Teachert2=newTeacher("T002","第二師","教授","教務處");
t1.Bh="T001";t1.Xm="第一師";t1.Zc="講師";t1.Bm="計劃部";
t1.talk();
t2.talk();

//Student類的測試
System.out.println(" Student類的測試");
Students1=newStudent();
Students2=newStudent("S002","第二生","98-2班",90);
s1.Bh="S001";s1.Xm="第一生";s1.Bj="98-1班";s1.Cj=85;
s1.talk();
s2.talk();
}
}

//剛學習寫JAVA,多多包涵

③ 急求java簡易計算器代碼

試試下面的代碼 絕對沒有錯誤。
package main;

import java.awt.Button;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class app7 extends JFrame implements ActionListener {
static Panel pan = new Panel();
static JTextField textField = new JTextField("0");
static Button b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, bp, ba, bs, bm, bd,
be, bc, bt, bf, bh;
private StringBuffer temp = new StringBuffer("");
private String optValue = "0";
private String optType="";
private boolean isChoiseOptType=true;
public void init() {
b0 = new Button("0");
b0.addActionListener(this);
b1 = new Button("1");
b1.addActionListener(this);
b2 = new Button("2");
b2.addActionListener(this);
b3 = new Button("3");
b3.addActionListener(this);
b4 = new Button("4");
b4.addActionListener(this);
b5 = new Button("5");
b5.addActionListener(this);
b6 = new Button("6");
b6.addActionListener(this);
b7 = new Button("7");
b7.addActionListener(this);
b8 = new Button("8");
b8.addActionListener(this);
b9 = new Button("9");
b9.addActionListener(this);
bp = new Button(".");
bp.addActionListener(this);
ba = new Button("+");
ba.addActionListener(this);
bs = new Button("-");
bs.addActionListener(this);
bm = new Button("*");
bm.addActionListener(this);
bd = new Button("/");
bd.addActionListener(this);
be = new Button("=");
be.addActionListener(this);
bc = new Button("c");
bc.addActionListener(this);
bt = new Button("退格");
bt.addActionListener(this);
bf = new Button("1/x");
bf.addActionListener(this);
bh = new Button("+/-");
bh.addActionListener(this);
this.setTitle("計算機");
this.setLayout(null);
this.setSize(260, 300);
this.setResizable(false);
GridLayout grid = new GridLayout(4, 5);
pan.setLayout(grid);
pan.setBounds(20, 60, 150, 120);
textField.setBounds(20, 35, 150, 20);
textField.setBackground(Color.cyan);
textField.setHorizontalAlignment(textField.RIGHT);
textField.setEditable(false);
pan.add(b1);
pan.add(b2);
pan.add(b3);
pan.add(ba);
pan.add(bc);
pan.add(b4);
pan.add(b5);
pan.add(b6);
pan.add(bs);
pan.add(bt);
pan.add(b7);
pan.add(b8);
pan.add(b9);
pan.add(bm);
pan.add(bf);
pan.add(b0);
pan.add(bh);
pan.add(bp);
pan.add(bd);
pan.add(be);
this.add(textField);
this.add(pan);
}

public static void main(String[] args) {
app7 frm = new app7();
frm.init();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setVisible(true);

}

@SuppressWarnings("static-access")
@Override
public void actionPerformed(ActionEvent e) {
String value="0";
if (e.getSource().equals(b0)) {
this.temp.append(b0.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b1)) {
this.temp.append(b1.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b2)) {
this.temp.append(b2.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b3)) {
this.temp.append(b3.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b4)) {
this.temp.append(b4.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b5)) {
this.temp.append(b5.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b6)) {
this.temp.append(b6.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b7)) {
this.temp.append(b7.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b8)) {
this.temp.append(b8.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(b9)) {
this.temp.append(b9.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(bp)) {
if(this.temp.length()<=0)
this.temp.append("0");
this.temp.append(bp.getLabel());
this.textField.setText(this.temp.toString());
isChoiseOptType=false;
} else if (e.getSource().equals(ba)) {
if(!isChoiseOptType){
value=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=value.substring(0,value.length()-1);
}
this.optValue=value;
this.temp=new StringBuffer("");
}
this.optType=ba.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bs)) {
if(!isChoiseOptType){
value=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=value.substring(0,value.length()-1);
}
this.optValue=value;
this.temp=new StringBuffer("");
}
this.optType=bs.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bm)) {
if(!isChoiseOptType){
value=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=value.substring(0,value.length()-1);
}
this.optValue=value;
this.temp=new StringBuffer("");
}
this.optType=bm.getLabel();
isChoiseOptType=true;
} else if (e.getSource().equals(bd)) {
if(!isChoiseOptType){
value=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=value.substring(0,value.length()-1);
}
this.optValue=value;
this.temp=new StringBuffer("");
}
this.optType=bd.getLabel();
isChoiseOptType=true;
}else if (e.getSource().equals(be)) {
if(!this.optType.equals("")){
BigDecimal opt1=new BigDecimal(this.optValue);
value=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
value=value.substring(0,value.length()-1);
}
BigDecimal opt2=new BigDecimal(value);
BigDecimal result=new BigDecimal(0);
if(this.optType.equals("+")){
result=opt1.add(opt2);
}else if(this.optType.equals("-")){
result=opt1.subtract(opt2);
}else if(this.optType.equals("*")){
result=opt1.multiply(opt2);
}else if(this.optType.equals("/")){
result=opt1.divide(opt2);
}else if(this.optType.equals("%")){
result=opt1.remainder(opt2);
}
this.textField.setText(result.toString());
this.temp=new StringBuffer("");
isChoiseOptType=false;
this.optValue="0";
}
} else if (e.getSource().equals(bc)) {
this.temp=new StringBuffer();
this.textField.setText("0");
} else if (e.getSource().equals(bt)) {
value=this.textField.getText();
value=value.substring(0,value.length()-1);
if(value.indexOf("-")>=0 && value.length()<=1){
value="0";
this.temp=new StringBuffer("");
}else{
this.temp=new StringBuffer(value);
}
this.textField.setText(value);
}else if (e.getSource().equals(bh)) {
value=this.textField.getText();
if(value.indexOf("-")==0){
value=value.substring(1,value.length());
}else{
value="-"+value;
}
this.temp=new StringBuffer(value);
this.textField.setText(value);
} else if (e.getSource().equals(bf)) {
this.optValue=this.textField.getText();
if(value.lastIndexOf(".")==value.length()-1){
this.optValue=this.optValue.substring(0,this.optValue.length()-1);
}
Integer opt1=new Integer(this.optValue);
if(!opt1.toString().equals("0")){
this.textField.setText(1.0/opt1.intValue()+"");
System.out.println(1/opt1.intValue()+"");
}else{
this.textField.setText("0");
}
this.temp=new StringBuffer("");
this.optType="";
this.optValue="0";

}
}

}
記住類名是app7.java 包名是main. 如果有不對的地方 到時候在找我 我在線。

④ 編寫Java程序,根據給定的身高和體重計算肥胖指數BMI,並輸出相應的健康標准。BMI計算公式為:

相信很多人都有這樣一種感覺:為什麼相同身高相同體重的兩個人,有人看起來瘦,有人看起來胖,或者是減肥的時候,明明體重沒有下降,甚至還上升了,但是看起來卻瘦下來了。

其實,這其中就是體脂率在起作用。有人過分追求減肥時的體重快速下降,但其實如果體脂率沒小,只是體重下去了,也是虛的。只有當體脂率變小,腰圍等才會變小,視覺上才會看起來「瘦」,這體脂率,指的就是脂肪的重要佔總體重的比例,當體脂率低,意味著身體的脂肪含量少,即使是相同體重的人,看起來也會比較瘦,這就是體脂率的意義。

如果按照概念來看,體脂率的計算公式就是:體脂率=(脂肪重量 ÷ 體重)×100%,通用的體脂率計算公式為:體脂率 =1.2×BMI+0.23× 年齡-5.4-10.8×性別(男為1,女為0),其中BM指的是體重指數,用體重除以身高的平方即可得到。

因此,按照公式就可以計算出自己的體脂率了,如此一來,就可以知道自己是「胖」還是「瘦」。有人就會提出疑問,是不是體脂率越低越好呢?當然不是。

⑤ java應用bm演算法的字元串匹配

判斷是否是數字字元串用val
要使單精度變數X,Y,Z分別保留一位,兩位,三位小數format在窗體顯示用form.print
^<>^

⑥ java中如何取得中文如「中國」在unicode編碼中的表示串

public class Demo
{
public static void main(String[] args)
{
String str="例子";
//數組bm保存的就是"例子"的Unicode代碼點(10進制)
int[] bm=new int[str.length()];

for(int i=0;i<str.length();i++)
{
bm[i]=str.codePointAt(i);
System.out.print(""+bm[i]+" ");
}
}
}

⑦ java計算器程序 附帶說明書

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math;
public class Calculator implements ActionListener{
JFrame f;
JPanel pa[]=new JPanel[6];
JLabel lb;
JTextField ta;
JButton bt[]=new JButton[22];
public Calculator(){
f=new JFrame("計算器小程序");
Container cp=f.getContentPane();
f.setVisible(true);
f.setSize(400,400);
cp.setLayout(new GridLayout(2,1));
pa[0]=new JPanel(new GridLayout(3,1));
cp.add(pa[0]);
pa[1]=new JPanel(new GridLayout(1,2));
pa[2]=new JPanel(new GridLayout(1,2));
cp.add(pa[2]);
pa[3]=new JPanel(new GridLayout(4,3));
pa[2].add(pa[3]);
pa[4]=new JPanel(new GridLayout(4,2));
pa[2].add(pa[4]);
lb=new JLabel("計算器");
pa[0].add(lb);
ta=new JTextField();
pa[0].add(ta);
pa[0].add(pa[1]);
for(int j=0;j<=9;j++){
String m=""+j;
bt[j]=new JButton(m);
bt[j].addActionListener(this);
pa[3].add(bt[j]);
}
bt[10]=new JButton("+");
bt[10].addActionListener(this);
pa[3].add(bt[10]);
bt[11]=new JButton("-");
bt[11].addActionListener(this);
pa[3].add(bt[11]);
bt[12]=new JButton("Backspace");
bt[12].addActionListener(this);
pa[1].add(bt[12]);
bt[13]=new JButton("清空");
bt[13].addActionListener(this);
pa[1].add(bt[13]);
bt[14]=new JButton("/");
bt[15]=new JButton("sqrt");
bt[16]=new JButton("*");
bt[17]=new JButton("+/-");
bt[18]=new JButton("pow");
bt[19]=new JButton("1/x");
bt[20]=new JButton(".");
bt[21]=new JButton("=");
for(int j=14;j<=21;j++) {
bt[j].addActionListener(this);
pa[4].add(bt[j]);
}
f.addWindowListener(new WinLis());
}
public void actionPerformed(ActionEvent e){
for(int i=0;i<=9;i++){
if(e.getSource()==bt[i]){
String n=ta.getText();
String m=n+i;
ta.setText(m);
}
}
if(e.getSource()==bt[10]){
String m=ta.getText();
ta.setText(m+"+");
}
if(e.getSource()==bt[11]){
String m=ta.getText();
ta.setText(m+"-");
}
if(e.getSource()==bt[12]){
String m=ta.getText();
int n=m.length();
if(n>=2){
String c=m.substring(0,n-1);
ta.setText(c);
}
else
ta.setText("");
}
if(e.getSource()==bt[13]){
ta.setText("0");
}
if(e.getSource()==bt[14]){
String m,c;
m=ta.getText();
c=m+"/";
ta.setText(c);
}
if(e.getSource()==bt[15]){
String m=ta.getText();
double n=Double.parseDouble(m);
double s=Math.sqrt(n);
String ss=""+s;
int sn=ss.indexOf('.');
String cs=ss.substring(sn+1);
int len=cs.length();
if(len>1){
ta.setText(ss);
}
else{
String st=""+cs.charAt(0);
int it=Integer.parseInt(st);
if(it>0)
ta.setText(ss);
else
ta.setText(ss.substring(0,sn));
}
}
if(e.getSource()==bt[16]){
String m=ta.getText();
ta.setText(m+"*");
}
if(e.getSource()==bt[17]){
String m=ta.getText();
String mm;
int b=m.indexOf('-');
if(b!=-1){
mm=m.substring(1);
ta.setText(mm);
}
else{
mm=m;
ta.setText("-"+mm);
}
}
if(e.getSource()==bt[18]){
String m=ta.getText();
double n=Double.parseDouble(m);
double s=Math.pow(n,2);
String ss=""+s;
int sn=ss.indexOf('.');
String cs=ss.substring(sn+1);
int len=cs.length();
if(len>1){
ta.setText(ss);
}
else{
String st=""+cs.charAt(0);
int it=Integer.parseInt(st);
if(it>0)
ta.setText(ss);
else
ta.setText(ss.substring(0,sn));
}
}
if(e.getSource()==bt[19]){
}
if(e.getSource()==bt[20]){
String m=ta.getText();
int nm=m.indexOf(".");
/*if(nm==-1){
ta.setText(m+".");
}*/
ta.setText(m+".");
}
if(e.getSource()==bt[21]){
String m=ta.getText();
int a=m.indexOf('+');
int p=m.indexOf('.');
if(a!=-1){
if(p==-1){
int s=Integer.parseInt(m.substring(0,a))+Integer.parseInt(m.substring(a+1));
ta.setText(""+s);
}
else{
double ds=Double.parseDouble(m.substring(0,a))+Double.parseDouble(m.substring(a+1));
ta.setText(""+ds);
}
}
int b=m.indexOf('-');
String bb=""+m.charAt(0);
String bm=m.substring(b+1);
int bn=bm.indexOf('-');
if(b!=-1){
if(bb=="-"&&bn!=-1){
if(p==-1){
int s=Integer.parseInt(m.substring(1,bn))+Integer.parseInt(m.substring(bn+1));
ta.setText("-"+s);
}
else{
double ds=Double.parseDouble(m.substring(1,bn))+Double.parseDouble(m.substring(bn+1));
ta.setText("-"+ds);
}

}
if(b>=1&&bn==-1){
if(p==-1){
int s=Integer.parseInt(m.substring(0,b))-Integer.parseInt(m.substring(b+1));
ta.setText(""+s);
}
else{
double ds=Double.parseDouble(m.substring(0,b))-Double.parseDouble(m.substring(b+1));
ta.setText(""+ds);
}
}
}
int c=m.indexOf('*');
if(c!=-1){
int s1=Integer.parseInt(m.substring(0,c));
int s2=Integer.parseInt(m.substring(c+1));
int s=s1*s2;
ta.setText(""+s);
}
int d=m.indexOf('/');
if(d!=-1){
int s1=Integer.parseInt(m.substring(0,d));
int s2=Integer.parseInt(m.substring(d+1));
if(s2==0){
ta.setText("除以零公式無效");
}
else{
double s=s1/s2;
ta.setText(""+s);
}
}
}
}
class WinLis extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
public static void main(String[] args){
new Calculator();
}
}
我也學java沒多長時間,寫了一個這樣的程序,有許多地方還需要完善,希望可以幫助你一下,沒寫注釋,我覺得你查一書就能看明白的

⑧ java 判斷字元串是不是網址

public static boolean isTopURL(String str){
//轉換為小寫
str = str.toLowerCase();
String domainRules = "com.cn|net.cn|org.cn|gov.cn|com.hk|公司|中國|網路|com|net|org|int|e|gov|mil|arpa|Asia|biz|info|name|pro|coop|aero|museum|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cf|cg|ch|ci|ck|cl|cm|cn|co|cq|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|es|et|ev|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gp|gr|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|ml|mm|mn|mo|mp|mq|mr|ms|mt|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|va|vc|ve|vg|vn|vu|wf|ws|ye|yu|za|zm|zr|zw";
String regex = "^((https|http|ftp|rtsp|mms)?://)"
+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
+ "(([0-9]{1,3}\\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
+ "|" // 允許IP和DOMAIN(域名)
+ "(([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]+\\.)?" // 域名- www.
+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\." // 二級域名
+ "("+domainRules+"))" // first level domain- .com or .museum
+ "(:[0-9]{1,4})?" // 埠- :80
+ "((/?)|" // a slash isn't required if there is no file name
+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
Pattern pattern = Pattern.compile(regex);
Matcher isUrl = pattern.matcher(str);
return isUrl.matches();
}

⑨ java小程序 if(buttonG.getSelection() == BM) 輸出問題

import javax.swing.*;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
public class CTextArea implements ActionListener
{

JRadioButton bm;
JRadioButton bf;
JButton bt;
JFrame f;
ButtonGroup buttonG;
public CTextArea()
{
f= new JFrame("新建 文本文檔.txt -記事本");
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
Container c=f.getContentPane();
c.setLayout(new FlowLayout());
bm=new JRadioButton("男生",true);
bf=new JRadioButton("女生");
bt=new JButton("提交");
buttonG = new ButtonGroup();
buttonG.add(bm);
buttonG.add(bf);
c.add(bm);
c.add(bf);
c.add(bt);
bt.addActionListener(this);

f.setSize(250,150);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String sex=null;
if(e.getSource()==bt)
{
if(bm.isSelected())
{
sex="男生";
}
if(bf.isSelected())
{
sex="女生";
}
JOptionPane.showMessageDialog(null,"性別:"+sex,"你的性別",JOptionPane.INFORMATION_MESSAGE);
}
}
public static void main(String[] args) {

new CTextArea();
}

}
這是我做的一個小例子,希望對你有所幫助。
good luck to you!

閱讀全文

與javabm相關的資料

熱點內容
機明自動編程軟體源碼 瀏覽:325
php埠號設置 瀏覽:540
phperegreplace 瀏覽:319
androidgridview翻頁 瀏覽:537
ssh協議編程 瀏覽:634
如何開我的世界電腦伺服器地址 瀏覽:861
玄關pdf 瀏覽:609
程序員學習論壇 瀏覽:940
程序員的毒雞湯怎麼做 瀏覽:548
安卓怎麼降級軟體到手機 瀏覽:281
雲與伺服器入門書籍推薦產品 瀏覽:636
delphi編程助手 瀏覽:761
電腦遇到伺服器問題怎麼辦 瀏覽:515
加工中心編程結束方法 瀏覽:296
了解什麼是web伺服器 瀏覽:139
面向對象的編程的基本特徵 瀏覽:718
php定時執行任務linux 瀏覽:787
php數組中刪除元素 瀏覽:724
螢石雲伺服器視頻 瀏覽:269
防火牆配置伺服器熱備的虛擬地址 瀏覽:189