Guest User

Untitled

a guest
Jul 23rd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. public class Test extends JFrame implements FocusListener, MouseMotionListener {
  2. private int datePanelHeight =30;
  3. private ChartPanel chartPanel;
  4. Test() throws IOException {
  5. super("Графическое приложение");
  6. this.setBackground(Color.WHITE);
  7. setBounds(50,50,1000, 450);
  8. this.setVisible(true);
  9. this.setVisible(false);
  10.  
  11. addToolBar();
  12.  
  13. MenuBar mb = new MenuBar();
  14. setMenuBar(mb);
  15. Menu f=new Menu("Файл");
  16. Menu v=new Menu("Вид");
  17. mb.add(f);
  18. mb.add(v);
  19. chartPanel = new ChartPanel(this.getContentPane().getWidth(), this.getContentPane().getHeight());
  20. add(chartPanel);
  21.  
  22. chartPanel.requestFocus();
  23. addKeyListener(chartPanel);
  24.  
  25.  
  26.  
  27. this.setVisible(true);
  28. setDefaultCloseOperation(EXIT_ON_CLOSE);
  29. System.out.println("this.getComponentCount() = "+this.getComponentCount());
  30. }
  31.  
  32. private void addToolBar(){
  33. JToolBar tb = new JToolBar("Панель ирструментов", JToolBar.HORIZONTAL);
  34. tb.add(new JButton("Кнопка"));
  35. tb.setFloatable(true);
  36. add(tb, BorderLayout.NORTH);
  37.  
  38. JTextField tf = new JTextField("0",3);
  39. tf.setMaximumSize(new Dimension(30,100));
  40. tf.setHorizontalAlignment(JTextField.RIGHT);
  41. tb.add(tf);
  42.  
  43. tb.addKeyListener(chartPanel);
  44. System.out.println("this.getComponentCount() = "+tb.getComponentCount());
  45. }
  46.  
  47. public static void main(String[] args) throws IOException {
  48. new FinanceMarketFrame();
  49. }
Add Comment
Please, Sign In to add comment