示例#1
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
  HeatMapControls(ControlBar creator) {
    super();
    parent = creator;

    setLayout(new BorderLayout());
    super.setPreferredSize(new Dimension(255, 170));

    String[] organisms = SpeciesTable.getOrganisms();
    String[] options = new String[organisms.length + 1];

    options[0] = "None";
    for (int i = 0; i < organisms.length; i++) {
      options[i + 1] = organisms[i];
    }

    species = new JComboBox(options);
    species.addActionListener(this);
    for (String str : SpeciesTable.getOrganisms()) {}

    super.add(species, BorderLayout.SOUTH);
    super.add(new Gradient(), BorderLayout.CENTER);
    super.add(new JLabel("Least"), BorderLayout.WEST);
    super.add(new JLabel("Most"), BorderLayout.EAST);
    super.add(new JLabel("Heat Map Controls"), BorderLayout.NORTH);
    super.setVisible(true);
  }
  private JPanel makeButtonPanel() {

    JPanel p = new JPanel();
    p.setLayout(new GridLayout(5, 1));
    p.setPreferredSize(new Dimension(150, 160));

    JLabel translationLabel = new JLabel("Set Translation (nm)", JLabel.CENTER);
    p.add(translationLabel);

    JLabel[] label =
        new JLabel[] {
          new JLabel("dx: ", JLabel.RIGHT),
          new JLabel("dy: ", JLabel.RIGHT),
          new JLabel("dz: ", JLabel.RIGHT)
        };

    JPanel[] shiftPanel = new JPanel[3];
    for (int i = 0; i < 3; i++) {
      shiftPanel[i] = new JPanel();
      shiftPanel[i].add(label[i]);
      shiftTF[i] =
          new ValueTextField("0.0", 5, ValueTextField.DOUBLE, Constraints.NO_CONSTRAINT, false);
      shiftPanel[i].add(shiftTF[i]);
      p.add(shiftPanel[i]);
    }

    JPanel buttonPanel = new JPanel();
    shift = new JButton("Translate");
    buttonPanel.add(shift);
    p.add(buttonPanel);

    JPanel rPanel = new JPanel();
    rPanel.add(p);
    return rPanel;
  }
示例#4
0
  private JPanel getMainPanel() {
    if (mainPanel == null) {
      mainPanel = new JPanel();
      mainPanel.setPreferredSize(new Dimension(550, 300));
      GridBagLayout layout = new GridBagLayout();

      mainPanel.setLayout(layout);

      GridBagConstraints constraints = new GridBagConstraints();

      constraints.fill = GridBagConstraints.BOTH;
      constraints.weightx = 2;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      constraints.gridwidth = 2;
      layout.setConstraints(getAvailableRobotsPanel(), constraints);
      mainPanel.add(getAvailableRobotsPanel());
      constraints.gridwidth = 1;
      constraints.weightx = 0;
      constraints.weighty = 0;
      constraints.anchor = GridBagConstraints.CENTER;
      layout.setConstraints(getButtonsPanel(), constraints);
      mainPanel.add(getButtonsPanel());
      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.weightx = 1;
      constraints.weighty = 1;
      constraints.anchor = GridBagConstraints.NORTHWEST;
      layout.setConstraints(getSelectedRobotsPanel(), constraints);
      mainPanel.add(getSelectedRobotsPanel());
    }
    return mainPanel;
  }
  private void buildExternalsPanel() {

    FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p"));
    int row = 1;
    for (ExternalFileEntry efe : externals) {
      builder.add(efe.getPanel()).xy(1, row);
      builder.appendRows("2dlu, p");
      row += 2;
    }
    builder.add(Box.createVerticalGlue()).xy(1, row);
    builder.appendRows("2dlu, p, 2dlu, p");
    builder.add(addExtPan).xy(1, row + 2);
    builder.add(Box.createVerticalGlue()).xy(1, row + 2);

    // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green));
    // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    JScrollPane pane = new JScrollPane(builder.getPanel());
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    externalFilesPanel.setMinimumSize(new Dimension(400, 400));
    externalFilesPanel.setPreferredSize(new Dimension(400, 400));
    externalFilesPanel.removeAll();
    externalFilesPanel.add(pane, BorderLayout.CENTER);
    externalFilesPanel.revalidate();
    externalFilesPanel.repaint();
  }
示例#6
0
  public ContactListUI() {
    cList = new ContactList("contacts.txt");

    // Set up the To: and From: panel
    JPanel staticPanel = new JPanel();
    staticPanel.setPreferredSize(new Dimension(100, 100));
    staticPanel.setLayout(new GridLayout(3, 1));
    to = new JButton("To: ");
    staticPanel.add(to);
    staticPanel.add(new JLabel(" "));
    staticPanel.add(new JLabel("From:", JLabel.CENTER));

    // Set up the panel for addContacts and removeContacts;
    JPanel buttonPanel = new JPanel();
    addContacts = new JButton("Add");
    removeContacts = new JButton("Remove");
    editContacts = new JButton("Edit");
    buttonPanel.setLayout(new FlowLayout());
    buttonPanel.add(addContacts);
    buttonPanel.add(removeContacts);
    buttonPanel.add(editContacts);

    // Set up the panel with the contact selection and buttons
    JPanel dynPanel = new JPanel();
    toText = new JTextField();
    fromText = new JTextField();
    dynPanel.setPreferredSize(new Dimension(300, 100));
    dynPanel.setLayout(new GridLayout(3, 1));
    dynPanel.add(toText);
    dynPanel.add(buttonPanel);
    dynPanel.add(fromText);

    // Add everything to a ContactUI
    to.addActionListener(this);
    addContacts.addActionListener(this);
    removeContacts.addActionListener(this);
    editContacts.addActionListener(this);
    this.setPreferredSize(new Dimension(500, 125));
    this.setLayout(new FlowLayout());
    this.add(staticPanel);
    this.add(dynPanel);

    deleteContact = new JButton("Delete");
    deleteContact.addActionListener(this);
    addSendContacts = new JButton("Confirm");
    addSendContacts.addActionListener(this);
  }
示例#7
0
  /**
   * Loads the tileset defined in the constructor into a JPanel which it then returns. Makes no
   * assumptions about height or width, which means it needs to read an extra 64 tiles at worst (32
   * down to check height and 32 across for width), since the maximum height/width is 32 tiles.
   */
  public JPanel loadTileset() {
    int height = MAX_TILESET_SIZE;
    int width = MAX_TILESET_SIZE;

    boolean maxHeight = false;
    boolean maxWidth = false;

    // find width
    int j = 0;
    while (!maxWidth) {
      try {
        File f = new File(tileDir + "/" + j + "_" + 0 + ".png");
        ImageIO.read(f);
      } catch (IOException e) {
        width = j;
        maxWidth = true;
      }
      j += TILE_SIZE;
    }

    // find height
    int i = 0;
    while (!maxHeight) {
      try {
        File f = new File(tileDir + "/" + 0 + "_" + i + ".png");
        ImageIO.read(f);
      } catch (IOException e) {
        height = i;
        maxHeight = true;
      }
      i += TILE_SIZE;
    }

    JPanel tileDisplay = new JPanel();
    tileDisplay.setLayout(new GridLayout(height / TILE_SIZE, width / TILE_SIZE));
    tileDisplay.setMinimumSize(new Dimension(width, height));
    tileDisplay.setPreferredSize(new Dimension(width, height));
    tileDisplay.setMaximumSize(new Dimension(width, height));

    for (i = 0; i < height; i += TILE_SIZE) {
      for (j = 0; j < width; j += TILE_SIZE) {
        String fPath = tileDir + "/" + j + "_" + i;
        try {
          int[] mov = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

          Image icon = getTile(tileDir, j, i, 1);
          Tile tile =
              new Tile(new ImageIcon(icon), "palette", 0, 0, mov, "none", false, "" + j + "_" + i);
          tile.addMouseListener(new PaletteButtonListener());
          tile.setMaximumSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tile.setPreferredSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tile.setMinimumSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tileDisplay.add(tile);
        } catch (IOException e) {
        }
      }
    }
    return tileDisplay;
  }
示例#8
0
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
示例#9
0
  public UnitTestRunner() {
    mainPane = new JPanel(new GridBagLayout());
    mainPane.setMinimumSize(new Dimension(0, 0));
    mainPane.setPreferredSize(new Dimension(270, 200));
    minPane = new JPanel(new GridBagLayout());

    initComponents();

    addGrid(
        mainPane, toolbar, 0, 0, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);

    addGrid(
        mainPane,
        new JSeparator(),
        0,
        1,
        2,
        GridBagConstraints.HORIZONTAL,
        1.0,
        GridBagConstraints.WEST);

    addGrid(
        mainPane, fCounterPanel, 0, 2, 2, GridBagConstraints.NONE, 0.0, GridBagConstraints.WEST);
    addGrid(
        mainPane,
        fProgressIndicator,
        0,
        3,
        2,
        GridBagConstraints.HORIZONTAL,
        1.0,
        GridBagConstraints.WEST);

    addGrid(
        mainPane,
        new JSeparator(),
        0,
        5,
        2,
        GridBagConstraints.HORIZONTAL,
        1.0,
        GridBagConstraints.WEST);
    addGrid(
        mainPane,
        new JLabel("Results:"),
        0,
        6,
        2,
        GridBagConstraints.HORIZONTAL,
        1.0,
        GridBagConstraints.WEST);

    addGrid(mainPane, fTestViewTab, 0, 7, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST);

    // _lineNoOfTest = new HashMap<String, Integer>();
  }
示例#10
0
 /*Creates the South section of the mancala board. */
 private JPanel southBoardPanel() {
   JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 300, 50));
   p1Label = new JLabel("Player 1");
   p1Label.setFont(new Font("Belta Regular", Font.BOLD, 50));
   p1Label.setForeground(new Color(203, 159, 0));
   southPanel.add(p1Label);
   southPanel.setOpaque(false);
   southPanel.setPreferredSize(new Dimension(600, 100));
   return southPanel;
 }
示例#11
0
 private JPanel getSelectedRobotsPanel() {
   if (selectedRobotsPanel == null) {
     selectedRobotsPanel = new JPanel();
     selectedRobotsPanel.setLayout(new BorderLayout());
     selectedRobotsPanel.setPreferredSize(new Dimension(120, 100));
     selectedRobotsPanel.setBorder(
         BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Selected Robots"));
     selectedRobotsPanel.add(getSelectedRobotsScrollPane(), BorderLayout.CENTER);
   }
   return selectedRobotsPanel;
 }
示例#12
0
  /*Creates the East section of the mancala board. Contains Collection Pit*/
  private JPanel eastBoardPanel() {
    JPanel eastPanel = new JPanel();
    eastPanel.setOpaque(false);
    eastPanel.setPreferredSize(new Dimension(150, 600));

    b6 = new JButton(String.valueOf(game.board.getPitAt(6).getCount()));
    b6.setPreferredSize(new Dimension(100, 330));
    b6.setFont(new Font("Belta Regular", Font.BOLD, 32));
    b6.setBackground(new Color(214, 162, 173));
    eastPanel.add(b6);
    return eastPanel;
  }
示例#13
0
  public DatePicker(JFrame parent) {
    d = new JDialog();
    d.setModal(true);
    String[] header = {"Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"};
    JPanel p1 = new JPanel(new GridLayout(7, 7));
    p1.setPreferredSize(new Dimension(430, 120));

    for (int x = 0; x < button.length; x++) {
      final int selection = x;
      button[x] = new JButton();
      button[x].setFocusPainted(false);
      button[x].setBackground(Color.white);
      if (x > 6)
        button[x].addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                day = button[selection].getActionCommand();
                d.dispose();
              }
            });
      if (x < 7) {
        button[x].setText(header[x]);
        button[x].setForeground(Color.red);
      }
      p1.add(button[x]);
    }
    JPanel p2 = new JPanel(new GridLayout(1, 3));
    JButton previous = new JButton("<< Previous");
    previous.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month--;
            displayDate();
          }
        });
    p2.add(previous);
    p2.add(l);
    JButton next = new JButton("Next >>");
    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            month++;
            displayDate();
          }
        });
    p2.add(next);
    d.add(p1, BorderLayout.CENTER);
    d.add(p2, BorderLayout.SOUTH);
    d.pack();
    d.setLocationRelativeTo(parent);
    displayDate();
    d.setVisible(true);
  }
示例#14
0
  // Panel above board
  private JPanel northWindowPanel() {
    JPanel lab2Panel = new JPanel();
    lab2Panel.setLayout(new BorderLayout());
    lab2Panel.setPreferredSize(new Dimension(300, 150));
    lab2Panel.setOpaque(false);
    statusLabel2 = new JLabel("", JLabel.CENTER);
    statusLabel2.setForeground(new Color(203, 159, 0));
    statusLabel2.setFont(new Font("Belta Regular", Font.ITALIC, 45));

    lab2Panel.add(statusLabel2, BorderLayout.CENTER);
    return lab2Panel;
  }
示例#15
0
  // Panel below board (Contains Label Indicating Player 1's turn
  private JPanel southWindowPanel() {
    JPanel lab1Panel = new JPanel();
    lab1Panel.setLayout(new BorderLayout());
    lab1Panel.setPreferredSize(new Dimension(300, 150));
    lab1Panel.setOpaque(false);
    statusLabel1 = new JLabel("Player 1's Turn", JLabel.CENTER);
    statusLabel1.setForeground(new Color(203, 159, 0));
    statusLabel1.setFont(new Font("Belta Regular", Font.ITALIC, 45));

    lab1Panel.add(statusLabel1, BorderLayout.CENTER);

    JPanel eastContainer = new JPanel();
    eastContainer.setLayout(new BorderLayout());
    eastContainer.setOpaque(false);
    eastContainer.setPreferredSize(new Dimension(200, 300));

    JPanel btnPanel = new JPanel();
    btnPanel.setOpaque(false);
    btnPanel.setPreferredSize(new Dimension(300, 60));
    eastContainer.add(btnPanel, BorderLayout.SOUTH);

    // Add help button to panel
    instructBtn.setPreferredSize(new Dimension(50, 40));
    instructBtn.setBorder(BorderFactory.createLineBorder(Color.black, 5));
    instructBtn.addActionListener(new ButtonListener());
    btnPanel.add(instructBtn);

    // Add restart button to panel
    restartBtn.setPreferredSize(new Dimension(100, 40));
    restartBtn.setBorder(BorderFactory.createLineBorder(Color.black, 5));
    restartBtn.addActionListener(new ButtonListener()); // Add Action Listener (Reset Game)
    btnPanel.add(restartBtn);

    JPanel westContainer = new JPanel();
    westContainer.setPreferredSize(new Dimension(200, 300));
    westContainer.setOpaque(false);
    lab1Panel.add(westContainer, BorderLayout.WEST);
    lab1Panel.add(eastContainer, BorderLayout.EAST);
    return lab1Panel;
  }
示例#16
0
  public Panel_AjoutTour(Game jeu, EcouteurDePanelTerrain edpt, int largeur, int hauteur) {
    this.jeu = jeu;
    this.edpt = edpt;

    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------------------
    // -- panel des tours --
    // ---------------------
    JPanel pTours = new JPanel(new GridLayout(2, 0));
    pTours.setOpaque(false);
    pTours.setPreferredSize(new Dimension(largeur, hauteur));

    String titrePrixAchat = Langue.getTexte(Langue.ID_TXT_PRIX_ACHAT);

    boutonsTours.add(bTourArcher);
    bTourArcher.setToolTipText(titrePrixAchat + " : " + Tower_Archer.PRIX_ACHAT);

    boutonsTours.add(bTourCanon);
    bTourCanon.setToolTipText(titrePrixAchat + " : " + Tower_Canon.PRIX_ACHAT);

    boutonsTours.add(bTourAntiAerienne);
    bTourAntiAerienne.setToolTipText(titrePrixAchat + " : " + Tower_AntiAerial.PRIX_ACHAT);

    boutonsTours.add(bTourDeGlace);
    bTourDeGlace.setToolTipText(titrePrixAchat + " : " + Tower_Ice.PRIX_ACHAT);

    boutonsTours.add(bTourElectrique);
    bTourElectrique.setToolTipText(titrePrixAchat + " : " + Tower_Electric.PRIX_ACHAT);

    boutonsTours.add(bTourDeFeu);
    bTourDeFeu.setToolTipText(titrePrixAchat + " : " + Tower_Fire.PRIX_ACHAT);

    boutonsTours.add(bTourDAir);
    bTourDAir.setToolTipText(titrePrixAchat + " : " + Tower_Air.PRIX_ACHAT);

    boutonsTours.add(bTourDeTerre);
    bTourDeTerre.setToolTipText(titrePrixAchat + " : " + Tower_Earth.PRIX_ACHAT);

    for (JButton bTour : boutonsTours) {
      bTour.addActionListener(this);
      bTour.setBorder(new EmptyBorder(5, 5, 5, 5));
      ManageFonts.setStyle(bTour);
      pTours.add(bTour);
    }

    miseAJour();

    add(pTours, BorderLayout.CENTER);
  }
示例#17
0
  public TestFrame() {
    super("Control Window");
    setLayout(new BorderLayout());
    setSize(400, 300);
    setLocation(500, 10);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    panel = new JPanel();
    getContentPane().add(panel, BorderLayout.NORTH);
    makeSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeSHButtonActionPerformed(e);
          }
        });
    panel.add(makeSHButton);

    JButton graphButton = new JButton("morph");
    graphButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            graphButtonActionPerformed(evt);
          }
        });
    panel.add(graphButton);

    pushAllSHButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            pushAllSHButtonActionPerformed(e);
          }
        });
    panel.add(pushAllSHButton);

    makeRelationsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            makeRelationsButtonActionPerformed(e);
          }
        });
    panel.add(makeRelationsButton);

    panel.setPreferredSize(new java.awt.Dimension(20, 80));
    panel.setBorder(new LineBorder(Color.black));
    JFrame frame = new JFrame("Relationship Frame");
    frame.setSize(500, 500);
    frame.setLocation(10, 10);
    frame.getContentPane().add(testPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
  private JPanel createContentPanel() {
    // compute content and other buttons
    SpringLayout springLayout = new SpringLayout();
    JPanel panel = new JPanel(springLayout);
    int panelHeight = 0;
    JTable propertiesPanel = createPropertiesPanel();
    panelHeight += propertiesPanel.getPreferredSize().getHeight();
    panel.add(propertiesPanel);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JScrollPane scrollPane = new JScrollPane(createAdaptersPanel());
    panelHeight += scrollPane.getPreferredSize().getHeight();
    panel.add(scrollPane);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JPanel buttonsPanel = createButtonsPanel();
    panelHeight += buttonsPanel.getPreferredSize().getHeight();
    panel.add(buttonsPanel);

    springLayout.putConstraint(
        SpringLayout.NORTH, panel, DEFAULT_PADDING, SpringLayout.NORTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, buttonsPanel);

    panel.setPreferredSize(
        new Dimension(
            CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH + COLUMN_WIDTH - 32,
            panelHeight + DEFAULT_PADDING));
    makeCompactGrid(panel, 5, 1, 0, 0, 0, 0);
    return panel;
  }
  TimerControls(ControlBar creator) {
    parent = creator;
    super.setPreferredSize(new Dimension(200, 172));
    setLayout(new BorderLayout());

    pausePlay = new JButton("Play");
    speed = makeJSlider();

    pausePlay.addActionListener(this);
    speed.addChangeListener(this);

    super.add(pausePlay, BorderLayout.WEST);
    super.add(speed, BorderLayout.EAST);
    super.add(new JLabel(" Simulation Speed Controls"), BorderLayout.NORTH);

    super.repaint();
    super.setVisible(true);
  }
  ControlBar(MainWindow creator) {
    parent = creator;

    super.setPreferredSize(new Dimension(720, 172));
    setLayout(new BorderLayout());

    // add timer, save, and heatmap controls to the bar

    tc = new TimerControls(this);
    sc = new SaveControls(parent.getGrid(), this);
    hc = new HeatMapControls(this);
    add(tc, BorderLayout.WEST);
    add(hc, BorderLayout.CENTER);
    add(sc, BorderLayout.EAST);

    super.repaint();
    super.setVisible(true);
    System.out.println("Done Constucting");
  }
  SaveControls(Grid currentGrid, ControlBar creator) {
    parent = creator;
    grid = currentGrid;
    super.setPreferredSize(new Dimension(200, 172));
    setLayout(new GridLayout(3, 0));

    fileName = new JTextField("SaveName");
    save = new JButton("Save");
    load = new JButton("Load");

    save.addActionListener(this);
    load.addActionListener(this);

    super.add(fileName);
    super.add(save);
    super.add(load);

    super.repaint();
    super.setVisible(true);
  }
示例#22
0
  public HotSMain() {
    // General
    setPreferredSize(new Dimension(800, 600));
    canvas.add(this);
    setBackground(Color.GRAY);
    frame.setResizable(false);
    frame.setTitle("Heroes of the Forest");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Overworld
    menuScreen.setPreferredSize(new Dimension(800, 150));
    menuScreen.setBackground(Color.DARK_GRAY);
    menuScreen.setVisible(false);

    menuButtons.add(itemsButton);
    menuButtons.add(equipButton);
    menuButtons.add(skillsButton);
    menuButtons.add(statusButton);
    menuButtons.add(settingsButton);
    menuButtons.add(dataButton);

    for (JButton button : menuButtons) {
      menuScreen.add(button);
      button.addActionListener(this);
    }

    canvas.add(menuScreen, BorderLayout.SOUTH);
    ImageIcon bg = new ImageIcon("OverworldBG.jpg");
    background = bg.getImage();

    frame.pack();
    frame.setVisible(true);
    player = new Player();
    enemies.add(new Stalker(375, 200));
    player.defaultPlayer();
    frame.addKeyListener(this);
    frame.addMouseListener(this);
    frame.addMouseMotionListener(this);
    moveTimer.start();
  }
示例#23
0
  /**
   * @param filenames
   * @exception Exception if internal error
   */
  public ChestImageViewer(String filenames[]) throws Exception {
    DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas();
    if (displayDeviceAreas == null) {
      System.err.println("Cannot determine device display areas");
    } else {
      System.err.println("Found " + displayDeviceAreas.length + " device display areas");
      for (int i = 0; i < displayDeviceAreas.length; ++i) {
        System.err.println("[" + i + "] = " + displayDeviceAreas[i]);
        displayDeviceAreas[i].getFrame().setBackground(Color.black);
        displayDeviceAreas[i].getFrame().setVisible(true);
      }

      {
        // Need to actually add something to the unused left display frame, else background will not
        // be set to black on Windows
        JPanel backgroundPanel = new JPanel();
        backgroundPanel.setBackground(Color.black);
        displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel);
        displayDeviceAreas[0].getFrame().validate();
      }

      frame = displayDeviceAreas[1].getFrame();

      Container content = frame.getContentPane();
      content.setLayout(new GridLayout(1, 1));
      multiPanel = new JPanel();
      // multiPanel.setBackground(Color.black);
      frameWidth = (int) frame.getWidth();
      frameHeight = (int) frame.getHeight();
      Dimension d = new Dimension(frameWidth, frameHeight);
      // multiPanel.setSize(d);
      multiPanel.setPreferredSize(d);
      multiPanel.setBackground(Color.black);
      content.add(multiPanel);
      // frame.pack();
      content.validate();

      loadMultiPanelFromSpecifiedFiles(filenames);
    }
  }
示例#24
0
 public MemoryMonitor() {
   setLayout(new BorderLayout());
   setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
   add(surf = new Surface());
   controls = new JPanel();
   controls.setPreferredSize(new Dimension(135, 80));
   Font font = new Font("serif", Font.PLAIN, 10);
   JLabel label = new JLabel("Sample Rate");
   label.setFont(font);
   label.setForeground(BLACK);
   controls.add(label);
   tf = new JTextField("1000");
   tf.setPreferredSize(new Dimension(45, 20));
   controls.add(tf);
   controls.add(label = new JLabel("ms"));
   label.setFont(font);
   label.setForeground(BLACK);
   controls.add(dateStampCB);
   dateStampCB.setFont(font);
   addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           removeAll();
           if ((doControls = !doControls)) {
             surf.stop();
             add(controls);
           } else {
             try {
               surf.sleepAmount = Long.parseLong(tf.getText().trim());
             } catch (Exception ex) {
             }
             surf.start();
             add(surf);
           }
           revalidate();
           repaint();
         }
       });
 }
  /**
   * Messaged from installComponents to create a Container containing the body of the message. The
   * icon is the created by calling <code>addIcon</code>.
   */
  protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder");
    if (topBorder != null) {
      top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container body = new JPanel(new GridBagLayout());
    Container realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
      JPanel sep = new JPanel();
      sep.setName("OptionPane.separator");
      sep.setPreferredSize(new Dimension(15, 1));
      realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor =
        DefaultLookup.getInt(
            optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0, 0, 3, 0);

    addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
  }
示例#26
0
  @Override
  public void setPlayers(PlayerInfo[] value) {
    // set header label indicating how many players are still needed
    String labelText = "";
    if (value.length == NUMBER_OF_PLAYERS) {
      labelText = "This game is ready to go!";
      addAiButton.setEnabled(false);
    } else {
      labelText = ("Waiting for Players: Need " + (NUMBER_OF_PLAYERS - value.length) + " more");
      addAiButton.setEnabled(true);
    }

    label.setText(labelText);

    // the center panel contains the individual player panels
    center.removeAll();

    // build an individual player panel and add it to the center panel
    for (int i = 0; i < value.length; i++) {
      String builtString = (i + 1) + " " + value[i].getName();
      JPanel playerPanel = new JPanel();
      playerPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); // left justify the text in the panel
      playerPanel.setPreferredSize(new Dimension(200, 50));
      playerPanel.setBackground(
          value[i].getColor().getJavaColor()); // set the background color of the player
      JLabel playerLabel = new JLabel(builtString, SwingConstants.LEFT); // justify the text left
      FontUtils.setFont(playerLabel, LABEL_TEXT_SIZE);
      playerPanel.add(playerLabel);
      center.add(playerPanel);

      // add space between player panels
      Dimension minSize = new Dimension(5, 10);
      Dimension prefSize = new Dimension(5, 10);
      Dimension maxSize = new Dimension(Short.MAX_VALUE, 10);
      center.add(new Box.Filler(minSize, prefSize, maxSize));
    }
  }
示例#27
0
 private void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   okButton.setText("OK");
   okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this));
   filtersTable.setRowSelectionAllowed(true);
   filtersTable.setPreferredSize(new Dimension(418, 200));
   filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
   filtersTable.setCellSelectionEnabled(true);
   filtersTable.setColumnSelectionAllowed(false);
   filtersTable.setModel(m_model);
   addButton.setToolTipText(
       "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type");
   addButton.setText("Add");
   addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this));
   deleteButton.setToolTipText("Delete the currently selected item.");
   deleteButton.setText("Delete");
   deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this));
   upButton.setText("Up");
   upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this));
   dnButton.setText("Down");
   dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this));
   panel1.setPreferredSize(new Dimension(418, 200));
   jScrollPane1.setMinimumSize(new Dimension(200, 80));
   jScrollPane1.setOpaque(true);
   buttonPanel.add(dnButton, null);
   buttonPanel.add(upButton, null);
   buttonPanel.add(addButton, null);
   buttonPanel.add(deleteButton, null);
   buttonPanel.add(okButton, null);
   buttonPanel.add(cancelButton, null);
   getContentPane().add(panel1);
   panel1.add(buttonPanel, BorderLayout.SOUTH);
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(filtersTable, null);
 }
  /**
   * Create the color information panel
   *
   * @param labelFont the font to use for labels
   * @return the color information panel
   */
  private JPanel createColorInfoPanel(Font labelFont) {
    // create a color info panel
    JPanel colorInfoPanel = new JPanel();
    colorInfoPanel.setLayout(new FlowLayout());

    // get the pixel at the x and y
    Pixel pixel = new Pixel(picture, colIndex, rowIndex);

    // create the labels
    rValue = new JLabel("R: " + pixel.getRed());
    gValue = new JLabel("G: " + pixel.getGreen());
    bValue = new JLabel("B: " + pixel.getBlue());

    // create the sample color panel and label
    colorLabel = new JLabel("Color at location: ");
    colorPanel = new JPanel();
    colorPanel.setBorder(new LineBorder(Color.black, 1));

    // set the color sample to the pixel color
    colorPanel.setBackground(pixel.getColor());

    // set the font
    rValue.setFont(labelFont);
    gValue.setFont(labelFont);
    bValue.setFont(labelFont);
    colorLabel.setFont(labelFont);
    colorPanel.setPreferredSize(new Dimension(25, 25));

    // add items to the color information panel
    colorInfoPanel.add(rValue);
    colorInfoPanel.add(gValue);
    colorInfoPanel.add(bValue);
    colorInfoPanel.add(colorLabel);
    colorInfoPanel.add(colorPanel);

    return colorInfoPanel;
  }
示例#29
0
  private void createGUI() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container window = getContentPane();
    window.setLayout(new FlowLayout());

    lSlider = new JSlider(JSlider.VERTICAL, 1, 6, 1);
    window.add(lSlider);
    lSlider.addChangeListener(this);

    panel = new JPanel();
    panel.setPreferredSize(new Dimension(200, 175));
    panel.setBackground(Color.WHITE);
    window.add(panel);

    rSlider = new JSlider(JSlider.VERTICAL, 1, 6, 1);
    window.add(rSlider);
    rSlider.addChangeListener(this);

    deepLabel = new JLabel("Deep end: ");
    window.add(deepLabel);

    deepField = new JTextField(4);
    window.add(deepField);

    shallLabel = new JLabel("Shall end: ");
    window.add(shallLabel);

    shallField = new JTextField(4);
    window.add(shallField);

    areaLabel = new JLabel("Area of the swimming pool: ");
    window.add(areaLabel);

    areaField = new JTextField(4);
    window.add(areaField);
  }
示例#30
0
  // --------------------------------initGUI------------------------------------
  public void initGUI() {
    bDeployed = bOpponentDeployed = false;
    listAT = new LinkedList();

    frame.setJMenuBar(new GameMenuBar(this));
    panParty = new PartyPanel(200, 480);
    panStatus = new JPanel(null);
    oMap = new Map(600, 350);
    panChat = new ChatPanel(600, 200);

    Container contentPane = frame.getContentPane();

    panParty.setOpaque(true);
    panStatus.setOpaque(true);
    panChat.setOpaque(true);

    panStatus.setPreferredSize(new Dimension(200, 70));

    contentPane.add(panStatus);
    contentPane.add(panParty);
    contentPane.add(oMap);
    contentPane.add(panChat);

    SpringLayout oLayout = new SpringLayout();
    contentPane.setLayout(oLayout);

    oLayout.putConstraint(SpringLayout.WEST, panParty, 0, SpringLayout.WEST, contentPane);
    oLayout.putConstraint(SpringLayout.NORTH, panParty, 0, SpringLayout.NORTH, contentPane);
    oLayout.putConstraint(SpringLayout.WEST, panStatus, 0, SpringLayout.WEST, contentPane);
    oLayout.putConstraint(SpringLayout.SOUTH, panStatus, 0, SpringLayout.SOUTH, contentPane);
    oLayout.putConstraint(SpringLayout.EAST, oMap, 0, SpringLayout.EAST, contentPane);
    oLayout.putConstraint(SpringLayout.NORTH, oMap, 0, SpringLayout.NORTH, contentPane);
    oLayout.putConstraint(SpringLayout.WEST, panChat, 0, SpringLayout.EAST, panStatus);
    oLayout.putConstraint(SpringLayout.NORTH, panChat, 0, SpringLayout.SOUTH, oMap);
    oLayout.putConstraint(SpringLayout.EAST, contentPane, 0, SpringLayout.EAST, panChat);
    oLayout.putConstraint(SpringLayout.SOUTH, contentPane, 0, SpringLayout.SOUTH, panChat);

    panChat.validate();
    panChat.setVisible(true);

    Insets oInsets = panStatus.getInsets();
    int nX = oInsets.left + 5;
    int nY = oInsets.top + 5;

    lblStatus1 = new JLabel("Not Connected...");
    lblStatus2 = new JLabel("No Party Formed...");
    lblStatus3 = new JLabel();

    Dimension oSize = lblStatus1.getPreferredSize();

    lblStatus1.setBounds(nX, nY, 180, oSize.height);
    nY += oSize.height + 7;
    lblStatus2.setBounds(nX, nY, 180, oSize.height);
    nY += oSize.height + 7;
    lblStatus3.setBounds(nX, nY, 180, oSize.height);

    panStatus.add(lblStatus1);
    panStatus.add(lblStatus2);
    panStatus.add(lblStatus3);

    frame.pack();
    frame.setResizable(false);
    frame.setLocation(
        ((scrBounds.x + scrBounds.width - frame.getWidth()) / 2),
        ((scrBounds.y + scrBounds.height - frame.getHeight()) / 2));

    oMap.addKeyListener(oMap);
    oMap.setButtonEvents(this);
  }