Exemplo n.º 1
0
  private void createGUI() {

    dataSourcePanel = new DataSourcePanel(app, mode);

    lblTitle = new JLabel();
    lblTitle.setIconTextGap(10);

    btnOK = new JButton();
    btnOK.addActionListener(this);

    btnCancel = new JButton();
    btnCancel.addActionListener(this);

    JPanel titlePanel = LayoutUtil.flowPanel(lblTitle);
    // titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(titlePanel, BorderLayout.NORTH);
    mainPanel.add(dataSourcePanel, BorderLayout.CENTER);
    mainPanel.add(LayoutUtil.flowPanelRight(5, 0, 0, btnCancel, btnOK), BorderLayout.SOUTH);

    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    setLabels();
  }
Exemplo n.º 2
0
  /**
   * Bind this view to a dock manager. Also initializes the whole GUI as just at this point the
   * application is available.
   *
   * @param dockManager1 dock manager
   */
  public void register(DockManagerD dockManager1) {
    this.dockManager = dockManager1;
    setApp(dockManager1.getLayout().getApplication());
    // create buttons for the panels
    createButtons();

    // create button panel
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(app.flowRight(), 0, 1));
    if (app.getLocalization().isRightToLeftReadingOrder()) {
      buttonPanel.add(closeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(windowButton);
      buttonPanel.add(unwindowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(maximizeButton);
    } else {
      buttonPanel.add(maximizeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(unwindowButton);
      buttonPanel.add(windowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(closeButton);
    }

    // Custom border for the major panels (title, stylebar and toolbar)
    Border panelBorder =
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, SystemColor.controlShadow),
            BorderFactory.createEmptyBorder(0, 2, 0, 2));

    // create style bar panel
    styleBarPanel = new JPanel(new BorderLayout(1, 2));
    styleBarPanel.setBorder(panelBorder);
    styleBarPanel.addMouseListener(this);

    styleBarButtonPanel = new JPanel(new BorderLayout());
    JPanel p = new JPanel(new FlowLayout(0, 0, app.flowLeft()));
    if (this.hasStyleBar) {
      p.add(toggleStyleBarButton2);
    }
    p.add(Box.createHorizontalStrut(4));

    styleBarButtonPanel.add(p, BorderLayout.NORTH);
    styleBarPanel.add(styleBarButtonPanel, loc.borderWest());
    styleBarPanel.add(LayoutUtil.flowPanelRight(0, 0, 4, unwindowButton2), loc.borderEast());

    // construct the title panel and add all elements
    titlePanel = new JPanel();
    titlePanel.setBorder(panelBorder);
    titlePanel.setLayout(new BorderLayout());

    titlePanel.add(createFocusPanel(), loc.borderWest());
    titlePanel.add(buttonPanel, loc.borderEast());
    titlePanel.addMouseListener(this); // dragging to reconfigure
    titlePanel.addMouseListener(new MyButtonHider());

    // create toolbar panel
    if (hasToolbar()) {
      toolbarPanel = new JPanel(new BorderLayout());
      toolbarPanel.setBorder(panelBorder);
    }

    // construct a meta panel to hold the title, tool bar and style bar
    // panels

    JPanel titleBar = new JPanel(new BorderLayout());
    titleBar.add(styleBarPanel, BorderLayout.SOUTH);
    titleBar.add(titlePanel, BorderLayout.NORTH);

    JPanel metaPanel = new JPanel(new BorderLayout());
    metaPanel.add(titleBar, BorderLayout.SOUTH);
    if (hasToolbar()) metaPanel.add(toolbarPanel, BorderLayout.CENTER);

    // make titlebar visible if necessary
    updatePanel();

    add(metaPanel, BorderLayout.NORTH);
  }