Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. package LearnSwingPkg;
  2.  
  3. import java.awt.BorderLayout;
  4.  
  5. class SplitPane extends JFrame {
  6.  
  7. private JPanel panel1;
  8. private JPanel panel2;
  9. private JScrollPane panel3;
  10. private JScrollPane panel4;
  11.  
  12. protected JSplitPane split;
  13.  
  14. public SplitPane(){
  15.  
  16. super("Learn Swing");
  17. JFrame.setDefaultLookAndFeelDecorated(true);
  18. setSize(900, 700);
  19. setDefaultCloseOperation(EXIT_ON_CLOSE);
  20. setLocation(0,0);
  21.  
  22. setTitle( "Split Pane Application" );
  23.  
  24. JPanel topPanel = new JPanel();
  25. topPanel.setLayout( new BorderLayout() );
  26. getContentPane().add( topPanel );
  27.  
  28. // Create the panels
  29. createPanel1();
  30. createPanel2();
  31. createPanel3();
  32. createPanel4();
  33.  
  34. JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,panel1, panel3);
  35. JSplitPane spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT,true, panel2, panel4);
  36.  
  37. split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,spLeft, spRight);
  38. split.setOneTouchExpandable(true);
  39.  
  40. getContentPane().add(split, BorderLayout.CENTER);
  41.  
  42.  
  43.  
  44. }
  45. //top left
  46. public void createPanel1(){
  47. panel1 = new JPanel();
  48. panel1.setLayout( new BorderLayout() );
  49. panel1.add((new TextArea("Panel1")));
  50.  
  51. panel1.setPreferredSize( new Dimension( 450, 400 ) );
  52. panel1.setMaximumSize(new Dimension(450, 400));
  53. }
  54.  
  55.  
  56. //top right
  57. public void createPanel2(){
  58. panel2 = new JPanel();
  59. panel2.setLayout( new BorderLayout() );
  60. panel2.add((new TextArea("Panel2")));
  61. panel2.setPreferredSize( new Dimension( 450, 400 ) );
  62. panel2.setMaximumSize(new Dimension(450, 400));
  63.  
  64. }
  65.  
  66. //bottom left
  67. public void createPanel3(){
  68. Label label_prop = new Label("Properties:", Label.LEFT);
  69.  
  70. String[] columnNames = {"Properties",
  71. "",
  72. };
  73. Object[][] data = {
  74. {"", "",}, {"", ""}, {"", ""},{"", ""},
  75. {"", "",}, {"", ""}, {"", ""},{"", ""},
  76. {"", "",}, {"", ""}, {"", ""},{"", ""}
  77. };
  78.  
  79.  
  80. JTable table = new JTable(data, columnNames);
  81. table.setBackground(getBackground());
  82. table.setBackground(Color.LIGHT_GRAY);
  83. table.setRowHeight(20);
  84. table.setBorder(BasicBorders.getMenuBarBorder());
  85.  
  86. panel3 = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZO
  87. panel3.add(label_prop);
  88. panel3.setPreferredSize( new Dimension( 20, 20 ) );
  89. panel3.setMinimumSize( new Dimension( 20, 20 ) );
  90.  
  91. }
  92. //bottom right
  93. public void createPanel4(){
  94.  
  95. panel4 = new JScrollPane();
  96. //panel4.setLayout( new FlowLayout() );
  97. String[] columnNames = {"Activities",
  98. "",
  99. };
  100. Object[][] data = {
  101. {"", "",}, {"", ""}, {"", ""},{"", ""},
  102. {"", "",}, {"", ""}, {"", ""},{"", ""},
  103. {"", "",}, {"", ""}, {"", ""},{"", ""}
  104. };
  105.  
  106.  
  107. JTable table = new JTable(data, columnNames);
  108. table.setBackground(getBackground());
  109. table.setBackground(Color.LIGHT_GRAY);
  110. table.setRowHeight(20);
  111. table.setBorder(BasicBorders.getMenuBarBorder());
  112. panel4 = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  113. panel4.setPreferredSize( new Dimension( 20, 20 ) );
  114. panel4.setMinimumSize( new Dimension( 20, 20 ) );
  115.  
  116.  
  117. }
  118.  
  119. public static void main( String args[] ){
  120. try {
  121. UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  122. } catch (Exception evt) {}
  123. // Create an instance of the test application
  124. SplitPane mainFrame = new SplitPane();
  125. mainFrame.setVisible( true );
  126. mainFrame.setBackground(Color.blue);
  127. }
  128. }
  129.  
  130. //top left
  131. public void createPanel1(){
  132. panel1 = new JPanel();
  133. panel1.setLayout( new BorderLayout() );
  134. JChemPaint.showInstance(filename, null, null, debug);
  135. panel1.setPreferredSize( new Dimension( 450, 400 ) );
  136. panel1.setMaximumSize(new Dimension(450, 400));
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement