日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 点允许没有反应 程序有main_我的java程序点击相应的button键没有反应?我想要实现的功能是点击“左齐”键,按钮左对齐,依此类推;...

發(fā)布時間:2024/10/14 编程问答 33 豆豆

我的源程序如下:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassfirstextendsJFrameimplementsActionListener{Containerc;JButtonle=newJButton("左齊");...

我的源程序如下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class first extends JFrame implements ActionListener

{

Container c;

JButton le=new JButton("左齊");

JButton mi=new JButton("居中");

JButton ri=new JButton("右齊");

FlowLayout fl=new FlowLayout();

public first()

{

super("流水版面配置");

c=getContentPane();

c.setLayout(fl);

c.add(le);

c.add(mi);

c.add(ri);

le.addActionListener(this);

mi.addActionListener(this);

ri.addActionListener(this);

setSize(400,200);

setVisible(true);

}

public void actionPerformed(ActionEvent e)

{

String s=e.getActionCommand();

if(s.equals("左齊"))

{

fl.setAlignment(FlowLayout.LEFT);

//this.invalidate();

//c.setLayout(fl);

System.out.println(s);

}

else

if(s.equals("居中"))

{

fl.setAlignment(FlowLayout.CENTER);

//this.invalidate();

//c.setLayout(fl);

System.out.println(s);

}

else

{

fl.setAlignment(FlowLayout.RIGHT);

//this.invalidate();

//c.setLayout(fl);

System.out.println(s);

}

}

public static void main(String[] args)

{

first f=new first();

f.addWindowListener(new MyWindowListener());

}

}

其中用到的MyWindowListener這個類的內(nèi)容如下:

import java.awt.event.*;

public class MyWindowListener implements WindowListener

{

public void windowActivated(WindowEvent e)

{

System.out.println("窗口為活動狀態(tài)");

}

public void windowClosed(WindowEvent e)

{

System.out.println("窗口為關(guān)閉狀態(tài)");

System.exit(0);

}

public void windowClosing(WindowEvent e)

{

System.out.println("窗口正在關(guān)閉");

System.exit(0);

}

public void windowDeactivated(WindowEvent e)

{

System.out.println("窗口不再活動");

}

public void windowDeiconified(WindowEvent e)

{

System.out.println("窗口由最小化變?yōu)檎?#34;);

}

public void windowIconified(WindowEvent e)

{

System.out.println("窗口為最小化");

}

public void windowOpened(WindowEvent e)

{

System.out.println("窗口首次可見");

}

}

展開

總結(jié)

以上是生活随笔為你收集整理的java 点允许没有反应 程序有main_我的java程序点击相应的button键没有反应?我想要实现的功能是点击“左齐”键,按钮左对齐,依此类推;...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。