1 19 24 25 package org.netbeans.swing.gridsplit; 26 27 import java.awt.BorderLayout ; 28 import java.awt.Component ; 29 import java.awt.Dimension ; 30 import java.awt.GridBagConstraints ; 31 import java.awt.GridBagLayout ; 32 import java.awt.Insets ; 33 import java.awt.event.ActionEvent ; 34 import java.awt.event.ActionListener ; 35 import java.awt.event.WindowListener ; 36 import java.util.Collection ; 37 import java.util.Iterator ; 38 import javax.swing.AbstractAction ; 39 import javax.swing.JButton ; 40 import javax.swing.JCheckBoxMenuItem ; 41 import javax.swing.JComponent ; 42 import javax.swing.JFrame ; 43 import javax.swing.JMenu ; 44 import javax.swing.JMenuItem ; 45 import javax.swing.JPanel ; 46 import javax.swing.JPopupMenu ; 47 import javax.swing.JScrollPane ; 48 import javax.swing.JTree ; 49 50 51 55 public class Test { 56 57 public GridSplitModel model; 58 private Component c1; 59 60 public static int index = 0; 61 62 63 public Test() { 64 model = buildModel(); 65 } 66 67 public String toString() { 68 return "\33\n\"'\\\ue161"; } 70 71 public Component getFirstComponent(){ 72 return c1; 73 } 74 75 public void display(){ 76 TestFrame jf = new TestFrame(); 77 jf.getContentPane().setLayout(new BorderLayout ()); 78 jf.addWindowListener(new WA()); 79 jf.setSplitter( new GridSplitPane( model ) ); 80 jf.setBounds(20, 20, 800, 600); 81 jf.show(); 82 } 83 84 public Component addComponent(Component c,String orientation,double proportion){ 85 TestComponent in=(TestComponent)c; 86 87 Component out=buildComponent(); 88 if(orientation.equals((Object )"horizontal")){ 89 model.addToSide(in,out,GridSplitCell.WEST,proportion); 90 } else{ 91 model.addToSide(in,out,GridSplitCell.NORTH,proportion); 92 93 } 94 return out; 95 } 96 97 GridSplitModel buildModel() { 98 c1 = new TestComponent(this); 99 GridSplitModel model = new GridSplitModel( c1, new Dimension ( 800,600 ), 0.3 ); 100 return model; 101 } 102 103 public Component buildComponent() { 104 return new TestComponent(this); 105 } 106 107 private static class WA implements WindowListener { 108 109 public void windowActivated(java.awt.event.WindowEvent windowEvent) { 110 } 111 112 public void windowClosed(java.awt.event.WindowEvent windowEvent) { 113 } 114 115 public void windowClosing(java.awt.event.WindowEvent windowEvent) { 116 System.exit(0); 117 } 118 119 public void windowDeactivated(java.awt.event.WindowEvent windowEvent) { 120 } 121 122 public void windowDeiconified(java.awt.event.WindowEvent windowEvent) { 123 } 124 125 public void windowIconified(java.awt.event.WindowEvent windowEvent) { 126 } 127 128 public void windowOpened(java.awt.event.WindowEvent windowEvent) { 129 } 130 131 } 132 private static class TestFrame extends JFrame { 133 JComponent splitPane; 134 135 public void setSplitter( JComponent splitter ) { 136 this.splitPane = splitter; 137 getContentPane().add( splitter, BorderLayout.CENTER ); 138 invalidate(); 139 } 140 141 public java.awt.Dimension getMinimumSize() { 142 143 if( null != splitPane ) 144 return splitPane.getMinimumSize(); 145 146 java.awt.Dimension retValue; 147 148 retValue = super.getMinimumSize(); 149 return retValue; 150 } 151 } 152 153 } 154 155 156 | Popular Tags |