vue 实现删除对象的元素 delete
418
2022-08-09
Java GUI实现多个窗口切换效果(java自行车)
本文实例为大家分享了vue + element ui实现锚点定位的具体代码,供大家参考,具体内容如下
功能:
主要实现的功能为实现多个界面的切换,并且一个window的打开和关闭可以影响其他window。
不足:
①可以多次多开同一个界面(可以加一个变量控制)②没有实现一个的窗体关闭,它的子窗体也随即关闭的效果
效果图:
第一个界面(主界面)
package 多界面跳转;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
class Frame1 extends JFrame implements WindowListener
{
JButton b2 = new JButton("界面2");
JButton b11 = new JButton("界面11");
private class btListener implements ActionListener
{
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("界面2"))
{
setVisible(false);
new Frame2();
}
else if(e.getActionCommand().equals("界面11"))
{
new Frame11();
}
}
}
public Frame1()
{
this.setTitle("界面1");
this.setSize(400, 300);
this.setLayout(new FlowLayout());
b11.addActionListener(new btListener());
b2.addActionListener(new btListener());
this.add(b11);
this.add(b2);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
setVisible(true);
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public static void main(String[] args) {
Frame1 f1 = new Frame1();
f1.setVisible(true);
}
}
第二个界面
package 多界面跳转;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class Frame2 extends JFrame implements ActionListener
{
JButton bt = new JButton("界面21");
Frame2()
{
this.setSize(350, 300);
this.setLocationRelativeTo(null);
this.setLayout(new FlowLayout());
this.setTitle("界面2");
this.add(bt);
bt.addActionListener(this);
this.addWindowListener(new Frame1());
this.addWindowListener(new Frame11());
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
new Frame21();
}
}
由第一个界面打开的界面
package 多界面跳转;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
class Frame11 extends JFrame implements WindowListener
{
Frame11()
{
this.setSize(300, 200);
this.setLocationRelativeTo(http://null);
this.setTitle("界面11");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
if(this.isVisible()) {
// setSize(800,600);
}
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-http://generated method stub
}
}
由第二个界面打开的界面
package 多界面跳转;
import javax.swing.*;
import java.awt.*;
class Frame21 extends JFrame
{
Frame21()
{
this.setSize(150, 100);
this.setLocationRelativeTo(null);
this.setTitle("界面21");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~