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

📄 testsplitpanes.java

📁 ALGAE是一个快速创建算法演示的框架。目前支持的算法实现语言包括java和c
💻 JAVA
字号:
package edu.odu.cs.zeil.AlgAE.gui;import java.awt.*;import java.awt.event.*;import edu.odu.cs.zeil.AlgAE.gui.HSplitPane;import edu.odu.cs.zeil.AlgAE.gui.VSplitPane;// import DialogWindow;class Canvas2 extends Canvas{    boolean toggle = true;    private Color c1;    private Color c2;            Canvas2(Color clr1, Color clr2)     {	super();	c1 = clr1;	c2 = clr2;	setBackground (Color.white);    }    public void paint (Graphics g)    {	if (toggle) {	    g.setColor (c1);	}	else {	    g.setColor (c2);	}	Dimension d = getSize();//	System.out.println ("Canvas2 paint: " + d.width//			    + " " + d.height);	g.fill3DRect (0, 0, d.width, d.height, false);	toggle = !toggle;    }    public Dimension getMinimumSize()    {	return new Dimension(2,2);    }    }public class TestSplitPanes extends Frame {    private boolean inAnApplet = true;    private Canvas w1;    private Canvas w2;    private Canvas w3;    private HSplitPane hpane;    private VSplitPane vpane;    private MenuItem exitItem;        public TestSplitPanes() {	w1 = new Canvas2(Color.red, Color.green);	w2 = new Canvas2(Color.blue, Color.yellow);	w3 = new Canvas2(Color.cyan, Color.magenta);	hpane = new HSplitPane (w1, w2, 0.75);	vpane = new VSplitPane (hpane, w3, 0.5);	add (vpane);	MenuBar mb = new MenuBar();	setMenuBar(mb);	Menu fileMenu = new Menu ("File", false);	mb.add(fileMenu);		exitItem = new MenuItem ("Exit");	fileMenu.add (exitItem);	exitItem.addActionListener(new ActionListener() {	  public void actionPerformed(ActionEvent e) {	    if (inAnApplet)	      {		dispose();	      }	    else	      {		System.exit(0);	      }	  }	});		addWindowListener(new WindowAdapter() {	  public void windowActivated(WindowEvent e) {}	  public void windowClosed(WindowEvent e) {}	  public void windowClosing(WindowEvent e) {System.exit(0);}	  public void windowDeactivated(WindowEvent e) {}	  public void windowDeiconified(WindowEvent e) {}	  public void windowIconified(WindowEvent e) {}	  public void windowOpened(WindowEvent e) {}});	addMouseListener(new MouseAdapter() {	  public void mouseClicked(MouseEvent e) {}	  public void mouseExited(MouseEvent e) {}	  public void mousePressed(MouseEvent e) {	      setTitle ("down [" + e.getX() + ", " + e.getY() + "]");	  }	  public void mouseReleased(MouseEvent e) {	      setTitle (getTitle() + "  up [" + e.getX() + ", " + e.getY() + "]");	  }});    }  /*  public boolean action(Event event, Object arg) {    if (event.target instanceof MenuItem) {      MenuItem mi=(MenuItem)(event.target);      if (mi == exitItem)	{	if (inAnApplet)	  {	    dispose();	  }	else	  {	    System.exit(0);	  }	}    }    return true;  }  */  public Dimension getPreferredSize() {    return new Dimension (400,300);  }  public synchronized Dimension getMinimumSize() {    return new Dimension (100,100);  }  /*  public boolean handleEvent(Event event) {    //System.out.println ("TestSplitPanes event " + event.id);    if (event.id == Event.WINDOW_DESTROY) {      if (inAnApplet) {	dispose();      } else {	System.exit(0);      }    }       return super.handleEvent(event);  }  */  /*  public boolean mouseDown(Event event, int x, int y)   {    setTitle ("down [" + x + ", " + y + "]");    return false;  }    public boolean mouseUp(Event event, int x, int y)   {    setTitle (getTitle() + "  up [" + x + ", " + y + "]");    return false;  }  */    public static void main(String args[]) {        TestSplitPanes window = new TestSplitPanes();        window.inAnApplet = false;        window.setTitle("SplitPanes Application");        window.pack();        window.show();    }}

⌨️ 快捷键说明

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