1 19 24 25 package org.netbeans.modules.piagetproject.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(jf)); 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 class WA implements WindowListener { 108 TestFrame frame; 109 public WA(TestFrame frame){ 110 this.frame = frame; 111 } 112 113 public void windowActivated(java.awt.event.WindowEvent windowEvent) { 114 } 115 116 public void windowClosed(java.awt.event.WindowEvent windowEvent) { 117 } 118 119 public void windowClosing(java.awt.event.WindowEvent windowEvent) { 120 frame.dispose(); 121 } 122 123 public void windowDeactivated(java.awt.event.WindowEvent windowEvent) { 124 } 125 126 public void windowDeiconified(java.awt.event.WindowEvent windowEvent) { 127 } 128 129 public void windowIconified(java.awt.event.WindowEvent windowEvent) { 130 } 131 132 public void windowOpened(java.awt.event.WindowEvent windowEvent) { 133 } 134 135 } 136 private static class TestFrame extends JFrame { 137 JComponent splitPane; 138 139 public void setSplitter( JComponent splitter ) { 140 this.splitPane = splitter; 141 getContentPane().add( splitter, BorderLayout.CENTER ); 142 invalidate(); 143 } 144 145 public java.awt.Dimension getMinimumSize() { 146 147 if( null != splitPane ) 148 return splitPane.getMinimumSize(); 149 150 java.awt.Dimension retValue; 151 152 retValue = super.getMinimumSize(); 153 return retValue; 154 } 155 } 156 157 } 158 159 160 | Popular Tags |