예제 #1
0
 // Script Editor
 private void scriptEditor() {
   scriptfield.setEditable(true);
   scriptfield.setFont(font);
   scriptfield.setPreferredSize(new Dimension(800, 900));
   scriptfield.setCursor(null);
   script.add(scriptfield);
 }
  /*
   * Test method for 'java.awt.TextArea.getPreferredSize(int, int)'
   */
  public void testGetPreferredSizeIntInt() {
    int rows = 2;
    int cols = 3;
    Dimension prefSize = new Dimension();
    assertEquals(area.getMinimumSize(rows, cols), area.getPreferredSize(rows, cols));
    prefSize.setSize(12, 13);
    area.setPreferredSize(prefSize);
    assertEquals(prefSize, area.getPreferredSize(rows, cols));
    area.setPreferredSize(null);
    assertEquals(new Dimension(), area.getPreferredSize(rows, cols));
    frame = new Frame();
    frame.add(area);
    frame.addNotify();

    assertEquals(area.getMinimumSize(rows, cols), area.getPreferredSize(rows, cols));
  }
예제 #3
0
  ComponentSampleI() {
    // analise o uso do método abaixo
    // tf.setPreferredSize(new Dimension(200,20));

    // insere b e tf no painel
    p.add(b);
    p.add(tf);

    // insere o painel no norte do frame
    add(p, BorderLayout.NORTH);

    // atribui cor ao fundo e às letras na área de texto
    ta.setBackground(Color.cyan);
    ta.setForeground(Color.red);
    ta.setPreferredSize(new Dimension(250, 50));

    x.setBackground(Color.yellow);
    add(x, BorderLayout.CENTER); // estica o componente em ambas as direções

    add(ta, BorderLayout.EAST); // estica o componente na horizontal
    add(l, BorderLayout.SOUTH); // estica o componente na vertical

    // descobre as dimensões do monitor
    d = (Toolkit.getDefaultToolkit()).getScreenSize();

    // calcula e posiciona o frame no centro da tela
    setLocation(
        (d.width - this.getSize().width) / 2 - 150, (d.height - this.getSize().height) / 2 - 200);

    setSize(300, 400);
    setVisible(true);
  }
 /*
  * Test method for 'java.awt.TextArea.getPreferredSize()'
  */
 public void testGetPreferredSize() {
   Dimension prefSize = new Dimension();
   assertEquals(prefSize, area.getPreferredSize());
   prefSize.setSize(4, 5);
   area.setPreferredSize(prefSize);
   assertNotSame(prefSize, area.getPreferredSize());
   assertEquals(prefSize, area.getPreferredSize());
   area.setPreferredSize(null);
   assertEquals(new Dimension(), area.getPreferredSize());
   frame = new Frame();
   frame.add(area);
   frame.addNotify();
   assertEquals(
       "By default preferred size is equal to minimum size",
       area.getMinimumSize(),
       area.getPreferredSize());
 }
 /*
  * Test method for 'java.awt.TextArea.preferredSize()'
  */
 @SuppressWarnings("deprecation")
 public void testPreferredSize() {
   Dimension prefSize = new Dimension();
   assertEquals(area.minimumSize(), area.preferredSize());
   prefSize.setSize(40, 50);
   area.setPreferredSize(prefSize);
   assertNotSame(prefSize, area.preferredSize());
   assertEquals(prefSize, area.preferredSize());
   area.setPreferredSize(null);
   assertEquals(new Dimension(), area.preferredSize());
   frame = new Frame();
   frame.add(area);
   frame.addNotify();
   assertEquals(
       "By default preferred size is equal to minimum size",
       area.minimumSize(),
       area.preferredSize());
 }
예제 #6
0
  private JPanel getContainer() {
    layout = new FlowLayout(); // Instanciation du layout
    layout.setAlignment(FlowLayout.CENTER); // On centre les composants

    container = new JPanel(); // On cr�e notre objet
    container.setLayout(layout); // On applique le layout

    textCycle.setEditable(false);
    textCycle.setPreferredSize(new Dimension(600, 200));
    for (int k = 0; k < cycles.size(); k++) {
      textCycle.setText(
          textCycle.getText()
              + "Cycle no"
              + k
              + " :"
              + cycles.get(k).toString()
              + "\n"
              + "\n"); // On lui donne un texte
      container.add(textCycle); // On l'ajoute au container
    }

    btnPath = new JButton(); // Cr�ation du bouton
    btnPath.setPreferredSize(new Dimension(200, 25)); // On lui donne une taille
    btnPath.setText("Show path"); // On lui donne un texte
    btnPath.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnPath); // On l'ajoute � la fen�tre

    oneState =
        new JComboBox(listOneState); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    oneState.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(oneState); // on l'ajoute � la fen�tre

    twoStates =
        new JComboBox(listTwoStates); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    twoStates.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(twoStates); // on l'ajoute � la fen�tre

    btnCycle = new JButton(); // Cr�ation du bouton
    btnCycle.setPreferredSize(new Dimension(300, 25)); // On lui donne une taille
    btnCycle.setText("Show cycle"); // On lui donne un texte
    btnCycle.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnCycle); // On l'ajoute � la fen�tre

    cyclesBox =
        new JComboBox(listCycles); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    cyclesBox.setPreferredSize(new Dimension(120, 25)); // On lui donne une taille
    container.add(cyclesBox); // on l'ajoute � la fen�tre

    btnReset = new JButton(); // Cr�ation du bouton
    btnReset.setPreferredSize(new Dimension(400, 25)); // On lui donne une taille
    btnReset.setText("Clear"); // On lui donne un texte
    btnReset.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnReset); // On l'ajoute � la fen�tre

    return container;
  }
  /** Returns the output text area. */
  private TextArea getOutput() {
    if (output == null) {
      output = new TextArea(6, 100);
      output.append("Output Goes Here...");
      output.setPreferredSize(new Dimension(580, 120));
      output.setEditable(false);
    }

    return output;
  }
예제 #8
0
  public JPanel Panels() throws IOException {

    Object[][] data = new Object[0][7];

    // Create the initial Routes Table
    try {
      FileInput input = new FileInput("input.txt"); // read the input file

      // get the data from input.txt
      routesInfo = input.routeArrayList(input.routesToken);
      routesInfo = sortRouteArray(routesInfo);
      airportsInfo = input.airportArrayList(input.airportsToken);
      closuresInfo = input.closureArrayList(input.closuresToken);
      routesInfo = routeClosureStatus(routesInfo, closuresInfo);

      // If one section has an error (is null) set all sections to null and lock all routes and
      // airprots menu items
      if (airportsInfo == null) {
        routesInfo = null;
        closuresInfo = null;
        systemLocked = true;
      } else if (routesInfo == null) {
        airportsInfo = null;
        closuresInfo = null;
        systemLocked = true;
      } else if (closuresInfo == null) {
        airportsInfo = null;
        routesInfo = null;
        systemLocked = true;
      }

      data = convertArrayListTo2DArray(routesInfo, 1);

    } catch (FileNotFoundException e1) { // If input.txt is missing
      System.out.println("The file input.txt is missing.");
    } catch (NullPointerException e1) { // If there are any other errors in the file
      System.out.println("There are errors in the input.txt file");
    }

    routePanel.add(CreateRouteTable(data, totalSize)); // add the table to the JPanel
    routePanel.setBorder(BorderFactory.createTitledBorder("Route Table"));
    // ------------------------------------------------end of route
    // table--------------------------------------------------------

    histPanel.setPreferredSize(new Dimension(totalSize.width, totalSize.height / 5));
    histPanel.setBorder(BorderFactory.createTitledBorder("History"));
    historyArea = new TextArea();
    historyArea.setEditable(false);
    historyArea.setPreferredSize(new Dimension(totalSize.width * 7 / 10, totalSize.height / 7));
    histPanel.add(historyArea);
    // ------------------------------------------------end of history
    // table--------------------------------------------------------
    Object[][] emptyData = new Object[0][7];
    resultsPanel.setBorder(BorderFactory.createTitledBorder("Search Results"));
    resultsPanel.add(CreateResultsTable(emptyData, totalSize));
    // ------------------------------------------------end of results
    // table--------------------------------------------------------

    mainPanel.add(routePanel, BorderLayout.WEST);
    mainPanel.add(histPanel, BorderLayout.SOUTH);
    mainPanel.add(resultsPanel, BorderLayout.EAST);

    return mainPanel;
  }