java如何实现像eclipse风格一样双击JTabbedPane的标签来实现窗口最大化
展开全部
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
public class Testing extends JFrame implements MouseListener{
private JTabbedPane jtp;
public Testing(String title){
super(title);
jtp = new JTabbedPane();
jtp.addMouseListener(this);
this.add(jtp);
this.setBounds(300, 200, 400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
}
/**
* @param test enter
*/
public static void main(String[] args) {
new Testing("test");
}
@Override
public void mouseClicked(MouseEvent e) {
if(e.getSource() ==jtp){
if (e.getClickCount()==2) {
Dimension size = this.getSize();
int currwidth = size.width;
int currheght = size.height;
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
if (currwidth == width && currheght == height) {
this.setBounds(300, 200, 400, 300);
}
else
this.setBounds(0, 0, width, height);
}
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Random;
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
public class Testing extends JFrame implements MouseListener{
private JTabbedPane jtp;
public Testing(String title){
super(title);
jtp = new JTabbedPane();
jtp.addMouseListener(this);
this.add(jtp);
this.setBounds(300, 200, 400, 300);
this.setVisible(true);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
}
/**
* @param test enter
*/
public static void main(String[] args) {
new Testing("test");
}
@Override
public void mouseClicked(MouseEvent e) {
if(e.getSource() ==jtp){
if (e.getClickCount()==2) {
Dimension size = this.getSize();
int currwidth = size.width;
int currheght = size.height;
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
if (currwidth == width && currheght == height) {
this.setBounds(300, 200, 400, 300);
}
else
this.setBounds(0, 0, width, height);
}
}
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用swt?
eclipse就是swt做的
eclipse就是swt做的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
changeListener?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询