private JPanel createParametersPanel() {
    JPanel parametersPanel = new JPanel();
    parametersPanel.setBorder(BorderFactory.createTitledBorder(dataLayer.getString("PARAMETERS")));

    GridLayout parametersPanelLayout = new GridLayout(0, 3);
    parametersPanelLayout.setHgap(10);
    parametersPanelLayout.setVgap(5);
    parametersPanel.setLayout(parametersPanelLayout);
    //
    // -- DELAY ------------------------------------------------------------
    JLabel delayName = new JLabel(dataLayer.getString("DELAY") + ":");
    delayName.setFont(fontBold);
    parametersPanel.add(delayName);

    // create formatter
    RegexFormatter delayFormatter = new RegexFormatter(Validator.DELAY_PATTERN);
    delayFormatter.setAllowsInvalid(true); // allow to enter invalid value for short time
    delayFormatter.setCommitsOnValidEdit(true); // value is immedeatly published to textField
    delayFormatter.setOverwriteMode(false); // do not overwrite charracters

    jTextFieldDelay = new JFormattedTextField(delayFormatter);
    jTextFieldDelay.setText("" + cable.getDelay());
    jTextFieldDelay.setToolTipText(dataLayer.getString("REQUIRED_FORMAT_IS") + " 1-99");
    // add decorator that paints wrong input icon
    parametersPanel.add(new JLayer<JFormattedTextField>(jTextFieldDelay, layerUI));

    JLabel delayTip = new JLabel("1-99");
    parametersPanel.add(delayTip);

    // --  ------------------------------------------------------------
    return parametersPanel;
  }
 private JPanel getJPanel1() {
   if (jPanel1 == null) {
     jPanel1 = new JPanel();
     GridLayout jPanel1Layout = new GridLayout(7, 2);
     jPanel1Layout.setColumns(2);
     jPanel1Layout.setHgap(5);
     jPanel1Layout.setVgap(5);
     jPanel1Layout.setRows(7);
     jPanel1.setLayout(jPanel1Layout);
     jPanel1.add(getJLabel1());
     jPanel1.add(getJTextField1());
     jPanel1.add(getJLabel2());
     jPanel1.add(getJTextField2());
     jPanel1.add(getJLabel3());
     jPanel1.add(getJTextField3());
     jPanel1.add(getJLabel4());
     jPanel1.add(getJTextField4());
     jPanel1.add(getJLabel5());
     jPanel1.add(getJTextField5());
     jPanel1.add(getJLabel6());
     jPanel1.add(getJTextField6());
     jPanel1.add(getJLabel7());
     jPanel1.add(getJTextField7());
   }
   return jPanel1;
 }
  /**
   * This method initializes jPanel
   *
   * @return JPanel
   */
  private JPanel getJPanel() {
    if (jPanel == null) {
      jPanel = new JPanel();
      java.awt.GridLayout layGridLayout7 = new java.awt.GridLayout();
      layGridLayout7.setRows(4);
      layGridLayout7.setColumns(4);
      layGridLayout7.setHgap(10);
      layGridLayout7.setVgap(10);
      jPanel.setLayout(layGridLayout7);

      // Another way to do this, but wouldn't
      // have a visual in the editor.
      //  for (int i = 1; i <= 16; i++) {
      //      String label = String.valueOf(i);
      //      JButton b = new JButton(label);
      //      b.addMouseListener(buttonEvents);
      //      b.addMouseMotionListener(buttonEvents);
      //      jPanel.add(b);
      //  }

      for (int i = 0; i < jButtons.length; i++) {
        jButtons[i] = createButton(String.valueOf(i + 1));
        jPanel.add(jButtons[i], null);
      }

      jPanel.setBackground(java.awt.Color.white);
      jPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
    }
    return jPanel;
  }
 private void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
   contentPane.setBorder(border1);
   contentPane.setLayout(borderLayout1);
   controlsPane.setLayout(gridLayout1);
   gridLayout1.setColumns(1);
   gridLayout1.setHgap(10);
   gridLayout1.setRows(0);
   gridLayout1.setVgap(10);
   okButton.setVerifyInputWhenFocusTarget(true);
   okButton.setMnemonic('O');
   okButton.setText("OK");
   buttonsPane.setLayout(flowLayout1);
   flowLayout1.setAlignment(FlowLayout.CENTER);
   messagePane.setEditable(false);
   messagePane.setText("");
   borderLayout1.setHgap(10);
   borderLayout1.setVgap(10);
   this.setTitle("Subscription Authorization");
   this.getContentPane().add(contentPane, BorderLayout.CENTER);
   contentPane.add(controlsPane, BorderLayout.SOUTH);
   controlsPane.add(responsesComboBox, null);
   controlsPane.add(buttonsPane, null);
   buttonsPane.add(okButton, null);
   contentPane.add(messageScrollPane, BorderLayout.CENTER);
   messageScrollPane.getViewport().add(messagePane, null);
 }
  private JPanel createInfoPanel() {
    JPanel infoPanel = new JPanel();
    infoPanel.setBorder(BorderFactory.createTitledBorder(dataLayer.getString("INFO")));

    GridLayout infoPanelLayout = new GridLayout(0, 2);
    infoPanelLayout.setHgap(10);
    infoPanelLayout.setVgap(5);
    infoPanel.setLayout(infoPanelLayout);
    //
    // -- TYPE -------------------------------------------------------------
    JLabel typeName = new JLabel(dataLayer.getString("TYPE") + ":");
    fontBold = new Font(typeName.getFont().getName(), Font.BOLD, typeName.getFont().getSize());
    typeName.setFont(fontBold);
    infoPanel.add(typeName);

    JLabel typeValue = new JLabel(cable.getHwType().toString());
    infoPanel.add(typeValue);
    //
    // -- DEVICE 1 name and interface --------------------------------------
    JLabel device1Name = new JLabel(dataLayer.getString("COMPONENT") + " 1:");
    device1Name.setFont(fontBold);
    infoPanel.add(device1Name);

    JLabel device1Value = new JLabel(cable.getComponent1().getDeviceName());
    infoPanel.add(device1Value);
    //
    JLabel interface1Name = new JLabel(dataLayer.getString("INTERFACE") + " 1:");
    interface1Name.setFont(fontBold);
    infoPanel.add(interface1Name);

    JLabel interface1Value = new JLabel(cable.getEth1().getName());
    infoPanel.add(interface1Value);
    //
    // -- DEVICE 2 name and interface --------------------------------------
    JLabel device2Name = new JLabel(dataLayer.getString("COMPONENT") + " 2:");
    device2Name.setFont(fontBold);
    infoPanel.add(device2Name);

    JLabel device2Value = new JLabel(cable.getComponent2().getDeviceName());
    infoPanel.add(device2Value);
    //
    JLabel interface2Name = new JLabel(dataLayer.getString("INTERFACE") + " 2:");
    interface2Name.setFont(fontBold);
    infoPanel.add(interface2Name);

    JLabel interface2Value = new JLabel(cable.getEth2().getName());
    infoPanel.add(interface2Value);
    //
    // -- UNIQUE ID --------------------------------------------------------
    if (viewUniqueId) {
      JLabel deviceIdName = new JLabel(dataLayer.getString("DEVICE_UNIQUE_ID") + ":");
      deviceIdName.setFont(fontBold);
      infoPanel.add(deviceIdName);

      JLabel deviceIdValue = new JLabel("" + cable.getId().toString());
      infoPanel.add(deviceIdValue);
    }

    return infoPanel;
  }
示例#6
0
 private GridLayout createButtonPanelLayout() {
   GridLayout buttonPanelLayout = new GridLayout(2, 2);
   buttonPanelLayout.setColumns(2);
   buttonPanelLayout.setHgap(5);
   buttonPanelLayout.setVgap(5);
   buttonPanelLayout.setRows(2);
   return buttonPanelLayout;
 }
示例#7
0
  public void buildGUI() {
    theFrame = new JFrame("Cyber BeatBox");
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    BorderLayout layout = new BorderLayout();
    JPanel background = new JPanel(layout);
    background.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    checkboxList = new ArrayList<JCheckBox>();
    Box buttonBox = new Box(BoxLayout.Y_AXIS);

    JButton start = new JButton("Start");
    start.addActionListener(new MyStartListener());
    buttonBox.add(start);

    JButton stop = new JButton("Stop");
    stop.addActionListener(new MyStopListener());
    buttonBox.add(stop);

    JButton upTempo = new JButton("Tempo Up");
    upTempo.addActionListener(new MyUpTempoListener());
    buttonBox.add(upTempo);

    JButton downTempo = new JButton("Tempo Down");
    downTempo.addActionListener(new MyDownTempoListener());
    buttonBox.add(downTempo);

    Box nameBox = new Box(BoxLayout.Y_AXIS);
    for (int i = 0; i < 16; i++) {
      nameBox.add(new Label(instrumentNames[i]));
    }

    background.add(BorderLayout.EAST, buttonBox);
    background.add(BorderLayout.WEST, nameBox);

    theFrame.getContentPane().add(background);

    GridLayout grid = new GridLayout(16, 16);
    grid.setVgap(1);
    grid.setHgap(2);
    mainPanel = new JPanel(grid);
    background.add(BorderLayout.CENTER, mainPanel);

    for (int i = 0; i < 256; i++) {
      JCheckBox c = new JCheckBox();
      c.setSelected(false);
      checkboxList.add(c);
      mainPanel.add(c);
    } // end loop

    setUpMidi();

    theFrame.setBounds(50, 50, 300, 300);
    theFrame.pack();
    theFrame.setVisible(true);
  } // close method
示例#8
0
  public ListarHisClientes(Frame padre) {

    super((Frame) padre, true);
    try {
      // this.cod_cli=cod_cli;
      lblNombre = new JLabel();
      lblNombre.setText("Nombre:");
      lblNombre.setBounds(17, 15, 48, 16);
      txtNombre = new JTextField();
      txtNombre.setBounds(77, 13, 323, 20);

      pnlArriba = new JPanel();

      pnlAbajo = new JPanel();
      GridLayout pnlAbajoLayout = new GridLayout(1, 1);
      pnlAbajoLayout.setHgap(5);
      pnlAbajoLayout.setVgap(5);
      pnlAbajoLayout.setColumns(1);
      pnlAbajo.setLayout(pnlAbajoLayout);
      getContentPane().add(pnlAbajo, BorderLayout.CENTER);
      pnlAbajo.setPreferredSize(new java.awt.Dimension(859, 429));

      getContentPane().add(pnlArriba, BorderLayout.NORTH);
      pnlArriba.setPreferredSize(new java.awt.Dimension(892, 42));
      pnlArriba.setLayout(null);
      pnlArriba.add(lblNombre);
      pnlArriba.add(txtNombre);

      btnBuscar = new JButton();
      pnlArriba.add(btnBuscar);
      btnBuscar.setText("Buscar");
      btnBuscar.setBounds(325, 10, 81, 26);
      btnBuscar.setVisible(false);
      btnBuscar.addActionListener(this);

      jPanel1 = new JPanel();
      getContentPane().add(jPanel1, BorderLayout.SOUTH);
      jPanel1.setPreferredSize(new java.awt.Dimension(412, 5));

      jScrollPane1 = new JScrollPane();
      pnlAbajo.add(jScrollPane1);
      jScrollPane1.setPreferredSize(new java.awt.Dimension(859, 467));

      jTable1 = new JTable();
      jScrollPane1.setViewportView(jTable1);
      jTable1.setModel(modelo2);
      jTable1.addMouseListener(this);

      this.setSize(428, 266);
      getNombre(ConfigurarCuentas.cod_cli);
      listarXcod(ConfigurarCuentas.cod_cli);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#9
0
 protected JComponent createButtonPanel() {
   GridLayout gridLayout = new GridLayout();
   JPanel jPanelButtons = new JPanel();
   jPanelButtons.setLayout(gridLayout);
   gridLayout.setRows(1);
   gridLayout.setHgap(10);
   gridLayout.setVgap(5);
   gridLayout.setColumns(buttons.length);
   for (int i = 0; i < buttons.length; i++) {
     jPanelButtons.add(buttons[i]);
   }
   return jPanelButtons;
 }
示例#10
0
  // table
  public void defineMiddlePanel() {
    middle = new JPanel();
    middle.setBackground(GuiControl.FILLER_COLOR);
    middle.setLayout(new FlowLayout(FlowLayout.CENTER));
    JPanel gridPanel = new JPanel();
    gridPanel.setBackground(GuiControl.SCREEN_BACKGROUND);
    middle.add(gridPanel);
    GridLayout gl = new GridLayout(5, 2);
    gl.setHgap(8);
    gl.setVgap(8);
    gridPanel.setLayout(gl);
    gridPanel.setBorder(new WindowBorder(GuiControl.WINDOW_BORDER));

    // add fields
    String[] fldNames = DefaultData.FIELD_NAMES;

    String labelName = fldNames[DefaultData.PRODUCT_NAME_INT];
    makeLabel(gridPanel, labelName);
    productNameField = new JTextField(10);
    productNameField.setText(fieldValues.getProperty(labelName));
    gridPanel.add(productNameField);

    // catalog group is different from the other fields
    // because it plays a different role in MaintainCatalog
    // so it is set differently
    labelName = "Catalog";
    makeLabel(gridPanel, labelName);
    catalogGroupField = new JComboBox();
    catalogGroupField.addItem(DefaultData.BOOKS);
    catalogGroupField.addItem(DefaultData.CLOTHES);
    catalogGroupField.setSelectedItem(catalogGroup);
    gridPanel.add(catalogGroupField);

    labelName = fldNames[DefaultData.PRICE_PER_UNIT_INT];
    makeLabel(gridPanel, labelName);
    pricePerUnitField = new JTextField(10);
    pricePerUnitField.setText(fieldValues.getProperty(labelName));
    gridPanel.add(pricePerUnitField);

    labelName = fldNames[DefaultData.MFG_DATE_INT];
    makeLabel(gridPanel, labelName);
    mfgDateField = new JTextField(10);
    mfgDateField.setText(fieldValues.getProperty(labelName));
    gridPanel.add(mfgDateField);

    labelName = fldNames[DefaultData.QUANTITY_INT];
    makeLabel(gridPanel, labelName);
    quantityField = new JTextField(10);
    quantityField.setText(fieldValues.getProperty(labelName));
    gridPanel.add(quantityField);
  }
  private void setUpTxtPanel() {
    // set up border for text panel
    TitledBorder border = BorderFactory.createTitledBorder("Total orders and costs");
    border.setTitleJustification(TitledBorder.CENTER);

    // set up layout for text panel
    GridLayout txtPanelLayout = new GridLayout(4, 2);
    txtPanelLayout.setHgap(5);
    txtPanelLayout.setVgap(5);
    txtPanel = new JPanel(txtPanelLayout);
    txtPanel.setBorder(border);

    setUpTxtPanelLabels();
  }
 /**
  * This method initializes jPanel
  *
  * @return javax.swing.JPanel
  */
 private JPanel getJPanel() {
   if (jPanel == null) {
     GridLayout gridLayout = new GridLayout();
     gridLayout.setRows(1);
     gridLayout.setHgap(10);
     gridLayout.setVgap(10);
     gridLayout.setColumns(2);
     jPanel = new JPanel();
     jPanel.setLayout(gridLayout);
     jPanel.add(getJButton(), null);
     jPanel.add(getJButton1(), null);
   }
   return jPanel;
 }
示例#13
0
 /**
  * This method initializes legendPanel
  *
  * @return javax.swing.JPanel
  */
 private JPanel getLegendPanel() {
   GridLayout gridLayout = new GridLayout();
   gridLayout.setRows(2);
   gridLayout.setHgap(3);
   gridLayout.setVgap(3);
   gridLayout.setColumns(2);
   JPanel legendPanel = new JPanel();
   legendPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));
   legendPanel.setLayout(gridLayout);
   addToLegend(legendPanel, "Key was found in base and compare file", Color.white);
   addToLegend(legendPanel, "Key was found in compare but not in base", Color.red);
   addToLegend(legendPanel, "Text for this key was changed but not saved yet", Color.orange);
   addToLegend(legendPanel, "Key was not found in compare file", Color.yellow);
   return legendPanel;
 }
 /**
  * This method initializes jPanel_TitleArea
  *
  * @return javax.swing.JPanel
  */
 private JPanel getJPanel_TitleArea() {
   if (jPanel_TitleArea == null) {
     GridLayout gridLayout = new GridLayout();
     gridLayout.setRows(2);
     gridLayout.setHgap(0);
     gridLayout.setColumns(0);
     gridLayout.setVgap(10);
     jPanel_TitleArea = new JPanel();
     jPanel_TitleArea.setLayout(gridLayout);
     jPanel_TitleArea.setName("jPanel2");
     jPanel_TitleArea.add(jLabel_Title, null);
     jPanel_TitleArea.add(getJPanel_ExplArea1(), null);
   }
   return jPanel_TitleArea;
 }
    /** Initializes all the components of the panel. */
    private void init() {
      final int[] ctrls = my_controls.getControls();
      final String[] ctrl_labels = my_controls.getControlLabels();

      final GridLayout grid = new GridLayout(ctrl_labels.length, NUM_COLUMNS_PER_PLAYER);
      grid.setVgap(VERTICAL_GAP);
      grid.setHgap(HORIZONTAL_GAP);
      setLayout(grid);

      for (int i = 0; i < ctrl_labels.length; i++) {
        final JLabel label = new JLabel(ctrl_labels[i]);
        add(label);
        final JTextField tf = new JTextField(KeyEvent.getKeyText(ctrls[i]));
        setUpTextField(tf, i);
        add(tf);
      }
    }
  /**
   * Erstellt die grafische Oberfläche.
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    contentPane = (JPanel) this.getContentPane();
    m_agentLabel.setBorder(BorderFactory.createEtchedBorder());
    m_agentLabel.setMaximumSize(new Dimension(150, 20));
    m_agentLabel.setMinimumSize(new Dimension(150, 20));
    m_agentLabel.setPreferredSize(new Dimension(150, 20));
    m_agentLabel.setToolTipText("Name des Agenten");
    m_agentLabel.setText("Agenten Name:");
    m_gridLayout.setColumns(3);
    m_gridLayout.setHgap(10);
    m_gridLayout.setRows(4);
    m_gridLayout.setVgap(10);
    contentPane.setLayout(m_gridLayout);
    this.setSize(new Dimension(581, 212));
    this.setTitle("Agentenanmeldung");
    contentPane.setMaximumSize(new Dimension(300, 32767));
    contentPane.setMinimumSize(new Dimension(300, 80));
    contentPane.setPreferredSize(new Dimension(300, 80));
    m_agentClass.setBorder(BorderFactory.createEtchedBorder());
    m_agentClass.setText("Klasse des Agenten:");
    m_serverLabel.setBorder(BorderFactory.createEtchedBorder());
    m_serverLabel.setText("Source-Server:");
    m_agentTF.setText("");
    m_roVButton.setBorder(BorderFactory.createRaisedBevelBorder());
    m_roVButton.setActionCommand("Registriere Agent ohne Visualisierung");
    m_roVButton.setText("Registriere Agent ohne Visualisierung");
    m_roVButton.addActionListener(new AgentRegistrationFrame_m_roVButton_actionAdapter(this));
    m_rwVAgentButton.setBorder(BorderFactory.createRaisedBevelBorder());
    m_rwVAgentButton.setText("Registriere Agent mit Visualisierung");
    m_rwVAgentButton.addActionListener(
        new AgentRegistrationFrame_m_rwVAgentButton_actionAdapter(this));

    m_rwVAgentButton.setVisible(false); // später auf true setzten

    m_agentClassCombo = new JComboBox(this.getAgentClasses());
    m_serverTF.setText("http://localhost:2003/");
    contentPane.add(m_agentLabel, null);
    contentPane.add(m_agentTF, null);
    contentPane.add(m_agentClass, null);
    contentPane.add(m_agentClassCombo, null);
    contentPane.add(m_serverLabel, null);
    contentPane.add(m_serverTF, null);
    contentPane.add(m_roVButton, null);
    contentPane.add(m_rwVAgentButton, null);
  }
示例#17
0
 private void preinitGUI() {
   try {
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     this.setResizable(false);
     {
       titleLabel = new JLabel();
       getContentPane().add(titleLabel, BorderLayout.NORTH);
       titleLabel.setFont(new java.awt.Font("Segoe UI", 1, 20));
       titleLabel.setPreferredSize(new java.awt.Dimension(434, 62));
       titleLabel.setHorizontalTextPosition(SwingConstants.CENTER);
       titleLabel.setText("TITOLO");
     }
     {
       buttonContainer = new JPanel();
       FlowLayout buttonContainerLayout = new FlowLayout();
       buttonContainerLayout.setAlignment(FlowLayout.RIGHT);
       buttonContainer.setLayout(buttonContainerLayout);
       getContentPane().add(buttonContainer, BorderLayout.SOUTH);
       {
         cancelButton = new JButton();
         buttonContainer.add(cancelButton);
         cancelButton.setText("Annulla");
         cancelButton.addActionListener(this);
       }
       {
         okButton = new JButton();
         buttonContainer.add(okButton);
         okButton.setText("Ok");
         okButton.addActionListener(this);
       }
     }
     {
       contentPanel = new JPanel();
       GridLayout contentPanelLayout = new GridLayout(1, 1);
       contentPanelLayout.setColumns(1);
       contentPanelLayout.setHgap(5);
       contentPanelLayout.setVgap(5);
       contentPanel.setLayout(contentPanelLayout);
       getContentPane().add(contentPanel, BorderLayout.CENTER);
       contentPanel.setPreferredSize(new java.awt.Dimension(434, 236));
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#18
0
  /**
   * Crée et renvoie le panneau de sprites
   *
   * @return Le panel contenant les sprites
   */
  public JPanel createSpritesPanel() {
    panneauSprites.setLayout(new GridBagLayout());
    panneauSprites.add(
        sprites,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    // Création de l'affichage des sprites

    // sprites.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    layoutSprites = new GridLayout();
    layoutSprites.setHgap(0);
    layoutSprites.setVgap(0);
    sprites.setLayout(layoutSprites);
    if (groupe.getButtonCount() <= 0) {
      System.err.println(
          "Erreur dans Selection.Selection(int lc, "
              + "int hc) : pas de dossiers dans le dossier images.");
    } else {
      ((JRadioButton) categories.getComponent(0)).setSelected(true);
      this.afficherSprites(
          new File("images/" + ((JRadioButton) categories.getComponent(0)).getText()));
    }

    // sprites.setLayout(new GridLayout(nbrSprites/nbrColonnes, nbrColonnes,
    // 0, 0));
    repaint();
    return panneauSprites;
  }
示例#19
0
  public CalculatorPanel() {

    result = 0;
    lastCommand = "+";
    ActionListener command = new CommandAction();

    GridLayout layout = new GridLayout(2, 5);
    layout.setHgap(5);
    layout.setVgap(5);

    panel = new JPanel();
    panel.setLayout(layout);
    panel.setPreferredSize(new Dimension(400, 200));

    // add display
    display = new JTextField();
    Command = new JTextField("+");
    firstNumber = new JTextField();
    secondNumber = new JTextField();
    JTextField equal = new JTextField("=");

    equal.setEnabled(false);
    display.setEnabled(false);
    Command.setEnabled(false);

    panel.add(firstNumber);
    panel.add(Command);
    panel.add(secondNumber);
    panel.add(equal);
    panel.add(display);

    addButton("+", command);
    addButton("-", command);
    addButton("*", command);
    addButton("/", command);
    addButton("OK", command);
    add(panel, BorderLayout.CENTER);
  }
示例#20
0
  /** @param parent Parent Frame of this panel */
  public AdminView(tester parent) {
    padre = parent;
    try { // Start Setting the look and feel to nimbus
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
      // If Nimbus is not available, set gui to CrossPlatform
      try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      } catch (ClassNotFoundException a) {
        // TODO Auto-generated catch block
      } catch (InstantiationException b) {
        // TODO Auto-generated catch block
      } catch (IllegalAccessException c) {
        // TODO Auto-generated catch block
      } catch (UnsupportedLookAndFeelException d) {
        // TODO Auto-generated catch block
      }
    }
    try { // start up the controller
      control = new Controller();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
    } catch (IOException e) {
      // TODO Auto-generated catch block
    }
    // make the panels
    JPanel total = new JPanel(new BorderLayout());
    JPanel test = new JPanel();
    JPanel users = new JPanel();
    JPanel info = new JPanel();
    // set any gaps i want
    Buttons.setVgap(10);
    Info.setHgap(20);
    // set layouts for the panels
    users.setLayout(List);
    test.setLayout(Buttons);
    info.setLayout(Info);
    // Set up the list
    listModel = new DefaultListModel<String>();
    userList = new JList<String>(listModel);
    userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // only one thing at a time
    userList.setVisibleRowCount(10);
    populateUsers();
    // userList.setPreferredSize(new Dimension(200,200));

    userList.setLayoutOrientation(JList.VERTICAL); // lists items vertically
    // put a scroll pane all up in
    JScrollPane userscroller =
        new JScrollPane(
            userList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    userscroller.setPreferredSize(new Dimension(200, 200));

    // Initialize buttons
    add_user = new JButton("Add User");
    add_user.setPreferredSize(new Dimension(100, 20));
    delete_user = new JButton("Delete User");
    delete_user.setPreferredSize(new Dimension(100, 20));
    logout = new JButton("Logout");
    logout.setPreferredSize(new Dimension(100, 20));
    // add listeners
    add_user.addActionListener(this);
    add_user.setActionCommand("Add");
    delete_user.addActionListener(this);
    delete_user.setActionCommand("Delete");
    logout.addActionListener(this);
    logout.setActionCommand("Logout");
    // add to panels
    test.add(add_user);
    test.add(delete_user);
    test.add(logout);
    test.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); // spacing!
    users.add(userscroller);
    users.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 10)); // spacing!

    total.add(users); // everything is contained in total
    total.add(test, BorderLayout.WEST);
    total.setBorder(BorderFactory.createRaisedSoftBevelBorder()); // nice border
    total.setBorder(BorderFactory.createTitledBorder("Welcome Admin"));
    add(total);
  }
  /**
   * Initializes the window and its components.
   *
   * @param the_controls the controls for which the GUI components will represent.
   */
  private void init(final List<Controls> the_controls) {
    setFocusable(true);
    addFocusListener(
        new FocusAdapter() {
          /**
           * Called upon when the window gains focus. Sets the instructions text.
           *
           * @param the_event not used.
           */
          @Override
          public void focusGained(final FocusEvent the_event) {
            my_instructions_label.setText(OPENING_INSTRUCTIONS);
          }
        });

    final Box box = Box.createVerticalBox();
    my_instructions_label.setAlignmentX(Component.CENTER_ALIGNMENT);
    box.add(Box.createRigidArea(new Dimension(0, MARGINS)));
    box.add(my_instructions_label);

    box.add(Box.createRigidArea(new Dimension(0, PADDING)));
    final JPanel player_panel = new JPanel(new GridLayout(1, the_controls.size()));
    for (int i = 0; i < the_controls.size(); i++) {
      final JLabel label = new JLabel("Player " + (i + 1));
      label.setHorizontalAlignment(SwingConstants.CENTER);
      player_panel.add(label);
    }
    box.add(player_panel);

    box.add(Box.createRigidArea(new Dimension(0, PADDING)));
    final Box sub_box = Box.createHorizontalBox();
    sub_box.add(Box.createRigidArea(new Dimension(MARGINS, 0)));
    final GridLayout grid = new GridLayout(1, the_controls.size());
    grid.setHgap(HORIZONTAL_GAP);
    grid.setVgap(VERTICAL_GAP);
    final JPanel controls_panel = new JPanel(grid);
    for (int i = 0; i < the_controls.size(); i++) {
      controls_panel.add(new ControlSettingsPanel(the_controls.get(i)));
    }
    sub_box.add(controls_panel);
    sub_box.add(Box.createRigidArea(new Dimension(MARGINS, 0)));
    box.add(sub_box);

    box.add(Box.createRigidArea(new Dimension(0, PADDING)));
    final JButton button = new JButton("OK");
    button.setAlignmentX(Component.CENTER_ALIGNMENT);
    button.addActionListener(
        new ActionListener() {
          /**
           * Called when the user clicks on the button.
           *
           * @param the_event not used.
           */
          @Override
          public void actionPerformed(final ActionEvent the_event) {
            if (Controls.allValidControls()) {
              dispose();
            } else {
              my_instructions_label.setText(ERROR_2_INSTRUCTIONS);
            }
          }
        });
    box.add(button);
    box.add(Box.createRigidArea(new Dimension(0, MARGINS)));

    add(box);

    pack();
    setSize(getWidth() + MARGINS, getHeight() + MARGINS);
    setResizable(false);
    setLocationByPlatform(true);
    setVisible(true);
  }
  private void jbInit() throws Exception {
    border1 = BorderFactory.createRaisedBevelBorder();
    jPanel1.setLayout(gridLayout1);
    panel2.setBorder(border1);
    panel2.setMaximumSize(new Dimension(400, 200));
    panel2.setMinimumSize(new Dimension(400, 200));
    panel2.setLayout(gridBagLayout2);
    button1.setText("OK");
    button1.addActionListener(new insertMapDialog_button1_actionAdapter(this));
    button2.setText("Cancel");
    gridLayout1.setHgap(4);
    button2.addActionListener(new insertMapDialog_button2_actionAdapter(this));
    this.addWindowListener(new insertMapDialog_this_windowAdapter(this));
    InsertMapPanel.setLayout(gridBagLayout1);
    upperLeftLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    upperLeftLabel.setText("Upper-left Hex:");
    headerLabel.setText("Please enter the hex where the upper-left ");
    upperLeftTextField.setText("A1");
    jLabel1.setText("corner of the selected map will be placed:");
    InsertMapPanel.add(
        jPanel1,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(4, 8, 4, 8),
            0,
            0));
    jPanel1.add(button1, null);
    jPanel1.add(button2, null);
    InsertMapPanel.add(
        panel2,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 2),
            0,
            0));
    panel2.add(
        upperLeftLabel,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(20, 118, 4, 12),
            88,
            5));
    panel2.add(
        headerLabel,
        new GridBagConstraints(
            0,
            0,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHEAST,
            GridBagConstraints.NONE,
            new Insets(-7, 186, 0, 156),
            69,
            12));
    panel2.add(
        upperLeftTextField,
        new GridBagConstraints(
            1,
            2,
            1,
            2,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(17, 0, 0, 0),
            65,
            0));
    panel2.add(
        jLabel1,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 16, 0, 0),
            225,
            0));
    getContentPane().add(InsertMapPanel);

    panel2.setPreferredSize(new Dimension(400, 200));
    this.validate();
  }
示例#23
0
  public FenetreAdministration(
      ListeUtilisateursImpl userlist, Utilisateur userConnected, File fileSave) {
    super("Application");

    this.userlist = userlist;
    this.userConnected = userConnected;
    this.fileSave = fileSave;

    JPanel main = new JPanel();
    main.setLayout(new BorderLayout());

    JMenuBar menubar = new JMenuBar();

    JMenu file = new JMenu("Fichier");
    JMenu gestion = new JMenu("Gestion");

    ajouter = new JMenuItem("Ajouter");
    supprimer = new JMenuItem("Supprimer");
    listeUtilisateurP3 = new JMenuItem("Lister les utilisateurs dans P3");
    listeUtilisateurP4 = new JMenuItem("Lister les utilisateurs dans P4");

    propos = new JMenuItem("A propos");
    quitter = new JMenuItem("Quitter");

    file.setMnemonic(KeyEvent.VK_F);
    gestion.setMnemonic(KeyEvent.VK_G);

    menubar.add(file);
    menubar.add(gestion);

    gestion.add(ajouter);
    gestion.add(supprimer);
    gestion.add(listeUtilisateurP3);
    gestion.add(listeUtilisateurP4);
    file.add(propos);
    file.add(quitter);

    setJMenuBar(menubar);

    GridLayout mainGrid = new GridLayout(2, 3);
    mainGrid.setHgap(15); // 5 pixels d'espace entre les colonnes (H comme Horizontal)
    mainGrid.setVgap(15); //
    main.setLayout(mainGrid);

    P1 = new PanelAjouter();
    P2 = new PanelSupprimer();
    P3 = new PanelListeUtilisateur();
    P4 = new PanelListeUtilisateur();
    JPanel P5 = new JPanel();
    JPanel P6 = new JPanel();

    P1.setLayout(new BorderLayout());
    P2.setLayout(new BorderLayout());
    P3.setLayout(new BorderLayout());
    P4.setLayout(new BorderLayout());
    P5.setLayout(new BorderLayout());
    P6.setLayout(new BorderLayout());

    TitledBorder titleNorthBorder = new TitledBorder("P1");
    titleNorthBorder.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P1.setBorder(titleNorthBorder);

    P2.setBorder(BorderFactory.createLineBorder(Color.black));

    TitledBorder titleNorthBorder2 = new TitledBorder("P2");
    titleNorthBorder2.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P2.setBorder(titleNorthBorder2);

    TitledBorder titleNorthBorder3 = new TitledBorder("P3");
    titleNorthBorder3.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P3.setBorder(titleNorthBorder3);

    TitledBorder titleNorthBorder4 = new TitledBorder("P4");
    titleNorthBorder4.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P4.setBorder(titleNorthBorder4);

    TitledBorder titleNorthBorder5 = new TitledBorder("P5");
    titleNorthBorder5.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P5.setBorder(titleNorthBorder5);

    TitledBorder titleNorthBorder6 = new TitledBorder("P6");
    titleNorthBorder6.setTitleFont(new Font("Arial", Font.BOLD, 15));
    P6.setBorder(titleNorthBorder6);

    main.add(P1);
    main.add(P2);
    main.add(P3);
    main.add(P4);
    main.add(P5);
    main.add(P6);

    this.addWindowListener(new ListenerCloseWindow());
    ListenerAdministration buttonlistener = new ListenerAdministration(this);
    this.propos.addActionListener(buttonlistener);
    this.quitter.addActionListener(buttonlistener);
    this.ajouter.addActionListener(buttonlistener);
    this.supprimer.addActionListener(buttonlistener);

    this.listeUtilisateurP3.addActionListener(buttonlistener);
    this.listeUtilisateurP4.addActionListener(buttonlistener);

    this.setContentPane(main);
    this.setVisible(true);
    this.setSize(1200, 600);
  }
示例#24
0
  public ImportDialog(boolean targetIsARow, String fileName) {
    Boolean targetIsARow1 = targetIsARow;
    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    setContentPane(contentPane);
    JPanel panel3 = new JPanel();
    panel3.setBackground(new Color(-1643275));
    JLabel labelHeadline = new JLabel(Localization.lang("Import_Metadata_from:"));
    labelHeadline.setFont(new Font(labelHeadline.getFont().getName(), Font.BOLD, 14));
    JLabel labelSubHeadline =
        new JLabel(Localization.lang("Choose_the_source_for_the_metadata_import"));
    labelSubHeadline.setFont(
        new Font(labelSubHeadline.getFont().getName(), labelSubHeadline.getFont().getStyle(), 13));
    JLabel labelFileName = new JLabel();
    labelFileName.setFont(new Font(labelHeadline.getFont().getName(), Font.BOLD, 14));
    JPanel headLinePanel = new JPanel();
    headLinePanel.add(labelHeadline);
    headLinePanel.add(labelFileName);
    headLinePanel.setBackground(new Color(-1643275));
    GridLayout gl = new GridLayout(2, 1);
    gl.setVgap(10);
    gl.setHgap(10);
    panel3.setLayout(gl);
    panel3.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel3.add(headLinePanel);
    panel3.add(labelSubHeadline);
    radioButtonNoMeta = new JRadioButton(Localization.lang("Create_blank_entry_linking_the_PDF"));
    radioButtonXmp = new JRadioButton(Localization.lang("Create_entry_based_on_XMP_data"));
    radioButtonPDFcontent = new JRadioButton(Localization.lang("Create_entry_based_on_content"));
    radioButtononlyAttachPDF = new JRadioButton(Localization.lang("Only_attach_PDF"));
    JButton buttonOK = new JButton(Localization.lang("Ok"));
    JButton buttonCancel = new JButton(Localization.lang("Cancel"));
    checkBoxDoNotShowAgain =
        new JCheckBox(Localization.lang("Do not show this box again for this import"));
    useDefaultPDFImportStyle =
        new JCheckBox(
            Localization.lang("Always use this PDF import style (and do not ask for each import)"));
    DefaultFormBuilder b =
        new DefaultFormBuilder(new FormLayout("left:pref, 5dlu, left:pref:grow", ""));
    b.appendSeparator(Localization.lang("Create New Entry"));
    b.append(radioButtonNoMeta, 3);
    b.append(radioButtonXmp, 3);
    b.append(radioButtonPDFcontent, 3);
    b.appendSeparator(Localization.lang("Update_Existing_Entry"));
    b.append(radioButtononlyAttachPDF, 3);
    b.nextLine();
    b.append(checkBoxDoNotShowAgain);
    b.append(useDefaultPDFImportStyle);
    b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(buttonOK);
    bb.addButton(buttonCancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    contentPane.add(panel3, BorderLayout.NORTH);
    contentPane.add(b.getPanel(), BorderLayout.CENTER);
    contentPane.add(bb.getPanel(), BorderLayout.SOUTH);

    if (!targetIsARow1) {
      this.radioButtononlyAttachPDF.setEnabled(false);
    }
    String name = new File(fileName).getName();
    if (name.length() < 34) {
      labelFileName.setText(name);
    } else {
      labelFileName.setText(new File(fileName).getName().substring(0, 33) + "...");
    }
    this.setTitle(Localization.lang("Import_Metadata_From_PDF"));

    setModal(true);
    getRootPane().setDefaultButton(buttonOK);

    // only one of the radio buttons may be selected.
    ButtonGroup bg = new ButtonGroup();
    bg.add(radioButtonNoMeta);
    bg.add(radioButtonXmp);
    bg.add(radioButtonPDFcontent);
    bg.add(radioButtononlyAttachPDF);

    buttonOK.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            onOK();
          }
        });

    buttonCancel.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });

    contentPane.registerKeyboardAction(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    switch (Globals.prefs.getInt(ImportSettingsTab.PREF_IMPORT_DEFAULT_PDF_IMPORT_STYLE)) {
      case NOMETA:
        radioButtonNoMeta.setSelected(true);
        break;
      case XMP:
        radioButtonXmp.setSelected(true);
        break;
      case CONTENT:
        radioButtonPDFcontent.setSelected(true);
        break;
      case ONLYATTACH:
        radioButtononlyAttachPDF.setSelected(true);
        break;
      default:
        // fallback
        radioButtonPDFcontent.setSelected(true);
        break;
    }

    this.setSize(555, 371);
  }
示例#25
0
    public void actionPerformed(ActionEvent arg0) {
      try {
        JPanel test = new JPanel();
        test.setLayout(new BorderLayout());
        JPanel content = new JPanel();
        GridLayout layout = new GridLayout();
        layout.setColumns(2);
        layout.setHgap(5);
        layout.setVgap(5);

        // content.setLayout(new TableLayout(new
        // double[][]{{TableLayout.PREFERRED,5,TableLayout.PREFERRED},{TableLayout.PREFERRED,5,TableLayout.PREFERRED,5,TableLayout.PREFERRED, 5, TableLayout.PREFERRED}}));
        content.setLayout(layout);
        test.add(new JLabel(getString("enter_name")), BorderLayout.NORTH);
        test.add(content, BorderLayout.CENTER);
        User user = getUserModule().getUser();

        Allocatable person = user.getPerson();
        JTextField inputSurname = new JTextField();
        addCopyPaste(inputSurname);
        JTextField inputFirstname = new JTextField();
        addCopyPaste(inputFirstname);
        JTextField inputTitle = new JTextField();
        addCopyPaste(inputTitle);
        // Person connected?
        if (person != null) {
          Classification classification = person.getClassification();
          DynamicType type = classification.getType();
          Map<String, JTextField> map = new LinkedHashMap<String, JTextField>();
          map.put("title", inputTitle);
          map.put("firstname", inputFirstname);
          map.put("forename", inputFirstname);
          map.put("surname", inputSurname);
          map.put("lastname", inputSurname);
          int rows = 0;
          for (Map.Entry<String, JTextField> entry : map.entrySet()) {
            String fieldName = entry.getKey();
            Attribute attribute = type.getAttribute(fieldName);
            JTextField value = entry.getValue();
            if (attribute != null && !content.isAncestorOf(value)) {
              Locale locale = getLocale();
              content.add(new JLabel(attribute.getName(locale)));
              content.add(value);
              Object value2 = classification.getValue(attribute);
              rows++;
              if (value2 != null) {
                value.setText(value2.toString());
              }
            }
          }
          layout.setRows(rows);
        } else {
          content.add(new JLabel(getString("name")));
          content.add(inputSurname);
          inputSurname.setText(user.getName());
          layout.setRows(1);
        }
        DialogUI dlg =
            DialogUI.create(
                getContext(),
                getComponent(),
                true,
                test,
                new String[] {getString("save"), getString("abort")});
        dlg.start();
        if (dlg.getSelectedIndex() == 0) {
          String title = inputTitle.getText();
          String firstname = inputFirstname.getText();
          String surname = inputSurname.getText();
          getUserModule().changeName(title, firstname, surname);

          nameLabel.setText(user.getName());
        }
      } catch (RaplaException ex) {
        showException(ex, getMainComponent());
      }
    }
 public GraphPanel() {
   gridLayout.setHgap(2);
   gridLayout.setVgap(2);
   setLayout(gridLayout);
 }
示例#27
0
  /*
   * call in constructor only
   */
  private JPanel createTable() {

    JPanel outerPanel = new JPanel();
    outerPanel.setLayout(new BorderLayout());

    outerPanel.setOpaque(true);
    outerPanel.setBackground(Color.black);

    JLabel title = new JLabel("Geheugen");
    title.setOpaque(true);
    title.setForeground(Color.white);
    title.setBackground(Color.blue);
    title.setHorizontalAlignment(JLabel.CENTER);

    outerPanel.add(title, BorderLayout.NORTH);

    JPanel panel = new JPanel();
    GridLayout layout = new GridLayout(_realSize + 1, 3);
    layout.setHgap(3);
    layout.setVgap(3);
    panel.setLayout(layout);
    panel.setForeground(Color.white);
    panel.setBackground(Color.black);

    JLabel labelLabel = new JLabel("Label");
    JLabel addressLabel = new JLabel("Adres");
    JLabel contentLabel = new JLabel("Inhoud");
    labelLabel.setOpaque(true);
    labelLabel.setForeground(Color.white);
    labelLabel.setBackground(Color.blue);
    labelLabel.setHorizontalAlignment(JLabel.CENTER);
    addressLabel.setOpaque(true);
    addressLabel.setForeground(Color.white);
    addressLabel.setBackground(Color.blue);
    addressLabel.setHorizontalAlignment(JLabel.CENTER);
    contentLabel.setOpaque(true);
    contentLabel.setForeground(Color.white);
    contentLabel.setBackground(Color.blue);
    contentLabel.setHorizontalAlignment(JLabel.CENTER);
    panel.add(labelLabel);
    panel.add(addressLabel);
    panel.add(contentLabel);

    _labels = new JLabel[_realSize];
    _addresses = new JLabel[_realSize];
    _values = new JLabel[_realSize];

    for (int i = 0; i < _realSize; i++) {
      _labels[i] = new JLabel();
      _labels[i].setForeground(Color.white);
      _labels[i].setHorizontalAlignment(JLabel.CENTER);
      panel.add(_labels[i]);
      _addresses[i] = new JLabel("");
      // _addresses[i].setOpaque(true);
      // _addresses[i].setBackground(Color.gray);
      _addresses[i].setForeground(Color.white);
      _addresses[i].setHorizontalAlignment(JLabel.CENTER);
      panel.add(_addresses[i]);
      _values[i] = new JLabel("");
      _values[i].setOpaque(true);
      _values[i].setBackground(Color.gray);
      _values[i].setForeground(Color.white);
      _values[i].setHorizontalAlignment(JLabel.CENTER);
      panel.add(_values[i]);
    }

    outerPanel.add(panel, BorderLayout.CENTER);

    return outerPanel;
  }
示例#28
0
  public AddRaces(JFrame parentFrame, EditDatabase database)
      throws EmployeeDBException, SQLException {
    super(parentFrame);
    setTitle("Add Horse");
    List<Horse> horseName = database.getHorse();
    List<Rider> riderName = database.getRider();

    for (int i = 0; i < 24; i++) {
      strCombHour[i] = new Integer(i + 1).toString();
    }
    for (int i = 0; i < 60; i++) {
      strCombMinute[i] = new Integer(i + 1).toString();
    }

    for (int i = 0; i < 31; i++) {
      strCombDay[i] = new Integer(i + 1).toString();
    }
    for (int i = 0; i < 12; i++) {
      strCombMon[i] = new Integer(i + 1).toString();
    }
    for (int i = 0; i < 50; i++) {
      strCombYear[i] = new Integer(i + 2000).toString();
    }

    final List<JComboBox> listComb = new ArrayList<>();
    final List<JComboBox> riderComb = new ArrayList<>();
    final List<JComboBox> posComb = new ArrayList<>();

    for (int i = 0; i < 7; i++) {
      String[] tmp = {"-", "1", "2", "3", "4", "5", "6", "7"};
      posComb.add(new JComboBox(tmp));
    }

    String[] horse = new String[horseName.size()];
    List<JLabel> labels = new ArrayList<>();
    for (int i = 0; i < 7; i++) {
      labels.add(new JLabel("Kůň:"));
    }

    for (int i = 0; i < 7; i++) {
      JComboBox tmp = new JComboBox<>();
      JComboBox rider = new JComboBox<>();
      for (Horse h : horseName) {
        tmp.addItem(h);
      }
      for (Rider r : riderName) {
        rider.addItem(r);
      }

      listComb.add(tmp);
      riderComb.add(rider);
    }

    lbFirst = new JLabel("Den");
    combList = new JComboBox<String>(strCombDay);

    JLabel lbMonth = new JLabel("Měsíc");
    combListM = new JComboBox<String>(strCombMon);

    JLabel lbYear = new JLabel("Rok");
    combListY = new JComboBox<String>(strCombYear);

    JLabel lbHour = new JLabel("Hodina");
    combListH = new JComboBox<String>(strCombHour);

    JLabel lbMinute = new JLabel("Minuta");
    combListMin = new JComboBox<String>(strCombMinute);

    JLabel lbName = new JLabel("Jméno dostihu: ");
    JLabel lbPlace = new JLabel("Místo dostihu: ");

    lbSecond = new JLabel("Jméno Koně");
    txtFirst = new JTextField();
    txtFirst.setColumns(10);
    txtSecond = new JTextField();
    txtSecond.setColumns(10);

    GroupLayout layout = new GroupLayout(inputPanel);
    inputPanel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(lbMinute)
                    .addComponent(lbHour)
                    .addComponent(lbFirst)
                    .addComponent(lbMonth)
                    .addComponent(lbYear)
                    .addComponent(lbName)
                    .addComponent(lbPlace))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(combListMin)
                    .addComponent(combListH)
                    .addComponent(combList)
                    .addComponent(combListM)
                    .addComponent(combListY)
                    .addComponent(txtFirst)
                    .addComponent(txtSecond))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(0))
                    .addComponent(labels.get(1))
                    .addComponent(labels.get(2))
                    .addComponent(labels.get(3))
                    .addComponent(labels.get(4))
                    .addComponent(labels.get(5))
                    .addComponent(labels.get(6)))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(listComb.get(0))
                    .addComponent(listComb.get(1))
                    .addComponent(listComb.get(2))
                    .addComponent(listComb.get(3))
                    .addComponent(listComb.get(4))
                    .addComponent(listComb.get(5))
                    .addComponent(listComb.get(6)))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(riderComb.get(0))
                    .addComponent(riderComb.get(1))
                    .addComponent(riderComb.get(2))
                    .addComponent(riderComb.get(3))
                    .addComponent(riderComb.get(4))
                    .addComponent(riderComb.get(5))
                    .addComponent(riderComb.get(6)))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(posComb.get(0))
                    .addComponent(posComb.get(1))
                    .addComponent(posComb.get(2))
                    .addComponent(posComb.get(3))
                    .addComponent(posComb.get(4))
                    .addComponent(posComb.get(5))
                    .addComponent(posComb.get(6))));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(0))
                    .addComponent(listComb.get(0))
                    .addComponent(riderComb.get(0))
                    .addComponent(posComb.get(0))
                    .addComponent(lbMinute)
                    .addComponent(combListMin))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(1))
                    .addComponent(listComb.get(1))
                    .addComponent(riderComb.get(1))
                    .addComponent(posComb.get(1))
                    .addComponent(lbHour)
                    .addComponent(
                        combListH,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(2))
                    .addComponent(listComb.get(2))
                    .addComponent(riderComb.get(2))
                    .addComponent(posComb.get(2))
                    .addComponent(lbFirst)
                    .addComponent(
                        combList,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(3))
                    .addComponent(riderComb.get(3))
                    .addComponent(listComb.get(3))
                    .addComponent(posComb.get(3))
                    .addComponent(lbMonth)
                    .addComponent(
                        combListM,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(4))
                    .addComponent(riderComb.get(4))
                    .addComponent(listComb.get(4))
                    .addComponent(posComb.get(4))
                    .addComponent(lbYear)
                    .addComponent(
                        combListY,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(5))
                    .addComponent(listComb.get(5))
                    .addComponent(riderComb.get(5))
                    .addComponent(posComb.get(5))
                    .addComponent(lbName)
                    .addComponent(
                        txtFirst,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE))
            .addGroup(
                layout
                    .createParallelGroup()
                    .addComponent(labels.get(6))
                    .addComponent(riderComb.get(6))
                    .addComponent(listComb.get(6))
                    .addComponent(posComb.get(6))
                    .addComponent(lbPlace)
                    .addComponent(
                        txtSecond,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)));

    inputPanel.add(combList);
    inputPanel.add(lbFirst);

    inputPanel.add(combListM);
    inputPanel.add(lbMonth);

    inputPanel.add(combListY);
    inputPanel.add(lbYear);

    inputPanel.add(combListH);
    inputPanel.add(lbHour);

    inputPanel.add(combListMin);
    inputPanel.add(lbMinute);

    inputPanel.add(lbName);
    inputPanel.add(txtFirst);
    inputPanel.add(lbPlace);
    inputPanel.add(txtSecond);

    GridLayout btnLayout = new GridLayout(1, 2);
    btnLayout.setHgap(5);
    btnLayout.setVgap(5);

    btnOk = new JButton("Ok");
    btnOk.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            myDate =
                new MyDate(
                    Integer.parseInt((String) combListY.getSelectedItem()),
                    Integer.parseInt((String) combListM.getSelectedItem()),
                    Integer.parseInt((String) combList.getSelectedItem()),
                    Integer.parseInt((String) combListH.getSelectedItem()),
                    Integer.parseInt((String) combListMin.getSelectedItem()));

            for (int i = 0; i < 7; i++) {
              resultHorse.add((Horse) listComb.get(i).getSelectedItem());
              resultRider.add((Rider) riderComb.get(i).getSelectedItem());
              resultPos.add((String) posComb.get(i).getSelectedItem());
            }

            try {
              result1 = txtFirst.getText();
              result2 = txtSecond.getText();
            } catch (Exception e1) {
              result2 = null;
              System.out.println(e1);
            }
            setVisible(false);
          }
        });

    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            result1 = null;
            result2 = null;
            setVisible(false);
          }
        });

    buttonPanel.setLayout(btnLayout);
    buttonPanel.add(btnOk);
    buttonPanel.add(btnCancel);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(inputPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    pack();
  }
示例#29
0
  private void initGUI() {
    this.createCombos();
    try {
      {
        jPanel1 = new JPanel();
        final GridLayout jPanel1Layout = new GridLayout(2, 1);
        jPanel1Layout.setHgap(5);
        jPanel1Layout.setVgap(5);
        jPanel1Layout.setColumns(1);
        jPanel1Layout.setRows(2);
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.setLayout(jPanel1Layout);
        {
          attackpanel = new JPanel();
          final AnchorLayout attackpanelLayout = new AnchorLayout();
          attackpanel.setLayout(attackpanelLayout);
          jPanel1.add(attackpanel);
          attackpanel.setPreferredSize(new java.awt.Dimension(291, 65));
          attackpanel.setMaximumSize(new java.awt.Dimension(400, 150));
          attackpanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));
          {
            attackpanel.add(
                icbminfoLabel,
                new AnchorConstraint(
                    707,
                    417,
                    863,
                    27,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            icbminfoLabel.setPreferredSize(new java.awt.Dimension(150, 20));
          }
          {
            attackpanel.add(
                missileinfoLabel,
                new AnchorConstraint(
                    550,
                    417,
                    707,
                    27,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            missileinfoLabel.setPreferredSize(new java.awt.Dimension(150, 20));
          }
          {
            attackpanel.add(
                cannoninfoLabel,
                new AnchorConstraint(
                    394,
                    417,
                    550,
                    27,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            cannoninfoLabel.setPreferredSize(new java.awt.Dimension(150, 20));
          }
          {
            attackpanel.add(
                soldiersinfoLabel,
                new AnchorConstraint(
                    238,
                    417,
                    394,
                    27,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            soldiersinfoLabel.setPreferredSize(new java.awt.Dimension(150, 20));
          }
          {
            attackpanel.add(
                infoLabel,
                new AnchorConstraint(
                    82,
                    938,
                    238,
                    27,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));

            infoLabel.setPreferredSize(new java.awt.Dimension(350, 20));
          }
          {
            negotiateButton = new JButton();
            negotiateButton.setLayout(null);
            attackpanel.add(
                negotiateButton,
                new AnchorConstraint(
                    87,
                    11,
                    11,
                    173,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS));
            negotiateButton.setText("Rechazar ataque");
            negotiateButton.setToolTipText("Rechazar el ataque y negociar");
            negotiateButton.setPreferredSize(new java.awt.Dimension(200, 30));
            // +++++++++++++++++++++
            acceptButton.addMouseListener(new AcceptDialogMouseAdapter(this, false));
          }
          {
            acceptButton = new JButton();
            attackpanel.add(
                acceptButton,
                new AnchorConstraint(
                    46,
                    11,
                    52,
                    173,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS,
                    AnchorConstraint.ANCHOR_ABS));
            acceptButton.setText("Aceptar ataque");
            acceptButton.setToolTipText("Aceptar el ataque");
            acceptButton.setPreferredSize(new java.awt.Dimension(200, 30));
            // +++++++++++++++++++++++++++++++++++++++++++++++++++++
            acceptButton.addKeyListener(new AcceptDialogKeyAdapter(this));
            acceptButton.addMouseListener(new AcceptDialogMouseAdapter(this, true));
          }
        }
        {
          negotiatePanel = new JPanel();
          final AnchorLayout negotiatePanelLayout = new AnchorLayout();
          negotiatePanel.setLayout(negotiatePanelLayout);
          jPanel1.add(negotiatePanel);
          negotiatePanel.setPreferredSize(new java.awt.Dimension(258, 233));
          negotiatePanel.setEnabled(false);
          negotiatePanel.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false));
          {
            tattackedinfoPanel = new JPanel();
            negotiatePanel.add(
                tattackedinfoPanel,
                new AnchorConstraint(
                    535,
                    694,
                    957,
                    14,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            tattackedinfoPanel.setPreferredSize(new java.awt.Dimension(261, 54));
            tattackedinfoPanel.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
              tainfoLabel = new JLabel();
              tattackedinfoPanel.add(tainfoLabel);
              tainfoLabel.setText("Territorio atacado: ");
              tainfoLabel.setPreferredSize(new java.awt.Dimension(250, 20));
            }
            {
              tattackedinfoPanel.add(tattackedinfoLabel);
            }
          }
          {
            tattackedinfoLabel.setPreferredSize(new java.awt.Dimension(250, 20));
          }
          {
            acceptNegotiationButton = new JButton();
            negotiatePanel.add(
                acceptNegotiationButton,
                new AnchorConstraint(
                    675,
                    970,
                    910,
                    709,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            acceptNegotiationButton.setText("Negociar");

            acceptNegotiationButton.setPreferredSize(new java.awt.Dimension(100, 30));
            acceptNegotiationButton.setToolTipText("Rechazar el ataque y negociar");
            acceptNegotiationButton.addMouseListener(new NegotiateDialogMouseAdapter(this, false));
          }
          {
            soldiersLabel = new JLabel();
            negotiatePanel.add(
                soldiersLabel,
                new AnchorConstraint(
                    316,
                    748,
                    441,
                    32,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            soldiersLabel.setText("Indique la cantidad de soldados: ");
            soldiersLabel.setPreferredSize(new java.awt.Dimension(275, 16));
          }
          {
            moneyLabel = new JLabel();
            negotiatePanel.add(
                moneyLabel,
                new AnchorConstraint(
                    121,
                    751,
                    246,
                    32,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            moneyLabel.setText("Indique la cantidad de dinero: ");
            moneyLabel.setPreferredSize(new java.awt.Dimension(276, 16));
          }
          {
            final ComboBoxModel soldiersComboModel =
                new DefaultComboBoxModel(new String[] {"Item One", "Item Two"});
            soldiersCombo = new JComboBox();
            negotiatePanel.add(
                soldiersCombo,
                new AnchorConstraint(
                    300,
                    970,
                    480,
                    779,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            soldiersCombo.setModel(soldiersComboModel);
            soldiersCombo.setPreferredSize(new java.awt.Dimension(73, 23));
          }
          {
            final ComboBoxModel moneyComboModel =
                new DefaultComboBoxModel(new String[] {"Item One", "Item Two"});
            moneyCombo = new JComboBox();
            negotiatePanel.add(
                moneyCombo,
                new AnchorConstraint(
                    82,
                    970,
                    261,
                    782,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL,
                    AnchorConstraint.ANCHOR_REL));
            moneyCombo.setModel(moneyComboModel);
            moneyCombo.setPreferredSize(new java.awt.Dimension(72, 23));
          }
        }
      }
      this.setSize(400, 300);
    } catch (final Exception e) {
      e.printStackTrace();
    }
  }
示例#30
-1
  public KrustyView() {
    content = new JFrame();
    content.setLayout(new RiverLayout());
    JLabel searchTerm = new JLabel("Search: ");
    content.add(searchTerm);
    this.inputText = new JTextField("", 20);
    content.add("left", inputText);
    JLabel fromDateLabel = new JLabel("From date: ");
    content.add(fromDateLabel);
    this.fromDate = new JTextField("", 6);
    content.add(fromDate);

    JLabel toDateLabel = new JLabel("To date: ");
    content.add(toDateLabel);
    this.toDate = new JTextField("", 6);
    content.add(toDate);

    for (String s : searchDescription) {
      searchCombo.addItem(s);
    }
    content.add("tab", searchCombo);
    this.searchButton = new JButton("Search");
    content.add("tab", searchButton);

    GridLayout outputLayout = new GridLayout(0, 2);
    outputLayout.setHgap(10);
    JPanel outputPanel = new JPanel(outputLayout);
    content.add("p hfill vfill", outputPanel);

    searchOutput = new JTextArea();
    searchOutput.setEditable(false);
    TitledBorder searchTitle;
    searchTitle = BorderFactory.createTitledBorder("Search results");
    searchTitle.setTitleJustification(TitledBorder.RIGHT);
    searchOutput.setBorder(searchTitle);
    searchOutput.setLineWrap(true);
    outputPanel.add(new JScrollPane(searchOutput));
    productionOutput = new JTextArea();
    productionOutput.setEditable(false);
    TitledBorder productionTitle;
    productionTitle = BorderFactory.createTitledBorder("Production status");
    productionTitle.setTitleJustification(TitledBorder.RIGHT);
    productionOutput.setBorder(productionTitle);
    productionOutput.setLineWrap(true);
    outputPanel.add(new JScrollPane(productionOutput));

    this.blockedTrue = new JButton("Blocked");
    content.add("p", blockedTrue);
    this.blockedFalse = new JButton("Not blocked");
    content.add("", blockedFalse);

    content.setSize(1024, 768);
    content.setTitle("Krusty Kookies");
    content.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    content.setVisible(true);
    content.setResizable(false);
  }