⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabpanehandler.java

📁 UCS (Ultra Corba Simulator) is one more powerful corba client/servant simulator tool than other simi
💻 JAVA
字号:
package com.corba.mnq.ui;

import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JSplitPane;
import javax.swing.border.EmptyBorder;

import net.infonode.tabbedpanel.TabbedPanel;
import net.infonode.tabbedpanel.titledtab.TitledTab;

public class TabPaneHandler {
	private static ImageIcon maxIcon=null;
	private static ImageIcon minIcon=null;
	private static ImageIcon restoreIcon=null;
	private static ImageIcon saveIcon=null;
	private static ImageIcon cleanIcon=null;
	private static ImageIcon closeIcon=null;
	
	public static ImageIcon getMaxIcon(){
		if( maxIcon==null )
			maxIcon=new ImageIcon(ClassLoader.class.getResource("/images/max.gif"));
		return maxIcon;
	}
	public static ImageIcon getMinIcon(){
		if( minIcon==null )
			minIcon=new ImageIcon(ClassLoader.class.getResource("/images/min.gif"));
		return minIcon;
	}
	public static ImageIcon getRestoreIcon(){
		if( restoreIcon==null )
			restoreIcon=new ImageIcon(ClassLoader.class.getResource("/images/restore.gif"));
		return restoreIcon;
	}
	public static ImageIcon getSaveIcon(){
		if( saveIcon==null )
			saveIcon=new ImageIcon(ClassLoader.class.getResource("/images/save.png"));
		return saveIcon;
	}
	public static ImageIcon getClearIcon(){
		if( cleanIcon==null )
			cleanIcon=new ImageIcon(ClassLoader.class.getResource("/images/clear.png"));
		return cleanIcon;
	}
	public static ImageIcon getCloseIcon(){
		if( closeIcon==null )
			closeIcon=new ImageIcon(ClassLoader.class.getResource("/images/close.gif"));
		return closeIcon;
	}

	private static JButton createCloseButton() {
	    JButton closeButton = new JButton(getCloseIcon());
	    closeButton.setOpaque(false);
	    closeButton.setMargin(null);
	    closeButton.setFont(closeButton.getFont().deriveFont(Font.BOLD).deriveFont((float) 10));
	    closeButton.setBorder(new EmptyBorder(1, 1, 1, 1));
	    closeButton.setToolTipText("Close This Window");
	    return closeButton;
}
	public static JButton createCloseTabButton(final TitledTab tab) {
		    JButton closeButton = createCloseButton();
		    closeButton.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		    	  tab.setVisible(false);
		      }
		    });
		    return closeButton;
	}
	  
	public static JButton createCloseTabsButton(final TabbedPanel tabbedPanel) {
		    final JButton closeButton = createCloseButton();
		    closeButton.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		    	  tabbedPanel.setVisible(false);
		      }
		    });
		    return closeButton;
	}
	private static JButton createMaxButton() {
		    JButton closeButton = new JButton(getMaxIcon());
		    closeButton.setOpaque(false);
		    closeButton.setMargin(null);
		    closeButton.setFont(closeButton.getFont().deriveFont(Font.BOLD).deriveFont((float) 10));
		    closeButton.setBorder(new EmptyBorder(1, 1, 1, 1));
		    closeButton.setToolTipText("Maximize");
		    return closeButton;
	}
	public static JButton createMaxButton(final TabbedPanel tabbedPanel,final boolean flag) {
		    final JButton maxButton = createMaxButton();
		    maxButton.addActionListener(new ActionListener() {
			     int oldValue=10;
			    boolean max=false;
		    	public void actionPerformed(ActionEvent e) {
		    		JSplitPane split=null;
			    	Container c=  tabbedPanel.getParent();
		    		if( c instanceof JSplitPane){
		    			split=(JSplitPane)c;
		    		}else {
		    			split=(JSplitPane)c.getParent();
		    		}

			    	  if( flag ){
				    	  if(max){
				    		  split.setDividerLocation(oldValue);
				    		  maxButton.setIcon(getMaxIcon());
				    		  max=false;
				    		  maxButton.setToolTipText("Maximize");
				    	  }else{
				    		  oldValue=split.getDividerLocation();
					    	  split.setDividerLocation(split.getMaximumDividerLocation());
					    	  maxButton.setIcon(getRestoreIcon());
					    	  max=true;
					    	  maxButton.setToolTipText("Restore");
				    	  }
			    	  }else{
				    	  if(max){
				    		  split.setDividerLocation(oldValue);
				    		  maxButton.setIcon(getMaxIcon());
				    		  maxButton.setToolTipText("Maximize");
				    		  max=false;
				    	  }else{
				    		  oldValue=split.getDividerLocation();
					    	  split.setDividerLocation(split.getMinimumDividerLocation());
					    	  maxButton.setIcon(getRestoreIcon());
					    	  max=true;
					    	  maxButton.setToolTipText("Restore");
				    	  }
			    	  }
		    	}
		    });
		    return maxButton;
	}	
	private static JButton createMinButton() {
	    JButton closeButton = new JButton(getMinIcon());
	    closeButton.setOpaque(false);
	    closeButton.setMargin(null);
	    closeButton.setFont(closeButton.getFont().deriveFont(Font.BOLD).deriveFont((float) 10));
	    closeButton.setBorder(new EmptyBorder(1, 1, 1, 1));
	    closeButton.setToolTipText("Minimize");
	    return closeButton;
	}
	public static JButton createMinButton(final TabbedPanel tabbedPanel,final boolean flag) {
	    final JButton minButton = createMinButton();
	    minButton.addActionListener(new ActionListener() {
	    	int oldValue=10;
	    	boolean min=false;
	    	public void actionPerformed(ActionEvent e) {
	    		JSplitPane split=null;
		    	Container c=  tabbedPanel.getParent();
	    		if( c instanceof JSplitPane){
	    			split=(JSplitPane)c;
	    		}else {
	    			split=(JSplitPane)c.getParent();
	    		}
	    		if( flag ){
			    	  if(min){
			    		  split.setDividerLocation(oldValue);
			    		  minButton.setIcon(getMinIcon());
			    		  min=false;
			    		  minButton.setToolTipText("Minimize");
			    	  }else{
			    		  oldValue=split.getDividerLocation();
			    		  split.setDividerLocation(split.getMinimumDividerLocation());
				    	  minButton.setIcon(getRestoreIcon());
				    	  min=true;
				    	  minButton.setToolTipText("Restore");
			    	  }
		    	  }else{
			    	  if(min){
			    		  split.setDividerLocation(oldValue);
			    		  minButton.setIcon(getMinIcon());
			    		  min=false;
			    		  minButton.setToolTipText("Minimize");
			    	  }else{
			    		  oldValue=split.getDividerLocation();
				    	  split.setDividerLocation(split.getMaximumDividerLocation());
				    	  minButton.setIcon(getRestoreIcon());
				    	  min=true;
				    	  minButton.setToolTipText("Restore");
			    	  }
		    	  }
	    	}
	    });
	    return minButton;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -