Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public PanelCalendarWeek() {
  2. /* This panel holds the date */
  3. innerPanel = new JPanel();
  4. innerPanel.setBackground(Color.BLACK);
  5. innerPanel.setBounds(0, 0, 700, 700);
  6. innerPanel.setPreferredSize(new Dimension(700, 700));
  7. innerPanel.setLayout(new GridBagLayout());
  8.  
  9. /* Create Grid bag containts for the BLACK area */
  10.  
  11. GridBagConstraints c = new GridBagConstraints();
  12. c.anchor = GridBagConstraints.PAGE_END;
  13. c.fill = GridBagConstraints.HORIZONTAL;
  14. c.weightx = 0.5;
  15. c.gridx = 0;
  16. c.gridy = 0;
  17.  
  18. /* Add example panels that would be dates */
  19.  
  20. JPanel panel1 = new JPanel();
  21. panel1.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
  22. panel1.setPreferredSize(new Dimension(1, 200));
  23. panel1.setBackground(Color.BLUE);
  24.  
  25. innerPanel.add(panel1, c);
  26.  
  27. /* Create more components in the manner above for example reasons */
  28.  
  29. this.addComponentListener(new ComponentListener() {
  30.  
  31. @Override
  32. public void componentResized(ComponentEvent e) {
  33. innerPanel.setBounds(0, 0, columnView.getWidth(), 1000);
  34. innerPanel.setPreferredSize(new Dimension(columnView.getWidth(), 1000));
  35. } // more code omitted for brevitu
  36. });
  37.  
  38. scrollPane = new JScrollPane();
  39. scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  40. scrollPane.getViewport().setLayout(null);
  41. scrollPane.setViewportView(innerPanel);
  42. scrollPane.setBounds(0, 0, 400, 400);
  43.  
  44. columnView = new JPanel();
  45. columnView.setBackground(Color.RED);
  46. columnView.setBounds(0, 0, 200, 50);
  47. columnView.setPreferredSize(new Dimension(200, 50));
  48. scrollPane.setColumnHeaderView(columnView);
  49.  
  50. rowView = new JPanel(); /* omitted, same process as above */
  51.  
  52. this.setLayout(new BorderLayout());
  53. this.add(scrollPane, BorderLayout.CENTER);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement