Exemplo n.º 1
0
Arquivo: View.java Projeto: Jegp/BGPP
  /** Instantiates the view. */
  public View() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    // create north, south, west and east panels
    JPanel northPanel = new JPanel(new FlowLayout());
    JPanel westPanel = new JPanel(new GridLayout(0, 1));
    JPanel eastPanel = new JPanel();
    JPanel southPanel = new JPanel();

    // create primitive start panel.
    JPanel startPanel = new JPanel(); // perhaps add picture?

    // set starting panel
    container = startPanel;

    // arrange the panels
    add(container, BorderLayout.CENTER);
    add(northPanel, BorderLayout.NORTH);
    add(westPanel, BorderLayout.WEST);
    add(eastPanel, BorderLayout.EAST);
    add(southPanel, BorderLayout.SOUTH);

    // create buttons
    reservationButton = new JButton("Reservation");
    customerButton = new JButton("Customer");
    vehicleButton = new JButton("Vehicle");

    // add components to north panel
    northPanel.add(reservationButton);
    northPanel.add(customerButton);
    northPanel.add(vehicleButton);

    // Add a loading panel to display loading before the container is shown
    loadingPanel = new JPanel(new BorderLayout());
    JLabel loading = new JLabel("Loading...");
    loadingPanel.add(loading, BorderLayout.NORTH);
    add(loadingPanel);

    // Set title
    setTitle("Bookingsystem");

    // Display
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(e.getMaximumWindowBounds());
    setPreferredSize(e.getMaximumWindowBounds().getSize());

    // Initialize
    pack();
    setVisible(true);
  }
 /*
  *  Keep the size of the component within the bounds of its parent.
  */
 private Dimension getBoundingSize(Component source) {
   if (source instanceof Window) {
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     Rectangle bounds = env.getMaximumWindowBounds();
     return new Dimension(bounds.width, bounds.height);
   } else {
     return source.getParent().getSize();
   }
 }
Exemplo n.º 3
0
 public Point getPreferredLocation() {
   if (!IJ.isJava14()) return new Point(0, 0);
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   Rectangle maxBounds = ge.getMaximumWindowBounds();
   int ijX = Prefs.getInt(IJ_X, -99);
   int ijY = Prefs.getInt(IJ_Y, -99);
   if (ijX >= 0 && ijY > 0 && ijX < (maxBounds.x + maxBounds.width - 75))
     return new Point(ijX, ijY);
   Dimension tbsize = toolbar.getPreferredSize();
   int ijWidth = tbsize.width + 10;
   double percent = maxBounds.width > 832 ? 0.8 : 0.9;
   ijX = (int) (percent * (maxBounds.width - ijWidth));
   if (ijX < 10) ijX = 10;
   return new Point(ijX, maxBounds.y);
 }
Exemplo n.º 4
0
  JFrame openMonitorGUI(String title) {
    try {
      MonitorGUI gui = new MonitorGUI(this, title);

      JFrame frame = new JFrame(title);
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      frame.addWindowListener(this);
      frame.getContentPane().add(gui);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Rectangle r = ge.getMaximumWindowBounds();
      frame.setSize(400, 200);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
      return frame;
    } catch (Exception e) {
      System.out.println("9\b" + getClass().getName() + "\n\t" + e);
      return null;
    }
  }