private void initComponents() {

    panel = new JPanel();
    panel.setBorder(new TitledBorder("Search users"));
    panel.setBounds(10, 10, 360, 170);
    panel.setLayout(null);

    jMessage = new javax.swing.JLabel();
    jMessage.setFont(new java.awt.Font("Comic Sans MS", 0, 16)); // NOI18N
    this.add(jMessage);
    jMessage.setBounds(40, 90, 150, 30);
    jMessage.setText("");

    backButton = new javax.swing.JButton();
    backButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13)); // NOI18N
    backButton.setText("Back");
    panel.add(backButton);
    backButton.setBounds(270, 120, 80, 30); // 310 300 80 30
    backButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            backButtonActionPerformed(evt);
          }
        });

    searchCheckBox = new JCheckBox("Use regular expressions");
    panel.add(searchCheckBox);
    searchCheckBox.setBounds(30, 60, 250, 30);
    searchCheckBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            searchCheckBoxPerformed(e);
          }
        });

    okButton = new JButton();
    okButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    okButton.setText("OK");
    panel.add(okButton);
    okButton.setBounds(140, 120, 80, 30);
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            okButtonActionPerfomed(e);
          }
        });

    // TextFields
    tfsearch = new JTextField();
    tfsearch.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    panel.add(tfsearch);
    tfsearch.setBounds(30, 30, 300, 30);

    add(panel);
  }
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmSignIn = new JFrame("Login");
    frmSignIn.setTitle("Sign in");
    frmSignIn.setResizable(false);
    frmSignIn.setBounds(100, 100, 450, 357);
    frmSignIn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmSignIn.setLocationRelativeTo(null);

    JLabel lblEmail = new JLabel("Email:");
    lblEmail.setBounds(73, 108, 56, 18);

    JLabel lblPassword = new JLabel("Password:"******"Show Password");
    chckbxShowPassword.setBounds(130, 176, 128, 23);
    frmSignIn.getContentPane().add(chckbxShowPassword);

    chckbxShowPassword.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              passwordField.setEchoChar((char) 0);
            } else {
              passwordField.setEchoChar(a);
            }
          }
        });

    JButton btnNewButton = new JButton("Sign in");
    btnNewButton.setBounds(325, 106, 72, 62);
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            username = textField.getText();
            String password = String.valueOf(passwordField.getPassword()); // getText()
            // is
            // deprecated;
            // changed
            // to
            // getPassword()
            // password.toLowerCase();  Do we want case sensitive email?
            /*
             * SHA implementation to validate password
             */

            VaultController v = new VaultController();
            int result = 0;
            try {
              result = v.loginCheck(username, password);
            } catch (NoSuchAlgorithmException e1) {

              e1.printStackTrace();
            }
            if (result == 1) {
              failedattempt = 0;
              frmSignIn.dispose();

            } else {
              txtWarning.setText("The Email and/or Password is incorrect. Please try again.");
              failedattempt++;
            }
            // TODO migrate failcheck to Vault controller!
            if (failedattempt > 1 && failedattempt < 5) {
              try {
                VaultController.Send(
                    "sentineldatavault",
                    "SENTINELDATA",
                    username,
                    "Security Warning",
                    "Dear user,\n\nYou have multiple failed login attempts for your account.\n"
                        + "If it is not you, please change your password immediately.\n\n"
                        + "Sincerely,\nSentinel Data Vault Team");
              } catch (AddressException e1) {
                e1.printStackTrace();
              } catch (MessagingException e1) {
                e1.printStackTrace();
              }
            } else if (failedattempt == 5) {
              DatabaseManager d = new DatabaseManager("vault_database");
              User u = d.retrieveUserFromDatabase(username);
              d.deleteAllEntriesFromDatabase(u);
              d.deleteUserFromDatabase(u);
              try {
                JOptionPane.showMessageDialog(
                    null,
                    "Your account data has been deleted due to multiple failed login attempts");
                VaultController.Send(
                    "sentineldatavault",
                    "SENTINELDATA",
                    username,
                    "Security Warning",
                    "Dear user,\n\nWe have deleted your account.\n"
                        + "Have a nice day.\n\n"
                        + "Sincerely,\nSentinel Data Vault Team");
              } catch (AddressException e1) {
                e1.printStackTrace();
              } catch (MessagingException e1) {
                e1.printStackTrace();
              }
            }
          }
        });
    frmSignIn.getContentPane().setLayout(null);

    btnSignUp = new JButton("Create new account");
    btnSignUp.setToolTipText("Click here to create a new Sentinel Data Vault account!");
    btnSignUp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SignupView signup = new SignupView();
            signup.setVisible(true);
          }
        });
    btnSignUp.setBounds(57, 264, 158, 27);
    frmSignIn.getContentPane().add(btnSignUp);
    frmSignIn.getContentPane().add(btnNewButton);
    frmSignIn.getContentPane().add(lblPassword);
    frmSignIn.getContentPane().add(lblEmail);
    frmSignIn.getContentPane().add(textField);
    frmSignIn.getContentPane().add(passwordField);

    btnForgotPassword = new JButton("I forgot my password");
    btnForgotPassword.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frmSignIn.setVisible(false);
            PasswordRecoveryView p = new PasswordRecoveryView(frmSignIn);
          }
        });
    btnForgotPassword.setToolTipText("Click here to reset your account password");
    btnForgotPassword.setBounds(227, 264, 170, 27);
    frmSignIn.getContentPane().add(btnForgotPassword);

    lblSentinelDataVault = new JLabel("Sentinel Data Vault");
    lblSentinelDataVault.setFont(new Font("Dialog", Font.PLAIN, 22));
    lblSentinelDataVault.setBounds(119, 33, 206, 27);
    frmSignIn.getContentPane().add(lblSentinelDataVault);

    txtWarning = new JTextField();
    txtWarning.setForeground(new Color(220, 20, 60));
    txtWarning.setBorder(null);
    txtWarning.setOpaque(false);
    txtWarning.setFocusable(false);
    txtWarning.setEditable(false);
    txtWarning.setFont(new Font("Tahoma", Font.ITALIC, 12));
    txtWarning.setBackground(SystemColor.window);
    txtWarning.setBounds(57, 196, 340, 26);
    frmSignIn.getContentPane().add(txtWarning);
    txtWarning.setColumns(10);

    frmSignIn
        .getContentPane()
        .setFocusTraversalPolicy(
            new FocusTraversalOnArray(new Component[] {textField, passwordField, btnNewButton}));
    frmSignIn.setFocusTraversalPolicy(
        new FocusTraversalOnArray(new Component[] {textField, passwordField, btnNewButton}));
  }
示例#3
0
  @SuppressWarnings("deprecation")
  NPCPane(SpritesNPCManager mgr, int NPCIndex) {
    myIndex = NPCIndex;
    setBorder(new TitledBorder(null, "NPC", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    lblSpriteSet = new JLabel("Spriteset:");
    add(lblSpriteSet);
    lblSpriteSet.setBounds(10, 38, lblSpriteSet.getText().length() * 8, 16);
    Rectangle r = lblSpriteSet.getBounds();
    txtSpriteSet = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1));
    txtSpriteSet.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            Save(MapIO.loadedMap.mapNPCManager);
          }
        });
    add(txtSpriteSet);
    txtSpriteSet.setBounds(90, 38, 87, 16);
    // txtSpriteSet.disable();

    lblBehavior1 = new JLabel("Behavior1:");
    add(lblBehavior1);
    lblBehavior1.setBounds(10, 54, lblBehavior1.getText().length() * 8, 16);
    r = lblBehavior1.getBounds();
    txtBehavior1 = new JTextField();
    txtBehavior1.setColumns(2);
    add(txtBehavior1);
    txtBehavior1.setBounds(90, 54, 32, 16);

    lblBehavior2 = new JLabel("Behavior2:");
    add(lblBehavior2);
    lblBehavior2.setBounds(10, 70, lblBehavior2.getText().length() * 8, 16);
    r = lblBehavior2.getBounds();
    txtBehavior2 = new JTextField();
    txtBehavior2.setColumns(2);
    add(txtBehavior2);
    txtBehavior2.setBounds(90, 70, 64, 16);

    lblIsTrainer = new JLabel("Is a Trainer:");
    add(lblIsTrainer);
    lblIsTrainer.setBounds(10, 86, lblIsTrainer.getText().length() * 8, 16);
    r = lblIsTrainer.getBounds();
    chkIsTrainer = new JCheckBox();
    add(chkIsTrainer);
    chkIsTrainer.setBounds(114, 86, 32, 16);

    lblTrainerLOS = new JLabel("TrainerLOS:");
    add(lblTrainerLOS);
    lblTrainerLOS.setBounds(10, 102, lblTrainerLOS.getText().length() * 8, 16);
    r = lblTrainerLOS.getBounds();
    txtTrainerLOS = new JTextField();
    txtTrainerLOS.setColumns(3);
    add(txtTrainerLOS);
    txtTrainerLOS.setBounds(90, 102, 32, 16);

    lbliFlag = new JLabel("NPC Flag:");
    add(lbliFlag);
    lbliFlag.setBounds(10, 128, 88, 16);

    txtiFlag = new JTextField();
    txtiFlag.setColumns(4);
    add(txtiFlag);
    txtiFlag.setText("0");
    txtiFlag.setBounds(90, 128, 32, 16);

    lblScript = new JLabel("NPC Script Pointer:");
    add(lblScript);
    lblScript.setBounds(10, 150, 88, 16);

    txtScript = new JTextField();
    txtScript.setColumns(9);
    add(txtScript);
    txtScript.setText("0");
    txtScript.setBounds(90, 150, 32, 16);

    JButton btnSave = new JButton("Save");
    btnSave.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent arg0) {
            Save(MapIO.loadedMap.mapNPCManager);
          }
        });
    add(btnSave);
    btnSave.setBounds(55, 163, 89, 23);
    Load(mgr, NPCIndex);
  }
  private void InitUI() {
    System.out.println("Create new Opportunity");

    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    add(Box.createRigidArea(new Dimension(0, 35)));

    eventTsText = new JTextField("2011-07-11 11:00:00.000 +0:00");
    eventTsLabel = new JLabel();

    try {
      ownerId =
          new JComboBox(
              tools.readLines("D:\\DataGenerator\\DataGenerator\\resources\\employees.txt"));
      ownerId.setSelectedIndex(-1);
    } catch (IOException e) {
      e.printStackTrace();
    }

    ownerIdLabel = new JLabel();

    try {
      accountId =
          new JComboBox(
              tools.readLines("D:\\DataGenerator\\DataGenerator\\resources\\accounts.txt"));
      accountId.setSelectedIndex(-1);
    } catch (IOException e) {
      e.printStackTrace();
    }
    accountIdLabel = new JLabel();

    try {
      leadSource =
          new JComboBox(
              tools.readLines("D:\\DataGenerator\\DataGenerator\\resources\\leadSources.txt"));
      leadSource.setSelectedIndex(-1);
    } catch (IOException e) {
      e.printStackTrace();
    }
    leadSourceLabel = new JLabel();

    ECDText = new JTextField("2011-07-11");
    ECDLabel = new JLabel();

    amountText = new JTextField("1000");
    amountLabel = new JLabel();

    nameText = new JTextField("");
    nameLabel = new JLabel();

    descriptionText = new JTextField("");
    descriptionLabel = new JLabel();

    stageNameText = new JTextField("");
    stageNameLabel = new JLabel();

    stageDescrText = new JTextField("");
    stageDescrLabel = new JLabel();

    statusText = new JTextField("");
    statusLabel = new JLabel();

    resultText = new JTextField("");
    resultLabel = new JLabel();

    isClosed = new JCheckBox("IsClosed");
    isWon = new JCheckBox("IsWon");

    createButton = new JButton("Create");
    cleanFormButton = new JButton("Clean Form");
    generateSQLButton = new JButton("Generate SQL");

    ownerId.setBounds(210, 20, 190, 30);
    ownerIdLabel.setBounds(30, 20, 150, 30);
    ownerIdLabel.setText("Owner ID");

    accountId.setBounds(210, 50, 190, 30);
    accountIdLabel.setBounds(30, 50, 150, 30);
    accountIdLabel.setText("Account ID");

    leadSource.setBounds(210, 80, 190, 30);
    leadSourceLabel.setBounds(30, 80, 150, 30);
    leadSourceLabel.setText("Lead Source");

    eventTsText.setBounds(210, 110, 190, 30);
    eventTsLabel.setBounds(30, 110, 150, 30);
    eventTsLabel.setText("Event TS");

    ECDText.setBounds(210, 140, 190, 30);
    ECDLabel.setBounds(30, 140, 150, 30);
    ECDLabel.setText("Expected Close Date");

    amountText.setBounds(210, 170, 150, 30);
    amountLabel.setBounds(30, 170, 80, 30);
    amountLabel.setText("Amount");

    nameText.setBounds(210, 200, 150, 30);
    nameLabel.setBounds(30, 200, 80, 30);
    nameLabel.setText("Name");

    descriptionText.setBounds(210, 230, 150, 30);
    descriptionLabel.setBounds(30, 230, 80, 30);
    descriptionLabel.setText("Description");

    stageNameText.setBounds(210, 260, 150, 30);
    stageNameLabel.setBounds(30, 260, 80, 30);
    stageNameLabel.setText("Stage Name");

    stageDescrText.setBounds(210, 290, 150, 30);
    stageDescrLabel.setBounds(30, 290, 80, 30);
    stageDescrLabel.setText("Stage Description");

    statusText.setBounds(210, 320, 150, 30);
    statusLabel.setBounds(30, 320, 80, 30);
    statusLabel.setText("Status");

    resultText.setBounds(210, 350, 150, 30);
    resultLabel.setBounds(30, 350, 80, 30);
    resultLabel.setText("Result");

    isClosed.setBounds(30, 380, 90, 30);
    isWon.setBounds(210, 380, 90, 30);

    createButton.setBounds(20, 420, 90, 30);
    cleanFormButton.setBounds(125, 420, 120, 30);
    generateSQLButton.setBounds(260, 420, 120, 30);

    setLayout(null);

    add(ownerId);
    add(ownerIdLabel);

    add(accountId);
    add(accountIdLabel);

    add(leadSource);
    add(leadSourceLabel);

    add(eventTsLabel);
    add(eventTsText);

    add(ECDText);
    add(ECDLabel);

    add(amountText);
    add(amountLabel);

    add(nameText);
    add(nameLabel);

    add(descriptionText);
    add(descriptionLabel);

    add(stageNameText);
    add(stageNameLabel);

    add(stageDescrText);
    add(stageDescrLabel);

    add(statusText);
    add(statusLabel);

    add(resultText);
    add(resultLabel);

    add(isClosed);
    add(isWon);

    add(createButton);
    add(cleanFormButton);
    add(generateSQLButton);

    setSize(420, 510);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);
  }
示例#5
0
  public void initComponents() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 902, 597);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    panel_4 = new JPanel();
    panel_4.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Geral",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            null,
            null));
    panel_4.setBounds(10, 11, 426, 236);
    contentPane.add(panel_4);
    panel_4.setLayout(null);

    lblModeloDoAutomato = new JLabel("Defini\u00E7\u00E3o do Automato:");
    lblModeloDoAutomato.setBounds(10, 47, 125, 14);
    panel_4.add(lblModeloDoAutomato);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane_2.setBounds(10, 72, 406, 124);
    panel_4.add(scrollPane_2);

    textArea = new JTextArea();
    textArea.setColumns(100);
    scrollPane_2.setColumnHeaderView(textArea);
    textArea.setAutoscrolls(true);
    textArea.setRows(9);

    JButton btnMinimizar = new JButton("Minimizar");
    btnMinimizar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            minimizarAutomato();
          }
        });
    btnMinimizar.setBounds(10, 207, 104, 23);
    panel_4.add(btnMinimizar);

    JPanel panel = new JPanel();
    panel.setBounds(10, 15, 250, 25);
    panel_4.add(panel);
    panel.setBorder(null);
    panel.setLayout(null);

    JLabel lblNome = new JLabel("Criar estado:");
    lblNome.setBounds(10, 5, 82, 14);
    panel.add(lblNome);
    lblNome.setHorizontalAlignment(SwingConstants.CENTER);

    isfinal = new JCheckBox("Final");
    isfinal.setBounds(98, 1, 56, 23);
    panel.add(isfinal);

    btnNovo = new JButton("Novo");
    btnNovo.setBounds(160, 1, 73, 23);
    panel.add(btnNovo);
    btnNovo.addActionListener(
        new ActionListener() {

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

    JPanel panel_5 = new JPanel();
    panel_5.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Visualiza\u00E7\u00E3o",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_5.setBounds(10, 258, 1310, 390);
    contentPane.add(panel_5);
    panel_5.setLayout(null);

    painelView = new JPanelVisualizacao(this);
    painelView.setBounds(10, 22, 1290, 357);
    panel_5.add(painelView);

    JPanel panel_2 = new JPanel();
    panel_2.setBounds(558, 11, 314, 251);
    contentPane.add(panel_2);
    panel_2.setLayout(null);

    lblNewLabel = new JLabel("Detalhes de ");
    lblNewLabel.setBounds(10, 11, 152, 14);
    panel_2.add(lblNewLabel);

    cbisFinal = new JCheckBox("Final");
    cbisFinal.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            turnFinal();
          }
        });
    cbisFinal.setBounds(168, 7, 60, 23);
    panel_2.add(cbisFinal);

    btnExcluir = new JButton("Excluir");
    btnExcluir.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            excluirEstado();
          }
        });
    btnExcluir.setBounds(231, 7, 73, 23);
    panel_2.add(btnExcluir);

    panel_3 = new JPanel();
    panel_3.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Transi\u00E7\u00F5es",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_3.setBounds(10, 36, 294, 204);
    panel_2.add(panel_3);
    panel_3.setLayout(null);

    JLabel lblSimbolo = new JLabel("Simbolo:");
    lblSimbolo.setBounds(10, 29, 96, 14);
    panel_3.add(lblSimbolo);

    cbAlfabeto = new JComboBox();
    cbAlfabeto.setBounds(122, 26, 49, 20);
    panel_3.add(cbAlfabeto);

    JLabel lblEstadosDestinos = new JLabel("Estados Destinos:");
    lblEstadosDestinos.setBounds(10, 57, 96, 14);
    panel_3.add(lblEstadosDestinos);

    cbEstadosDestinos = new JComboBox();
    cbEstadosDestinos.setBounds(122, 54, 49, 20);
    panel_3.add(cbEstadosDestinos);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 82, 274, 111);
    panel_3.add(scrollPane_1);

    tblTrans = new JTable();
    scrollPane_1.setViewportView(tblTrans);

    btnNova = new JButton("Nova");
    btnNova.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novaTransicao();
          }
        });
    btnNova.setBounds(181, 25, 89, 23);
    panel_3.add(btnNova);

    btnRemover = new JButton("Remover");
    btnRemover.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removerTransicao();
          }
        });
    btnRemover.setBounds(181, 53, 89, 23);
    panel_3.add(btnRemover);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Estados",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_1.setBounds(446, 11, 102, 236);
    contentPane.add(panel_1);
    panel_1.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 26, 82, 199);
    panel_1.add(scrollPane);

    tblEstados = new JTable();
    scrollPane.setViewportView(tblEstados);
    tblEstados.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            selecionaEstadoAtual(a.getEstados().get(tblEstados.getSelectedRow()));
          }
        });
    tblEstados.setAutoscrolls(true);
    tblEstados.add(new Scrollbar());
  }
示例#6
0
  private void makeMenuScreen() {
    menu = new JPanel();
    menu.setBackground(Color.BLACK);
    menu.setLayout(null);
    menu.setBounds(0, 0, width, height);

    try {
      BufferedImage menuIMG =
          ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png"));
      // BufferedImage menuIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png"));
      menuIMGL =
          new JLabel(
              new ImageIcon(
                  menuIMG.getScaledInstance(
                      (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH)));
      menuIMGL.setBounds(0, 0, width, height);
    } catch (Exception e) {
    }

    highscoreL = new JLabel(String.valueOf(highscore));
    highscoreL.setBackground(Color.darkGray);
    highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100);
    highscoreL.setForeground(Color.white);

    easy = new JButton("Easy");
    hard = new JButton("Hard");

    easy.addActionListener(this);
    hard.addActionListener(this);

    easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20);
    hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20);

    onePlayerRB = new JRadioButton("One Player");
    twoPlayerRB = new JRadioButton("Two Player");
    mouseRB = new JRadioButton("Mouse (Player 1)");
    keyboardRB = new JRadioButton("Keyboard (Player 1)");
    keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    musicCB = new JCheckBox("Music");

    onePlayerRB.setBackground(null);
    twoPlayerRB.setBackground(null);
    mouseRB.setBackground(null);
    keyboardRB.setBackground(null);
    keyboardSpeedS1.setBackground(null);
    keyboardSpeedS2.setBackground(null);
    musicCB.setBackground(null);

    onePlayerRB.setForeground(Color.WHITE);
    twoPlayerRB.setForeground(Color.WHITE);
    mouseRB.setForeground(Color.WHITE);
    keyboardRB.setForeground(Color.WHITE);
    keyboardSpeedS1.setForeground(Color.WHITE);
    keyboardSpeedS2.setForeground(Color.WHITE);
    musicCB.setForeground(Color.WHITE);

    ButtonGroup playerChoice = new ButtonGroup();
    playerChoice.add(onePlayerRB);
    playerChoice.add(twoPlayerRB);
    onePlayerRB.setSelected(true);

    ButtonGroup peripheralChoice = new ButtonGroup();
    peripheralChoice.add(mouseRB);
    peripheralChoice.add(keyboardRB);
    mouseRB.setSelected(true);

    musicCB.setSelected(true);

    onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20);
    twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20);
    mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20);
    keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20);
    keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50);
    keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50);
    musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20);

    keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)");
    keyboardSpeedL1.setForeground(Color.WHITE);
    keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50);

    keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)");
    keyboardSpeedL2.setForeground(Color.WHITE);
    keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50);

    howTo = new JButton("How To Play");
    howTo.addActionListener(this);
    howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20);

    try {
      BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png"));
      // BufferedImage howToIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png"));
      howToIMGL = new JLabel(new ImageIcon(howToIMG));
      howToIMGL.setBounds(
          width / 2 - howToIMG.getWidth() / 2,
          height / 2 - howToIMG.getHeight() / 2,
          howToIMG.getWidth(),
          howToIMG.getHeight());
    } catch (Exception e) {
    }

    howToBack = new JButton("X");
    howToBack.setBounds(
        (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50);
    howToBack.setBackground(Color.BLACK);
    howToBack.setForeground(Color.WHITE);
    howToBack.addActionListener(this);

    menu.add(easy);
    menu.add(hard);
    menu.add(howTo);
    menu.add(highscoreL);
    menu.add(onePlayerRB);
    menu.add(twoPlayerRB);
    menu.add(mouseRB);
    menu.add(keyboardRB);
    menu.add(keyboardSpeedL1);
    menu.add(keyboardSpeedL2);
    menu.add(keyboardSpeedS1);
    menu.add(keyboardSpeedS2);
    menu.add(musicCB);
    menu.add(menuIMGL);

    back = new JButton("Back");
    back.setBounds(width / 2 - 40, height / 2, 100, 20);
    back.addActionListener(this);
    back.setVisible(false);
    this.add(back);
  }
示例#7
0
  void createFrame() {
    /* see Preferences.java */
    int GUI_BIG = 13;
    int GUI_BETWEEN = 10;
    int GUI_SMALL = 6;
    int FIELD_SIZE = 30;

    int left = GUI_BIG;
    int top = GUI_BIG;
    int right = 0;

    Dimension d;

    frame = new JFrame("Directives Editor");
    Container pane = frame.getContentPane();
    pane.setLayout(null);

    JLabel label = new JLabel("Click here to read about directives.");
    label.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            Base.openURL("http://processingjs.org/reference/pjs%20directive");
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}
        });
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN + GUI_BETWEEN;

    // CRISP

    crispBox = new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()");
    pane.add(crispBox);
    d = crispBox.getPreferredSize();
    crispBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // FONTS

    label = new JLabel("\"font\": to load (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    fontField = new JTextField(FIELD_SIZE);
    pane.add(fontField);
    d = fontField.getPreferredSize();
    fontField.setBounds(left, top, d.width, d.height);

    JButton button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanFonts();
          }
        });
    pane.add(button);
    Dimension d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // GLOBAL_KEY_EVENTS

    globalKeyEventsBox = new JCheckBox("\"globalKeyEvents\": receive global key events");
    pane.add(globalKeyEventsBox);
    d = globalKeyEventsBox.getPreferredSize();
    globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PAUSE_ON_BLUR

    pauseOnBlurBox = new JCheckBox("\"pauseOnBlur\": pause if applet loses focus");
    pane.add(pauseOnBlurBox);
    d = pauseOnBlurBox.getPreferredSize();
    pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PRELOAD images

    label = new JLabel("\"preload\": images (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    preloadField = new JTextField(FIELD_SIZE);
    pane.add(preloadField);
    d = preloadField.getPreferredSize();
    preloadField.setBounds(left, top, d.width, d.height);

    button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanImages();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // TRANSPARENT

    /*transparentBox =
         new JCheckBox("\"transparent\": set applet background to be transparent");
       pane.add(transparentBox);
    d = transparentBox.getPreferredSize();
       transparentBox.setBounds(left, top, d.width + 10, d.height);
       right = Math.max(right, left + d.width);
       top += d.height + GUI_BETWEEN;*/

    // APPLY / OK

    button = new JButton("OK");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyDirectives();
            hide();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    int BUTTON_HEIGHT = d2.height;
    int BUTTON_WIDTH = 80;

    int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton("Cancel");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hide();
          }
        });
    pane.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;

    // frame.getContentPane().add(box);
    frame.pack();
    Insets insets = frame.getInsets();
    frame.setSize(
        right + GUI_BIG + insets.left + insets.right, top + GUI_SMALL + insets.top + insets.bottom);

    // frame.setResizable(false);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            frame.setVisible(false);
          }
        });
    Toolkit.registerWindowCloseKeys(
        frame.getRootPane(),
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            frame.setVisible(false);
          }
        });
    Toolkit.setIcon(frame);
  }
示例#8
0
  editprof(String str, String user) {
    cp = getContentPane();
    cp.setLayout(null);
    user1 = user;
    try {

      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

    } catch (Exception e) {
    }

    JTextField ft = new JTextField();
    name1 = new JLabel("First Name");
    try {
      r = new FileReader(user + "/First name.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    name = new JTextField();
    name.setText(ft.getText());

    last1 = new JLabel("Enter Last Name");
    try {
      r = new FileReader(user + "/last name.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    last = new JTextField();
    last.setText(ft.getText());

    pass = new JLabel("Password");
    try {
      r = new FileReader(user + "/password.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    pwd = new JPasswordField();
    pwd.setText(ft.getText());
    pwd.setEditable(false);

    email1 = new JLabel("Enter email address");
    try {
      r = new FileReader(user + "/email.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    email = new JTextField();
    email.setText(ft.getText());

    addimage = new JButton("Add Image");
    icon = new JLabel();

    date1 = new JLabel("Date Of Birth");
    date = new JComboBox();
    for (int i = 1; i <= 31; i++) {
      date.addItem(i);
    }

    month = new JComboBox();
    month.addItem("Jan");
    month.addItem("Feb");
    month.addItem("Mar");
    month.addItem("Apr");
    month.addItem("May");
    month.addItem("Jun");
    month.addItem("Jul");
    month.addItem("Aug");
    month.addItem("Sep");
    month.addItem("Oct");
    month.addItem("Nov");
    month.addItem("Dec");

    year = new JComboBox();
    for (int j = 1900; j <= 2010; j++) {
      year.addItem(j);
    }

    sx = new JLabel("Gender");
    gen = new JComboBox();
    gen.addItem("Male");
    gen.addItem("Female");

    con1 = new JLabel("Country Name");
    con = new JComboBox();
    con.addItem(" Austrelia");
    con.addItem(" America");
    con.addItem(" Antartica");
    con.addItem(" Africa");
    con.addItem(" Canda");
    con.addItem(" Corea");
    con.addItem(" Chaina");
    con.addItem(" Denmark");
    con.addItem(" England");
    con.addItem(" Franc");
    con.addItem(" Hangery");
    con.addItem(" Holand");
    con.addItem(" Itali");
    con.addItem(" India");
    con.addItem(" Indonesia");
    con.addItem(" Jermany");
    con.addItem(" Japan");
    con.addItem(" Korea");
    con.addItem(" Kembridge");
    con.addItem(" Merusalem");
    con.addItem(" Noth America");
    con.addItem(" Norvey");
    con.addItem(" West Indies");
    con.addItem(" Peru");
    con.addItem(" Zimbawe");

    about = new JLabel("About me");
    try {
      r = new FileReader(user + "/about.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;

    main = new JTextArea();
    main.setText(ft.getText());

    JScrollPane jsp = new JScrollPane(main, v, h);

    allow = new JLabel("Allow To:");
    JCheckBox c1 = new JCheckBox(" orkut Friends");
    JCheckBox c2 = new JCheckBox("Collage Friends");
    JCheckBox c3 = new JCheckBox("Business Partner");
    JCheckBox c4 = new JCheckBox("Relatives");

    col = new JLabel("Collage Name:");
    try {
      r = new FileReader(user + "/Collage.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    col1 = new JTextField();
    col1.setText(ft.getText());
    try {
      r = new FileReader(user + "/UniverSity.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    uni = new JLabel("Univercity");
    uni1 = new JTextField();
    uni1.setText(ft.getText());

    state1 = new JLabel("State Name");
    try {
      r = new FileReader(user + "/state.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    state = new JTextField();
    state.setText(ft.getText());

    city = new JLabel("City");
    try {
      r = new FileReader(user + "/City.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    city1 = new JTextField();
    city1.setText(ft.getText());

    try {
      r = new FileReader(user + "/imagepath.txt");
      ft.read(r, null);
      r.close();
    } catch (Exception de) {
    }
    ImageIcon io = new ImageIcon(ft.getText());
    icon.setIcon(io);

    next = new JButton("Update");
    next.setBackground(Color.white);
    // adding to container

    name1.setBounds(10, 10, 130, 25);
    name.setBounds(150, 10, 130, 25);

    last1.setBounds(10, 40, 130, 25);
    last.setBounds(150, 40, 130, 25);

    email1.setBounds(10, 70, 130, 25);
    email.setBounds(150, 70, 130, 25);

    pass.setBounds(290, 70, 130, 25);
    pwd.setBounds(390, 70, 130, 25);

    addimage.setBounds(350, 440, 100, 25);
    icon.setBounds(490, 410, 100, 100);

    date1.setBounds(10, 100, 130, 25);
    date.setBounds(120, 100, 40, 25);
    month.setBounds(180, 100, 130, 25);
    year.setBounds(320, 100, 130, 25);

    sx.setBounds(10, 140, 130, 25);
    gen.setBounds(150, 140, 130, 25);

    about.setBounds(10, 180, 130, 25);
    jsp.setBounds(150, 180, 250, 80);

    allow.setBounds(10, 260, 130, 25);
    c1.setBounds(150, 260, 130, 25);
    c2.setBounds(290, 260, 130, 25);

    c3.setBounds(150, 290, 130, 25);
    c4.setBounds(290, 290, 130, 25);

    uni.setBounds(10, 330, 130, 25);
    uni1.setBounds(150, 330, 130, 25);
    col.setBounds(10, 360, 130, 25);
    col1.setBounds(150, 360, 130, 25);

    con1.setBounds(10, 390, 130, 25);
    con.setBounds(150, 390, 130, 25);

    state1.setBounds(10, 430, 130, 25);
    state.setBounds(150, 430, 130, 25);

    city.setBounds(10, 460, 130, 25);
    city1.setBounds(150, 460, 130, 25);

    next.setBounds(50, 490, 130, 25);

    cp.add(name);
    cp.add(name1);
    cp.add(last);
    cp.add(last1);
    cp.add(email);
    cp.add(email1);
    cp.add(addimage);
    cp.add(icon);
    cp.add(date1);
    cp.add(date);
    cp.add(month);
    cp.add(year);
    cp.add(about);
    cp.add(jsp);
    cp.add(sx);
    cp.add(gen);
    cp.add(allow);
    cp.add(c1);
    cp.add(c2);
    cp.add(c3);
    cp.add(c4);
    cp.add(next);
    cp.add(uni);
    cp.add(uni1);
    cp.add(col);
    cp.add(col1);
    cp.add(con);
    cp.add(con1);
    cp.add(state1);
    cp.add(state);
    cp.add(city);
    cp.add(city1);
    cp.add(next);
    cp.add(pwd);
    cp.add(pass);

    addimage.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            filepath = name.getText();
            JFileChooser chooser = new JFileChooser();

            while (true) {
              int val = chooser.showOpenDialog(editprof.this);
              File f = chooser.getSelectedFile();
              String path = f.getPath();
              String name = f.getName();

              try {

                if (val == JFileChooser.CANCEL_OPTION || val == -1) {
                  break;
                } else {
                  image = new ImageIcon(path);
                  icon.setIcon(image);
                  w = new FileWriter(filepath + "/" + "imagePath.txt");
                  w.write(path + "");
                  w.close();
                  break;
                }
              } catch (Exception se) {
              }
            }
          }
        });

    date.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int str = (Integer) e.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "date.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });

    month.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e1) {
            String str = (String) e1.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "month.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    con.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e2) {
            String str = (String) e2.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "contry.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    year.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e2) {
            int str = (Integer) e2.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "year.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });
    gen.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e3) {
            String str = (String) e3.getItem();
            File f = new File(name.getText());
            f.mkdir();
            try {
              w = new FileWriter(name.getText() + "/" + "gender.txt");
              w.write(str + "");
              w.close();
            } catch (IOException de) {
            }
          }
        });

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent se) {
            try {

              w = new FileWriter(name.getText() + "/" + "First name.txt");
              w.write(name.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "last name.txt");
              w.write(last.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "email.txt");
              w.write(email.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "Collage.txt");
              w.write(col1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "UniverSity.txt");
              w.write(uni1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "state.txt");
              w.write(state.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "City.txt");
              w.write(city1.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "about.txt");
              w.write(main.getText());
              w.close();

              w = new FileWriter(name.getText() + "/" + "password.txt");
              w.write(pwd.getText());
              w.close();

              profile e1 = new profile("My Profile", user1);
              e1.setVisible(true);
              e1.setLocation(00, 00);
              e1.setSize(800, 800);
              setVisible(false);
            } catch (Exception be) {
            }
          }
        });
  }
示例#9
0
  public Preferences() {

    // setup dialog for the prefs

    //dialog = new JDialog(editor, "Preferences", true);
    dialog = new JFrame(_("Preferences"));
    dialog.setResizable(false);

    Container pain = dialog.getContentPane();
    pain.setLayout(null);

    int top = GUI_BIG;
    int left = GUI_BIG;
    int right = 0;

    JLabel label;
    JButton button; //, button2;
    //JComboBox combo;
    Dimension d, d2; //, d3;
    int h, vmax;


    // Sketchbook location:
    // [...............................]  [ Browse ]

    label = new JLabel(_("Sketchbook location:"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height; // + GUI_SMALL;

    sketchbookLocationField = new JTextField(40);
    pain.add(sketchbookLocationField);
    d = sketchbookLocationField.getPreferredSize();

    button = new JButton(PROMPT_BROWSE);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          File dflt = new File(sketchbookLocationField.getText());
          File file =
            Base.selectFolder(_("Select new sketchbook location"), dflt, dialog);
          if (file != null) {
            sketchbookLocationField.setText(file.getAbsolutePath());
          }
        }
      });
    pain.add(button);
    d2 = button.getPreferredSize();

    // take max height of all components to vertically align em
    vmax = Math.max(d.height, d2.height);
    sketchbookLocationField.setBounds(left, top + (vmax-d.height)/2,
                                      d.width, d.height);
    h = left + d.width + GUI_SMALL;
    button.setBounds(h, top + (vmax-d2.height)/2,
                     d2.width, d2.height);

    right = Math.max(right, h + d2.width + GUI_BIG);
    top += vmax + GUI_BETWEEN;


    // Preferred language: [        ] (requires restart of Arduino)
    Container box = Box.createHorizontalBox();
    label = new JLabel(_("Editor language: "));
    box.add(label);
    comboLanguage = new JComboBox(languages);
    comboLanguage.setSelectedIndex((Arrays.asList(languagesISO)).indexOf(Preferences.get("editor.languages.current")));
    box.add(comboLanguage);
    label = new JLabel(_("  (requires restart of Arduino)"));
    box.add(label);
    pain.add(box);
    d = box.getPreferredSize();
    box.setForeground(Color.gray);
    box.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // Editor font size [    ]

    box = Box.createHorizontalBox();
    label = new JLabel(_("Editor font size: "));
    box.add(label);
    fontSizeField = new JTextField(4);
    box.add(fontSizeField);
    label = new JLabel(_("  (requires restart of Arduino)"));
    box.add(label);
    pain.add(box);
    d = box.getPreferredSize();
    box.setBounds(left, top, d.width, d.height);
    Font editorFont = Preferences.getFont("editor.font");
    fontSizeField.setText(String.valueOf(editorFont.getSize()));
    top += d.height + GUI_BETWEEN;


    // Show verbose output during: [ ] compilation [ ] upload

    box = Box.createHorizontalBox();
    label = new JLabel(_("Show verbose output during: "));
    box.add(label);
    verboseCompilationBox = new JCheckBox(_("compilation "));
    box.add(verboseCompilationBox);
    verboseUploadBox = new JCheckBox(_("upload"));
    box.add(verboseUploadBox);
    pain.add(box);
    d = box.getPreferredSize();
    box.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;

    // [ ] Verify code after upload

    verifyUploadBox = new JCheckBox(_("Verify code after upload"));
    pain.add(verifyUploadBox);
    d = verifyUploadBox.getPreferredSize();
    verifyUploadBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // [ ] Use external editor

    externalEditorBox = new JCheckBox(_("Use external editor"));
    pain.add(externalEditorBox);
    d = externalEditorBox.getPreferredSize();
    externalEditorBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;


    // [ ] Check for updates on startup

    checkUpdatesBox = new JCheckBox(_("Check for updates on startup"));
    pain.add(checkUpdatesBox);
    d = checkUpdatesBox.getPreferredSize();
    checkUpdatesBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // [ ] Update sketch files to new extension on save (.pde -> .ino)

    updateExtensionBox = new JCheckBox(_("Update sketch files to new extension on save (.pde -> .ino)"));
    pain.add(updateExtensionBox);
    d = updateExtensionBox.getPreferredSize();
    updateExtensionBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    domainPortField= new JTextField();
    domainPortField.setColumns(30);
    Box domainBox = Box.createHorizontalBox();
    domainBox.add(new JLabel("Tftp upload Domain:"));
    domainBox.add(domainPortField);
    pain.add(domainBox);
    d = domainBox.getPreferredSize();
    domainBox.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;

    autoResetPortField= new JTextField();
    autoResetPortField.setColumns(8);
    Box resetBox = Box.createHorizontalBox();
    resetBox.add(new JLabel("Auto Reset Port:"));
    resetBox.add(autoResetPortField);
    pain.add(resetBox);
    d = resetBox.getPreferredSize();
    resetBox.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;


    tftpPassField = new JTextField();
    tftpPassField.setColumns(30);
    Box tftpBox = Box.createHorizontalBox();
    tftpBox.add(new JLabel("Tftp Secret Password:"******"Automatically associate .ino files with Arduino"));
      pain.add(autoAssociateBox);
      d = autoAssociateBox.getPreferredSize();
      autoAssociateBox.setBounds(left, top, d.width + 10, d.height);
      right = Math.max(right, left + d.width);
      top += d.height + GUI_BETWEEN;
    }

    // More preferences are in the ...

    label = new JLabel(_("More preferences can be edited directly in the file"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setForeground(Color.gray);
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height; // + GUI_SMALL;

    label = new JLabel(preferencesFile.getAbsolutePath());
    final JLabel clickable = label;
    label.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
          Base.openFolder(Base.getSettingsFolder());
        }

        public void mouseEntered(MouseEvent e) {
          clickable.setForeground(new Color(0, 0, 140));
        }

        public void mouseExited(MouseEvent e) {
          clickable.setForeground(Color.BLACK);
        }
      });
    pain.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height;

    label = new JLabel(_("(edit only when Arduino is not running)"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setForeground(Color.gray);
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height; // + GUI_SMALL;


    // [  OK  ] [ Cancel ]  maybe these should be next to the message?

    button = new JButton(PROMPT_OK);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          applyFrame();
          disposeFrame();
        }
      });
    pain.add(button);
    d2 = button.getPreferredSize();
    BUTTON_HEIGHT = d2.height;

    h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton(PROMPT_CANCEL);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          disposeFrame();
        }
      });
    pain.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;


    // finish up

    wide = right + GUI_BIG;
    high = top + GUI_SMALL;


    // closing the window is same as hitting cancel button

    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          disposeFrame();
        }
      });

    ActionListener disposer = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
          disposeFrame();
        }
      };
    Base.registerWindowCloseKeys(dialog.getRootPane(), disposer);
    Base.setIcon(dialog);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    dialog.setLocation((screen.width - wide) / 2,
                      (screen.height - high) / 2);

    dialog.pack(); // get insets
    Insets insets = dialog.getInsets();
    dialog.setSize(wide + insets.left + insets.right,
                  high + insets.top + insets.bottom);


    // handle window closing commands for ctrl/cmd-W or hitting ESC.

    pain.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
          //System.out.println(e);
          KeyStroke wc = Editor.WINDOW_CLOSE_KEYSTROKE;
          if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
              (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
            disposeFrame();
          }
        }
      });
  }
示例#10
0
  /** Create the frame. */
  public GenXml() {
    setResizable(false);
    setTitle("XML生成向导");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 670, 500);
    contentPane = new JPanel();
    contentPane.setBorder(new LineBorder(Color.DARK_GRAY, 4));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(0, 0));

    btnpanel = new JPanel();
    btnpanel.setBackground(Color.DARK_GRAY);
    btnpanel.setBorder(new LineBorder(Color.DARK_GRAY));
    btnpanel.setPreferredSize(new Dimension(10, 60));
    contentPane.add(btnpanel, BorderLayout.SOUTH);
    btnpanel.setLayout(null);

    prevBtn = new JButton("上一步");
    prevBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            prev();
          }
        });
    prevBtn.setEnabled(false);
    prevBtn.setBounds(294, 10, 113, 40);
    btnpanel.add(prevBtn);

    nextBtn = new JButton("下一步");
    nextBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            next();
          }
        });
    nextBtn.setBounds(417, 10, 113, 40);
    btnpanel.add(nextBtn);

    doneBtn = new JButton("完成");
    doneBtn.addActionListener(doneListener);
    doneBtn.setEnabled(false);
    doneBtn.setBounds(540, 10, 113, 40);
    btnpanel.add(doneBtn);

    card = new CardLayout(0, 0);
    pane = new JPanel(card);
    contentPane.add(pane, BorderLayout.CENTER);

    step1 = new JPanel();
    step1.setBackground(Color.LIGHT_GRAY);
    step1.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step1, "name_287780550285180");
    step1.setLayout(null);

    JLabel label = new JLabel("请输入类名(全路径):");
    label.setFont(new Font("宋体", Font.PLAIN, 18));
    label.setBounds(10, 42, 344, 43);
    step1.add(label);

    classPath = new JTextField();
    classPath.setForeground(Color.BLACK);
    classPath.setBackground(Color.WHITE);
    classPath.setFont(new Font("宋体", Font.BOLD, 20));
    classPath.setBounds(10, 95, 636, 52);
    step1.add(classPath);
    classPath.setColumns(10);

    JLabel lblxml = new JLabel("保存xml路径(全路径):");
    lblxml.setFont(new Font("宋体", Font.PLAIN, 18));
    lblxml.setBounds(10, 218, 344, 43);
    step1.add(lblxml);

    filePath = new JTextField();
    // 默认使用当前路径
    String path = GenXml.class.getResource("/").getPath();
    if (path.startsWith("/")) {
      path = path.substring(1);
    }
    filePath.setText(path);
    filePath.setForeground(Color.BLACK);
    filePath.setFont(new Font("宋体", Font.BOLD, 20));
    filePath.setColumns(10);
    filePath.setBackground(Color.WHITE);
    filePath.setBounds(10, 271, 636, 52);
    step1.add(filePath);

    step2 = new JPanel();
    step2.setBackground(Color.LIGHT_GRAY);
    step2.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step2, "name_287788958231594");
    step2.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    step2.add(scrollPane);

    table = new JTable();
    table.setRowHeight(30);
    table.setAutoCreateRowSorter(true);
    table.setDragEnabled(true);
    table.setFont(new Font("宋体", Font.PLAIN, 18));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setForeground(Color.BLACK);
    table.setBackground(Color.WHITE);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {},
            new String[] {"\u5B57\u6BB5\u540D", "\u7C7B\u578B", "\u5217\u540D"}));
    table.getColumnModel().getColumn(0).setPreferredWidth(120);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(2).setPreferredWidth(120);
    scrollPane.setViewportView(table);

    panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(10, 40));
    step2.add(panel_1, BorderLayout.NORTH);
    panel_1.setLayout(null);

    label_1 = new JLabel("需要显示的属性:");
    label_1.setBounds(10, 10, 157, 22);
    panel_1.add(label_1);

    panel_2 = new JPanel();
    panel_2.setPreferredSize(new Dimension(100, 10));
    step2.add(panel_2, BorderLayout.EAST);
    panel_2.setLayout(null);

    reset = new JButton("重置");
    reset.setBounds(3, 0, 93, 25);
    panel_2.add(reset);

    mvT = new JButton("向上");
    mvT.setBounds(3, 30, 93, 25);
    panel_2.add(mvT);

    mvD = new JButton("向下");
    mvD.setBounds(3, 60, 93, 25);
    panel_2.add(mvD);

    delBtn = new JButton("删除");
    delBtn.setBounds(3, 90, 93, 25);
    panel_2.add(delBtn);
    delBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 删除选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row > -1) {
              tableModel.removeRow(row);
              if (row < table.getRowCount()) {
                table.getSelectionModel().setSelectionInterval(row, row);
              } else if (row > 1) {
                table.getSelectionModel().setSelectionInterval(row, row);
              }
            }
          }
        });
    mvD.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 移动选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row < table.getRowCount()) {
              tableModel.moveRow(row, row, ++row);
              table.getSelectionModel().setSelectionInterval(row, row);
            }
          }
        });
    mvT.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 移动选中列
            DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            if (row > 0) {
              tableModel.moveRow(row, row, --row);
              table.getSelectionModel().setSelectionInterval(row, row);
            }
          }
        });
    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ReadInTable(classPath.getText());
          }
        });

    step3 = new JPanel();
    step3.setBackground(Color.LIGHT_GRAY);
    step3.setBorder(new LineBorder(new Color(0, 0, 0)));
    pane.add(step3, "name_287798491067114");
    step3.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panel.setBackground(Color.LIGHT_GRAY);
    panel.setBorder(new LineBorder(new Color(0, 0, 0)));
    step3.add(panel);
    panel.setLayout(null);

    lblsheet = new JLabel("sheet序号:");
    lblsheet.setBounds(106, 226, 99, 15);
    panel.add(lblsheet);

    label_3 = new JLabel("开始行号:");
    label_3.setBounds(106, 291, 99, 24);
    panel.add(label_3);

    lblSheet = new JLabel("sheet名称:");
    lblSheet.setBounds(106, 261, 99, 15);
    panel.add(lblSheet);

    label_4 = new JLabel("是否缓存:");
    label_4.setBounds(106, 191, 99, 15);
    panel.add(label_4);

    cache = new JCheckBox("选中为缓存(不选为不缓存)");
    cache.setSelected(true);
    cache.setBounds(215, 184, 312, 30);
    panel.add(cache);

    sheet = new JTextField();
    sheet.setText("Sheet0");
    sheet.setColumns(10);
    sheet.setBounds(215, 254, 312, 30);
    panel.add(sheet);

    sheetNum = new JTextField();
    sheetNum.setHorizontalAlignment(SwingConstants.CENTER);
    sheetNum.setBackground(Color.DARK_GRAY);
    sheetNum.setForeground(Color.WHITE);
    sheetNum.setEnabled(false);
    sheetNum.setBounds(461, 219, 66, 30);
    panel.add(sheetNum);
    sheetNum.setColumns(10);

    startRow = new JTextField();
    startRow.setHorizontalAlignment(SwingConstants.CENTER);
    startRow.setForeground(Color.WHITE);
    startRow.setBackground(Color.DARK_GRAY);
    startRow.setEnabled(false);
    startRow.setColumns(10);
    startRow.setBounds(461, 289, 66, 30);
    panel.add(startRow);

    sliderRow = new JSlider();
    sliderRow.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            startRow.setText("" + sliderRow.getValue());
          }
        });
    sliderRow.setMaximum(10);
    sliderRow.setValue(0);
    sliderRow.setBounds(215, 289, 240, 30);
    panel.add(sliderRow);

    sliderSheet = new JSlider();
    sliderSheet.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            sheetNum.setText("" + sliderSheet.getValue());
          }
        });
    sliderSheet.setValue(0);
    sliderSheet.setMaximum(10);
    sliderSheet.setBounds(215, 219, 240, 30);
    panel.add(sliderSheet);

    label_2 = new JLabel("           基本信息:");
    label_2.setPreferredSize(new Dimension(60, 35));
    step3.add(label_2, BorderLayout.NORTH);
  }