コード例 #1
0
  private boolean validateForm() {
    int error = 0;
    if (txtNome.getText().isEmpty()) {
      txtNome.setBorder(borderError);
      error++;
    } else txtNome.setBorder(borderDefault);

    if (txtCpf.getText().isEmpty()) {
      txtCpf.setBorder(borderError);
      error++;
    } else txtCpf.setBorder(borderDefault);

    if (txtEndereco.getText().isEmpty()) {
      txtEndereco.setBorder(borderError);
      error++;
    } else txtEndereco.setBorder(borderDefault);

    if (txtTelefone.getText().isEmpty()) {
      txtTelefone.setBorder(borderError);
      error++;
    } else txtTelefone.setBorder(borderDefault);

    if (txtEmail.getText().isEmpty()) {
      txtEmail.setBorder(borderError);
      error++;
    } else txtEmail.setBorder(borderDefault);

    if (error > 0) return false;
    return true;
  }
コード例 #2
0
ファイル: ElizaGui.java プロジェクト: RafaUresti/sxyjava
 /*
  *Creates the JTextField for the GUI.
  */
 private JTextField inputField() {
   inputField = new JTextField();
   Border inputBorder = BorderFactory.createEtchedBorder();
   inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:");
   inputField.setBorder(inputBorder);
   inputField.addActionListener(new ActionListenerField());
   return inputField;
 }
コード例 #3
0
  private JTextField createField(final String text) {
    final JTextField field =
        new JTextField(text) {
          public Dimension getPreferredSize() {
            Dimension preferredSize = super.getPreferredSize();
            return new Dimension(preferredSize.width, myTextHeight);
          }
        };
    field.setBackground(UIUtil.getPanelBackground());
    field.setEditable(false);
    final Border lineBorder = BorderFactory.createLineBorder(UIUtil.getPanelBackground());
    final DottedBorder dotted = new DottedBorder(UIUtil.getActiveTextColor());
    field.setBorder(lineBorder);
    // field.setFocusable(false);
    field.setHorizontalAlignment(JTextField.RIGHT);
    field.setCaretPosition(0);
    field.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {
            field.setBorder(dotted);
          }

          public void focusLost(FocusEvent e) {
            field.setBorder(lineBorder);
          }
        });
    return field;
  }
コード例 #4
0
ファイル: ShowSavedResults.java プロジェクト: pjotrp/EMBOSS
  /** @param frameName title name for frame */
  public ShowSavedResults(String frameName) {
    super(frameName);
    aboutRes =
        new JTextArea(
            "Select a result set from"
                + "\nthose listed and details"
                + "\nof that analysis will be"
                + "\nshown here. Then you can"
                + "\neither delete or view those"
                + "\nresults using the buttons below.");
    aboutScroll = new JScrollPane(aboutRes);
    ss = new JScrollPane(sp);
    ss.getViewport().setBackground(Color.white);

    //  resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1));
    ClassLoader cl = getClass().getClassLoader();
    rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif"));

    // results status
    resButtonStatus = new JPanel(new BorderLayout());
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();
    Border raisedbevel = BorderFactory.createRaisedBevelBorder();
    Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);
    statusField = new JTextField();
    statusField.setBorder(compound);
    statusField.setEditable(false);
  }
コード例 #5
0
ファイル: Viajes.java プロジェクト: alejo120/Sustentacio
 @Override
 public void keyPressed(KeyEvent ke) {
   if (ke.getSource() == jtxtCodigo) {
     if (jtxtCodigo.getText().trim().length() < 0) {
       jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
     } else {
       jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
     }
   }
   if (ke.getSource() == jtxtPrecio) {
     if (jtxtPrecio.getText().trim().length() < 0) {
       jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
     } else {
       jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
     }
   }
 }
コード例 #6
0
  private void buildUI() {
    Box.Filler divider =
        new Box.Filler(new Dimension(1, 1), new Dimension(1, 1), new Dimension(1, 1));
    divider.setBackground(field.getForeground());
    divider.setOpaque(true);

    GridBagConstraints gbcLabel =
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            0,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0);
    GridBagConstraints gbcDivider =
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL,
            new Insets(0, 2, 0, 2),
            0,
            0);
    GridBagConstraints gbcField =
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0);

    setLayout(new GridBagLayout());
    add(label, gbcLabel);
    add(divider, gbcDivider);
    add(field, gbcField);

    setBorder(field.getBorder());
    setBackground(field.getBackground());
    setOpaque(true);
    label.setBackground(field.getBackground());
    label.setOpaque(true);
    field.setBorder(null);
  }
コード例 #7
0
  loginframe() {
    Container c = getContentPane();
    c.setLayout(null);
    Color co1 = new Color(252, 251, 251);
    Color co2 = new Color(153, 153, 153);
    Color co3 = new Color(0, 0, 0);
    Font fo1 = new Font("Curlz MT", Font.BOLD, 35);
    Font fo2 = new Font("Tahoma", Font.BOLD, 14);
    Font fo3 = new Font("Tahoma", Font.PLAIN, 12);

    l1 = new JLabel("LOGIN");
    l1.setFont(fo1);
    c.add(l1);
    l1.setBounds(130, 30, 200, 30);
    l1.setForeground(co1);

    l2 = new JLabel("Username");
    c.add(l2);
    l2.setBounds(130, 100, 100, 30);
    l2.setForeground(co1);
    l2.setFont(fo2);

    l3 = new JLabel("Password");
    c.add(l3);
    l3.setBounds(130, 150, 100, 30);
    l3.setForeground(co1);
    l3.setFont(fo2);

    t1 = new JTextField();
    t1.setBounds(250, 100, 120, 25);
    c.add(t1);
    t1.setBackground(co2);
    t1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    t1.setForeground(co3);
    t1.setFont(fo3);

    p1 = new JPasswordField();
    p1.setBounds(250, 150, 120, 25);
    c.add(p1);
    p1.setBackground(co2);
    p1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    b1 = new JButton("Login");
    b1.setBounds(140, 220, 70, 30);
    b1.addActionListener(this);
    c.add(b1);

    b2 = new JButton("Exit");
    b2.setBounds(270, 220, 70, 30);
    b2.addActionListener(this);
    c.add(b2);

    l4 = new JLabel("");
    c.add(l4);
    l4.setBounds(0, 0, 464, 409);
    l4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/loginpackage/locked2_1.jpg")));
  }
コード例 #8
0
  private static void insertQuestion(final JTextPane textPane, String str) {
    Document doc = textPane.getDocument();
    try {
      doc.insertString(doc.getLength(), str, null);

      final int pos = doc.getLength();
      System.out.println(pos);
      final JTextField field =
          new JTextField(4) {
            @Override
            public Dimension getMaximumSize() {
              return getPreferredSize();
            }
          };
      field.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
      field.addFocusListener(
          new FocusListener() {
            @Override
            public void focusGained(FocusEvent e) {
              try {
                Rectangle rect = textPane.modelToView(pos);
                rect.grow(0, 4);
                rect.setSize(field.getSize());
                // System.out.println(rect);
                // System.out.println(field.getLocation());
                textPane.scrollRectToVisible(rect);
              } catch (BadLocationException ex) {
                ex.printStackTrace();
              }
            }

            @Override
            public void focusLost(FocusEvent e) {
              /* not needed */
            }
          });
      Dimension d = field.getPreferredSize();
      int baseline = field.getBaseline(d.width, d.height);
      field.setAlignmentY(baseline / (float) d.height);

      SimpleAttributeSet a = new SimpleAttributeSet();
      StyleConstants.setLineSpacing(a, 1.5f);
      textPane.setParagraphAttributes(a, true);

      textPane.insertComponent(field);
      doc.insertString(doc.getLength(), "\n", null);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
コード例 #9
0
ファイル: JSpinner.java プロジェクト: suvarchal/IDV
  /**
   * _more_
   *
   * @param initValue
   * @param min
   * @param max
   */
  public JSpinner(int initValue, int min, int max) {
    value = initValue;
    this.minValue = min;
    this.maxValue = max;

    // the value field
    tf = new JTextField(1);
    tf.setEditable(false);
    javax.swing.border.Border border = tf.getBorder();
    tf.setBorder(BorderFactory.createEmptyBorder());
    setBorder(javax.swing.border.LineBorder.createBlackLineBorder());

    setValue(initValue);

    // create up & down buttons
    JPanel udPanel = new JPanel(new GridLayout(2, 1));
    JButton up = createButton(SpinIcon.TypeUp);
    udPanel.add(up);

    JButton down = createButton(SpinIcon.TypeDown);
    udPanel.add(down);

    add(tf);
    add(udPanel);

    // listeners
    up.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (value < maxValue) {
              value++;
            }
            setValue(value);
          }
        });
    down.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (value > minValue) {
              value--;
            }
            setValue(value);
          }
        });
  }
コード例 #10
0
  /** Constructs a new MemorySegmentComponent. */
  public MemorySegmentComponent() {
    dataFormat = Format.DEC_FORMAT;
    listeners = new Vector();
    errorEventListeners = new Vector();
    highlightIndex = new Vector();
    segmentTable = new JTable(getTableModel());
    segmentTable.setDefaultRenderer(segmentTable.getColumnClass(0), getCellRenderer());
    startEnabling = -1;
    endEnabling = -1;

    JTextField tf = new JTextField();
    tf.setFont(Utilities.bigBoldValueFont);
    tf.setBorder(null);
    DefaultCellEditor editor = new DefaultCellEditor(tf);
    segmentTable.getColumnModel().getColumn(getColumnValue()).setCellEditor(editor);

    jbInit();
  }
コード例 #11
0
ファイル: Annotation.java プロジェクト: argodev/BiLab
  protected void setUpSRSFrame(URL url, String search) throws IOException {
    if (BigPane.srsFrame == null) {
      BigPane.setUpSRSFrame((2 * desktop.getHeight()) / 3, desktop);
      Border loweredbevel = BorderFactory.createLoweredBevelBorder();
      Border raisedbevel = BorderFactory.createRaisedBevelBorder();
      Border compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel);

      JTextField statusField = new JTextField();
      statusField.setBorder(compound);
      statusField.setEditable(false);
      BigPane.srsFrame.getContentPane().add(statusField, BorderLayout.SOUTH);
    }

    Annotation edPane = new Annotation(url);
    JScrollPane jsp = new JScrollPane(edPane);
    JTabbedPane jtab = (JTabbedPane) BigPane.srsFrame.getContentPane().getComponent(0);
    jtab.insertTab(search, null, jsp, null, 0);
    BigPane.srsFrame.setVisible(true);
  }
コード例 #12
0
ファイル: GameBoard.java プロジェクト: LaytonW/CardGame
  /** Constructor for allocating memory and simple initializing. */
  public GameBoard() {
    dealerPanel = new JPanel();
    playerPanel = new JPanel();
    controlPanel = new JPanel();
    money = new JLabel();
    record = new JLabel();
    inputImage = new JLabel(new ImageIcon("res/INPUT.gif"));
    moneyLabel = new JLabel(new ImageIcon("res/MONEY.gif"));
    betLabel = new JLabel(new ImageIcon("res/MAKE_YOUR_BET.gif"));
    recordLabel = new JLabel(new ImageIcon("res/BEST_SCORE.gif"));
    betButton = new JButton(new ImageIcon("res/BET.gif"));
    resultButton = new JButton(new ImageIcon("res/RESULT.gif"));
    betInput = new JTextField();

    try {
      recordReader = new BufferedReader(new FileReader("res/record"));
      bestScore = Integer.parseInt(recordReader.readLine());
      recordReader.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    inputImage.setLayout(new BorderLayout());
    controlPanel.setLayout(new FlowLayout());

    betInput.setHorizontalAlignment(JTextField.CENTER);
    betButton.setBorder(BorderFactory.createEmptyBorder());
    betButton.setContentAreaFilled(false);
    resultButton.setBorder(BorderFactory.createEmptyBorder());
    resultButton.setContentAreaFilled(false);
    resultButton.setEnabled(false);
    betButton.addMouseListener(new BetListener());
    resultButton.addMouseListener(new ResultListener());
    betInput.setOpaque(false);
    betInput.setBorder(BorderFactory.createEmptyBorder());
    money.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    record.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30));
    setOpaque(false);

    initGame();
    initRound();
  }
コード例 #13
0
  public WalletSumPanel(BigInteger balance) {

    this.setBackground(Color.WHITE);
    double width = this.getSize().getWidth();
    this.setPreferredSize(new Dimension(500, 50));
    Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
    Border empty = new EmptyBorder(5, 8, 5, 8);
    CompoundBorder border = new CompoundBorder(line, empty);

    JLabel addressField = new JLabel();
    addressField.setPreferredSize(new Dimension(300, 35));
    this.add(addressField);

    JTextField amount = new JTextField();
    amount.setBorder(border);
    amount.setEnabled(true);
    amount.setEditable(false);
    amount.setText(Utils.getValueShortString(balance));

    amount.setPreferredSize(new Dimension(100, 35));
    amount.setForeground(new Color(143, 170, 220));
    amount.setHorizontalAlignment(SwingConstants.RIGHT);
    amount.setFont(new Font("Monospaced", 0, 13));
    amount.setBackground(Color.WHITE);
    this.add(amount);

    URL payoutIconURL = ClassLoader.getSystemResource("buttons/wallet-pay.png");
    ImageIcon payOutIcon = new ImageIcon(payoutIconURL);
    JLabel payOutLabel = new JLabel(payOutIcon);
    payOutLabel.setToolTipText("Payout for all address list");
    payOutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    payOutLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JOptionPane.showMessageDialog(null, "Under construction");
          }
        });

    this.add(payOutLabel);
  }
コード例 #14
0
 @Nullable
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   myValue = ((MyTableModel) table.getModel()).getRegistryValue(row);
   if (myValue.asColor(null) != null) {
     final Color color =
         ColorChooser.chooseColor(
             table, "Choose color", ((RegistryValue) value).asColor(Color.WHITE));
     if (color != null) {
       myValue.setValue(color.getRed() + "," + color.getGreen() + "," + color.getBlue());
     }
     return null;
   } else if (myValue.isBoolean()) {
     myCheckBox.setSelected(myValue.asBoolean());
     myCheckBox.setBackground(table.getBackground());
     return myCheckBox;
   } else {
     myField.setText(myValue.asString());
     myField.setBorder(null);
     myField.selectAll();
     return myField;
   }
 }
コード例 #15
0
ファイル: Viajes.java プロジェクト: alejo120/Sustentacio
  public Viajes() {
    super.setBounds(181, 61, 700, 538); // (ancho,alto)
    super.setLayout(null);
    super.setOpaque(false);
    super.setVisible(false);

    try {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    tbDatos = new JTable(dataModel);
    tbDatos.setEnabled(false);
    tbDatos.setAutoResizeMode(5);
    tbDatos.setCellSelectionEnabled(true);
    tbDatos.setForeground(Color.BLACK);
    pnDatos = new JScrollPane(tbDatos);
    pnDatos.setBounds(30, 30, 640, 478);
    pnDatos.setVisible(false);
    this.add(pnDatos);
    llenarDatos();

    jlbCodigo = new JLabel("*Código");
    jlbCodigo.setBounds(90, 100, 220, 25);
    jlbCodigo.setForeground(Color.BLACK);
    jlbCodigo.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbCodigo);

    jtxtCodigo = new JTextField("");
    jtxtCodigo.setBounds(90, 125, 520, 30);
    jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtCodigo.addKeyListener(this);
    this.add(jtxtCodigo);

    jlbOrigen = new JLabel("*Origen");
    jlbOrigen.setBounds(90, 180, 150, 25);
    jlbOrigen.setForeground(Color.BLACK);
    jlbOrigen.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbOrigen);

    jcbOrigen = new JComboBox();
    jcbOrigen.setBorder(null);
    jcbOrigen.setBackground(Color.WHITE);
    jcbOrigen.addItem("Medellín");
    jcbOrigen.addItem("Bogotá");
    jcbOrigen.addItem("Barranquilla");
    jcbOrigen.setBounds(90, 205, 250, 30);
    this.add(jcbOrigen);

    jlbDestino = new JLabel("*Destino");
    jlbDestino.setBounds(360, 180, 150, 25);
    jlbDestino.setForeground(Color.BLACK);
    jlbDestino.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbDestino);

    jcbDestino = new JComboBox();
    jcbDestino.setBorder(null);
    jcbDestino.setBackground(Color.WHITE);
    jcbDestino.addItem("Bogotá");
    jcbDestino.addItem("Medellín");
    jcbDestino.addItem("Barranquilla");
    jcbDestino.setBounds(360, 205, 250, 30);
    this.add(jcbDestino);

    jlbPrecio = new JLabel("*Precio");
    jlbPrecio.setBounds(90, 260, 120, 25);
    jlbPrecio.setForeground(Color.BLACK);
    jlbPrecio.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbPrecio);

    jtxtPrecio = new JTextField("");
    jtxtPrecio.setBounds(90, 285, 520, 30);
    jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtPrecio.addKeyListener(this);
    this.add(jtxtPrecio);

    jlbEstado = new JLabel("*Estado");
    jlbEstado.setBounds(90, 340, 150, 25);
    jlbEstado.setForeground(Color.BLACK);
    jlbEstado.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbEstado);

    jcbEstado = new JComboBox();
    jcbEstado.setBorder(null);
    jcbEstado.setBackground(Color.WHITE);
    jcbEstado.addItem("Activo");
    jcbEstado.addItem("Inactivo");
    jcbEstado.setBounds(90, 365, 520, 30);
    this.add(jcbEstado);

    jbtnListar = new JButton(" Lista");
    jbtnListar.setBounds(0, 0, 233, 60);
    jbtnListar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/List-26.png")));
    jbtnListar.setBorder(null);
    jbtnListar.setBackground(new Color(0, 154, 225));
    jbtnListar.setForeground(Color.WHITE);
    jbtnListar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnListar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnListar.addMouseListener(this);
    jbtnListar.addActionListener(this);
    jbtnListar.setFocusPainted(false);
    this.add(jbtnListar);

    jbtnBuscar = new JButton(" Buscar");
    jbtnBuscar.setBounds(233, 0, 234, 60);
    jbtnBuscar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Search-26.png")));
    jbtnBuscar.setBorder(null);
    jbtnBuscar.setBackground(new Color(0, 154, 225));
    jbtnBuscar.setForeground(Color.WHITE);
    jbtnBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnBuscar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnBuscar.addMouseListener(this);
    jbtnBuscar.addActionListener(this);
    jbtnBuscar.setFocusPainted(false);
    this.add(jbtnBuscar);

    jbtnActualizar = new JButton(" Actualizar");
    jbtnActualizar.setBounds(233, 0, 234, 60);
    jbtnActualizar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Edit-26.png")));
    jbtnActualizar.setBorder(null);
    jbtnActualizar.setBackground(new Color(0, 154, 225));
    jbtnActualizar.setForeground(Color.WHITE);
    jbtnActualizar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnActualizar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnActualizar.addMouseListener(this);
    jbtnActualizar.setVisible(false);
    jbtnActualizar.addActionListener(this);
    jbtnActualizar.setFocusPainted(false);
    this.add(jbtnActualizar);

    jbtnLimpiar = new JButton(" Limpiar");
    jbtnLimpiar.setBounds(467, 0, 233, 60);
    jbtnLimpiar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Clean-26.png")));
    jbtnLimpiar.setBorder(null);
    jbtnLimpiar.setBackground(new Color(0, 154, 225));
    jbtnLimpiar.setForeground(Color.WHITE);
    jbtnLimpiar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnLimpiar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnLimpiar.addMouseListener(this);
    jbtnLimpiar.addActionListener(this);
    jbtnLimpiar.setFocusPainted(false);
    this.add(jbtnLimpiar);

    jpBotones = new JPanel();
    jpBotones.setBackground(new Color(0, 123, 183));
    jpBotones.add(jbtnListar);
    jpBotones.add(jbtnBuscar);
    jpBotones.add(jbtnActualizar);
    jpBotones.add(jbtnLimpiar);
    jpBotones.setLayout(null);
    jpBotones.setBounds(0, 478, 700, 60);
    this.add(jpBotones);

    jlbValidar = new JLabel("Los campos con (*) son obligatorios");
    jlbValidar.setForeground(Color.WHITE);
    jlbValidar.setBounds(80, 8, 300, 27);
    jlbValidar.setFont(new Font("Segoe UI", Font.PLAIN, 17));
    this.add(jlbValidar);

    jpError = new JPanel();
    jpError.add(jlbValidar);
    jpError.setLayout(null);
    jpError.setBackground(new Color(0, 123, 183));
    jpError.setBounds(0, 0, 700, 45);
    this.add(jpError);

    this.repaint();
  }
  public Design() throws Exception {
    super.setBackground(Color.BLACK);
    this.setTitle("");
    con = getContentPane();
    con.setLayout(null);
    dim = tk.getDefaultToolkit().getScreenSize();
    this.setTitle("Customer Peer Login");

    l1 = new JLabel(new ImageIcon("plain.jpg"));
    l1.setBounds(0, 0, 400, 400);
    con.add(l1);
    l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black));

    title = new JLabel("CUSTOMER PEER LOGIN ");
    title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20));
    title.setForeground(Color.red);
    title.setBounds(80, 30, 300, 30);
    l1.add(title);

    l4 = new JLabel("CMACHINE NAME");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.BLUE);
    l4.setBounds(70, 100, 160, 20);
    //	l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green));

    l1.add(l4);
    jtf2 = new JTextField();
    jtf2.setBounds(250, 100, 100, 20);
    jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf2);

    l2 = new JLabel("CUSER LOGIN");
    l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l2.setForeground(Color.blue);
    l2.setBounds(70, 150, 120, 20);
    l1.add(l2);

    jtf1 = new JTextField();
    jtf1.setBounds(250, 150, 100, 20);
    jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jtf1);

    l3 = new JLabel("CPASSWORD");
    l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l3.setForeground(Color.blue);
    l3.setBounds(70, 200, 120, 20);
    l1.add(l3);

    jptf1 = new JPasswordField();
    jptf1.setBounds(250, 200, 100, 20);
    jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));

    l1.add(jptf1);

    JLabel l4 = new JLabel("DAgent");
    l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16));
    l4.setForeground(Color.blue);
    l4.setBounds(70, 250, 120, 20);
    l1.add(l4);

    box = new JComboBox();
    box.setBounds(250, 250, 100, 20);
    box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green));
    l1.add(box);

    b2 = new JButton("Register");
    b2.setBounds(50, 300, 100, 20);
    l1.add(b2);
    b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    b3 = new JButton("Login");
    b3.setBounds(150, 300, 100, 20);
    b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));
    l1.add(b3);

    b1 = new JButton("Cancel");
    b1.setBounds(250, 300, 100, 20);
    b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE));

    l1.add(b1);

    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            dispose();
          }
        });

    try {

      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      conn = DriverManager.getConnection("jdbc:odbc:agent");

    } catch (Exception exp) {

    }

    try {
      Statement satem = conn.createStatement();
      ResultSet rsatem = satem.executeQuery("select * from Dagent");
      while (rsatem.next()) {
        String namem = rsatem.getString("uname");
        box.addItem(namem);
      }

    } catch (Exception expo1) {

    }

    b2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String dname = box.getSelectedItem().toString();
            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {
              exp.printStackTrace();
            }

            try {
              packet p = new packet();
              p.setaction("Creg");
              p.setCuser(username);
              p.setCpass(password);
              p.setCmname(mechine);
              p.setCDpeer(dname);
              Socket soc = new Socket(servermachine, porte);
              ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream());
              out.writeObject(p);
              ObjectInputStream in = new ObjectInputStream(soc.getInputStream());
              packet rpac = (packet) in.readObject();
              if (rpac.getaction().equals("ok")) {

                JOptionPane.showMessageDialog(null, "Sucessfully Registered");

                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");

              } else {

                JOptionPane.showMessageDialog(null, "Already Registered");
                jtf2.setText("");
                jtf1.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent we) {

            String username = jtf1.getText().trim();
            String password = jptf1.getText().trim();
            String mechine = jtf2.getText().trim();
            String Dname = box.getSelectedItem().toString();

            int porte = 0;

            try {
              Statement sate = conn.createStatement();
              ResultSet rsate =
                  sate.executeQuery("select * from Dagent where uname='" + Dname + "'");
              if (rsate.next()) {
                servermachine = rsate.getString("umechine");
                porte = rsate.getInt("ulistport");
                System.out.println(servermachine);
              }
              System.out.println(servermachine);

            } catch (Exception exp) {

            }

            try {

              packet p1 = new packet();
              p1.setaction("clogin");
              p1.setCuser(username);
              p1.setCpass(password);
              p1.setCmname(mechine);
              p1.setCDpeer(Dname);
              Socket soc1 = new Socket(servermachine, porte);
              ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream());
              out1.writeObject(p1);
              ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream());
              packet rpac1 = (packet) in1.readObject();
              if (rpac1.getaction().equals("ok")) {
                int port1 = 0;
                try {

                  int portm = rpac1.getCport();
                  System.out.println("XXXXXXX" + portm);
                  //	JOptionPane.showMessageDialog(null,"Sucessfully Started");

                  new Listen(portm);
                  new process(username, portm);
                  dispose();
                } catch (Exception exp) {
                }
              } else {
                JOptionPane.showMessageDialog(
                    null, "Enter valid username and password", "Server reply", 2);
                jtf1.setText("");
                jtf2.setText("");
                jptf1.setText("");
              }

            } catch (Exception exp) {
            }
          }
        });

    setSize(400, 400);
    show();
    setLocation(150, 100);
    setResizable(false);
  }
コード例 #17
0
ファイル: ClientGui.java プロジェクト: timburrow/ovj3
  ShutdownFrame(CryoBay cb) {
    super("CryoBay Monitor");
    cryoB = cb;

    cmdClose =
        new JButton("Close") {
          public JToolTip createToolTip() {
            return new JToolTip();
          }
        };

    cmdClose.setToolTipText("Close program");

    cmdClose.addActionListener(this);
    addWindowListener(this);

    GridBagConstraints gbc = new GridBagConstraints();
    Border loweredbevel = BorderFactory.createLoweredBevelBorder();

    lblBStatus = new JLabel("Status: ");
    lblBHeater = new JLabel("Heater: ");
    lblBTemp = new JLabel("  Temp: ");
    lblBCli = new JLabel("   CLI: ");

    lblStatus = new JTextField(17);
    lblStatus.setEditable(false);
    lblStatus.setOpaque(true);
    lblStatus.setBorder(loweredbevel);

    lblHeater = new JTextField(17);
    lblHeater.setEditable(false);
    lblHeater.setOpaque(true);
    lblHeater.setBorder(loweredbevel);

    lblTemp = new JTextField(17);
    lblTemp.setEditable(false);
    lblTemp.setOpaque(true);
    lblTemp.setBorder(loweredbevel);

    lblCli = new JTextField(17);
    lblCli.setEditable(false);
    lblCli.setOpaque(true);
    lblCli.setBorder(loweredbevel);

    JPanel lblPanel = new JPanel();
    lblPanel.setLayout(new GridBagLayout());
    gbc.insets = new Insets(2, 5, 2, 5);
    setGbc(gbc, 0, 0, 1, 1);
    lblPanel.add(lblBStatus, gbc);
    setGbc(gbc, 0, 1, 1, 1);
    lblPanel.add(lblBHeater, gbc);
    setGbc(gbc, 0, 2, 1, 1);
    lblPanel.add(lblBTemp, gbc);
    setGbc(gbc, 0, 3, 1, 1);
    lblPanel.add(lblBCli, gbc);

    JPanel valPanel = new JPanel();
    valPanel.setLayout(new GridBagLayout());
    gbc.insets = new Insets(2, 5, 2, 5);
    setGbc(gbc, 0, 0, 1, 1);
    valPanel.add(lblStatus, gbc);
    setGbc(gbc, 0, 1, 1, 1);
    valPanel.add(lblHeater, gbc);
    setGbc(gbc, 0, 2, 1, 1);
    valPanel.add(lblTemp, gbc);
    setGbc(gbc, 0, 3, 1, 1);
    valPanel.add(lblCli, gbc);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    gbc.anchor = GridBagConstraints.CENTER;
    setGbc(gbc, 0, 5, 1, 1);
    buttonPanel.add(cmdClose, gbc);

    // finally, add the panels to the content pane
    getContentPane().setLayout(new GridBagLayout());
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.anchor = GridBagConstraints.CENTER;
    setGbc(gbc, 0, 0, 1, 4);
    getContentPane().add(lblPanel, gbc);
    setGbc(gbc, 1, 0, 1, 4);
    getContentPane().add(valPanel, gbc);
    setGbc(gbc, 0, 5, 0, 0);
    getContentPane().add(buttonPanel, gbc);

    setSize(300, 220);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 220);
    setResizable(true);
  }
コード例 #18
0
  private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border3, "Subject");
    border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder2 = new TitledBorder(border4, "Message");
    border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder3 = new TitledBorder(border5, "Subject");
    border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder4 = new TitledBorder(border6, "Message");
    border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder5 = new TitledBorder(border7, "Messages");
    border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder6 = new TitledBorder(border8, "Online Users");
    border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder7 = new TitledBorder(border9, "Send Message");
    this.getContentPane().setLayout(borderLayout1);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setBorder(border1);
    jSplitPane1.setLastDividerLocation(250);
    jSplitPane1.setResizeWeight(1.0);
    jLabelServer.setRequestFocusEnabled(true);
    jLabelServer.setText("Server");
    jLabelUserId.setText("User Id");
    jTextFieldServer.setPreferredSize(new Dimension(75, 20));
    jTextFieldServer.setText("");
    jTextFieldUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldUser.setText("");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setJMenuBar(jMenuBarMain);
    this.setTitle("Message Client");
    jLabeltargetUser.setText("Target");
    jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldTargetUser.setText("");
    jPanelSendMessages.setBorder(border2);
    jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767));
    jPanelSendMessages.setOpaque(false);
    jPanelSendMessages.setPreferredSize(new Dimension(96, 107));
    jPanelSendMessages.setRequestFocusEnabled(true);
    jPanelSendMessages.setToolTipText("");
    jPanelSendMessages.setLayout(verticalFlowLayout1);
    jTextFieldSendSubject.setBorder(titledBorder3);
    jTextFieldSendSubject.setText("");
    jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this));
    jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    jScrollPane1.setBorder(titledBorder5);
    jScrollPane2.setBorder(titledBorder6);
    jToggleButtonRegister.setText("Register");
    jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this));
    jButtonMultiConnect.setText("Multi-Connect");
    jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this));
    jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this));
    jToggleButtonConnect.setText("Connect");
    jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this));
    jTextPaneDisplayMessages.setEditable(false);
    jTextPaneDisplayMessages.addMouseListener(
        new Client_jTextPaneDisplayMessages_mouseAdapter(this));
    jTextFieldSendMessages.setBorder(titledBorder7);
    jTextFieldSendMessages.setToolTipText("");
    jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this));
    jButtonMessageStresser.setText("Msg Stresser");
    jButtonMessageStresser.addActionListener(
        new Client_jToggleButtonMessageStresser_actionAdapter(this));
    jMenuItemClearMessages.setText("Clear Messages");
    jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this));
    jMenuServer.setText("Server");
    jMenuItemServerConnect.setText("Connect");
    jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this));
    jMenuItemServerDisconnect.setText("Disconnect");
    jMenuItemServerDisconnect.addActionListener(
        new Client_jMenuItemServerDisconnect_actionAdapter(this));
    jMenuOptions.setText("Options");
    jMenuTest.setText("Test");
    jMenuItemOptionsRegister.setText("Register");
    jMenuItemOptionsRegister.addActionListener(
        new Client_jMenuItemOptionsRegister_actionAdapter(this));
    jMenuItemOptionsDeregister.setText("Deregister");
    jMenuItemOptionsDeregister.addActionListener(
        new Client_jMenuItemOptionsDeregister_actionAdapter(this));
    jMenuItemOptionsEavesdrop.setText("Eavesdrop");
    jMenuItemOptionsEavesdrop.addActionListener(
        new Client_jMenuItemOptionsEavesdrop_actionAdapter(this));
    jMenuItemOptionsUneavesdrop.setText("Uneavesdrop");
    jMenuItemOptionsUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this));
    jMenuItemTestMulticonnect.setText("Multiconnect");
    jMenuItemTestMulticonnect.addActionListener(
        new Client_jMenuItemTestMulticonnect_actionAdapter(this));
    jMenuItemTestMessageStresser.setText("Message Stresser");
    jMenuItemTestMessageStresser.addActionListener(
        new Client_jMenuItemTestMessageStresser_actionAdapter(this));
    jMenuItemTestMultidisconnect.setText("Multidisconnect");
    jMenuItemTestMultidisconnect.addActionListener(
        new Client_jMenuItemTestMultidisconnect_actionAdapter(this));
    jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop");
    jMenuItemOptionsGlobalEavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this));
    jMenuItemOptionsGlobalUneavesdrop.setEnabled(false);
    jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop");
    jMenuItemOptionsGlobalUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this));
    jLabelPwd.setText("Pwd");
    jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20));
    jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20));
    jPasswordFieldPwd.setText("");
    jMenuItemScheduleCommand.setText("Schedule Command");
    jMenuItemScheduleCommand.addActionListener(
        new Client_jMenuItemScheduleCommand_actionAdapter(this));
    jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands");
    jMenuItemEditScheduledCommands.addActionListener(
        new Client_jMenuItemEditScheduledCommands_actionAdapter(this));
    jPanelSendMessages.add(jTextFieldSendSubject, null);
    jPanelSendMessages.add(jTextFieldSendMessages, null);
    jSplitPane1.add(jSplitPane2, JSplitPane.TOP);
    jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
    jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null);
    jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM);
    jScrollPane2.getViewport().add(jListOnlineUsers, null);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM);
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabelServer, null);
    jPanel1.add(jTextFieldServer, null);
    jPanel1.add(jLabelUserId, null);
    jPanel1.add(jTextFieldUser, null);
    jPanel1.add(jLabelPwd, null);
    jPanel1.add(jPasswordFieldPwd, null);
    jPanel1.add(jLabeltargetUser, null);
    jPanel1.add(jTextFieldTargetUser, null);
    jPanel1.add(jToggleButtonConnect, null);
    jPanel1.add(jToggleButtonRegister, null);
    jPanel1.add(jButtonMultiConnect, null);
    jPanel1.add(jButtonMessageStresser, null);
    jPopupMenuMessageArea.add(jMenuItemClearMessages);
    jMenuBarMain.add(jMenuServer);
    jMenuBarMain.add(jMenuOptions);
    jMenuBarMain.add(jMenuTest);
    jMenuServer.add(jMenuItemServerConnect);
    jMenuServer.add(jMenuItemServerDisconnect);
    jMenuOptions.add(jMenuItemOptionsRegister);
    jMenuOptions.add(jMenuItemOptionsDeregister);
    jMenuOptions.add(jMenuItemOptionsEavesdrop);
    jMenuOptions.add(jMenuItemOptionsUneavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop);
    jMenuTest.add(jMenuItemTestMulticonnect);
    jMenuTest.add(jMenuItemTestMultidisconnect);
    jMenuTest.add(jMenuItemTestMessageStresser);
    jMenuTest.add(jMenuItemScheduleCommand);
    jMenuTest.add(jMenuItemEditScheduledCommands);
    jSplitPane1.setDividerLocation(200);
    jSplitPane2.setDividerLocation(600);
    jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer());
    jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    jMenuItemTestMulticonnect.setEnabled(true);
    jMenuItemTestMultidisconnect.setEnabled(false);
    jMenuItemServerConnect.setEnabled(true);
    jMenuItemServerDisconnect.setEnabled(false);
    jMenuItemOptionsRegister.setEnabled(true);
    jMenuItemOptionsDeregister.setEnabled(false);
  }
コード例 #19
0
ファイル: Viajes.java プロジェクト: alejo120/Sustentacio
  @Override
  public void actionPerformed(ActionEvent ae) {
    ViajesEnt ViajesE = new ViajesEnt();
    ViajesNg ViajesN = new ViajesNg();
    if (ae.getSource() == jbtnListar) {
      LimpiarCampos();
      pnDatos.setVisible(true);
      jpBotones.setVisible(false);
      jpError.setVisible(false);
      vaciar();
      llenarDatos();
    }
    if (ae.getSource() == jbtnBuscar) {
      LimpiarCampos();
      String Codigo;
      Codigo = jtxtCodigo.getText();
      if (Codigo.trim().length() != 0) {
        ViajesE = ViajesN.buscarViajeCodigo(Codigo);
        if (ViajesE != null) {
          jtxtCodigo.setText(ViajesE.getCodigo());
          jcbDestino.setSelectedItem(ViajesE.getDestino());
          jcbOrigen.setSelectedItem(ViajesE.getOrigen());
          jtxtPrecio.setText(ViajesE.getPrecio());
          jcbEstado.setSelectedItem(ViajesE.getEstado());
          jtxtCodigo.setFocusable(false);
          jbtnBuscar.setVisible(false);
          jbtnActualizar.setVisible(true);
          if (jbtnActualizar.getBounds().x == 0) {
            jbtnListar.setBounds(0, 0, 350, 60);
            jbtnLimpiar.setBounds(350, 0, 350, 60);
          }
        } else {
          Toolkit.getDefaultToolkit().beep();
          jpError.setBackground(new Color(237, 28, 36));
          jlbValidar.setText("El viaje no se ha encontrado");
        }
      } else {
        Toolkit.getDefaultToolkit().beep();
        jpError.setBackground(new Color(237, 28, 36));
        jlbValidar.setText("Ingrese el Código");
        jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
      }
    }

    if (ae.getSource() == jbtnActualizar) {
      if (jtxtPrecio.getText().trim().length() == 0) {
        Toolkit.getDefaultToolkit().beep();
        jpError.setBackground(new Color(237, 28, 36));
        jlbValidar.setText("Ingrese los campos en rojo");
        jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
        return;
      } else {
        jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
      }
      try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      } catch (Exception ex) {
        System.err.println(ex);
      }
      int option =
          JOptionPane.showConfirmDialog(
              this,
              "¿Está seguro que desea actualizar el viaje?",
              "Airline Travel",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE);
      try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      if (option == JOptionPane.YES_OPTION) {
        if (jtxtCodigo.getText().trim().length() > 0) {
          ViajesE.setCodigo(jtxtCodigo.getText());
        }

        ViajesE.setOrigen((String) jcbOrigen.getSelectedItem());
        ViajesE.setDestino((String) jcbDestino.getSelectedItem());

        if (jtxtPrecio.getText().trim().length() > 0) {
          ViajesE.setPrecio(jtxtPrecio.getText());
        }

        ViajesE.setEstado((String) jcbEstado.getSelectedItem());

        boolean respuestau = ViajesN.modificarViaje(ViajesE);
        if (respuestau) {
          LimpiarCampos();
          jpError.setBackground(new Color(0, 154, 225));
          jlbValidar.setText("Se ha actualizado el viaje");
        }
      }
    }

    if (ae.getSource() == jbtnLimpiar) {
      LimpiarCampos();
      VaciarCampos();
      jtxtCodigo.setFocusable(true);
      jbtnBuscar.setVisible(true);
      jbtnActualizar.setVisible(false);
      if (jbtnActualizar.getBounds().x == 0) {
        jbtnListar.setBounds(0, 0, 233, 60);
        jbtnLimpiar.setBounds(467, 0, 233, 60);
      }
    }
  }
コード例 #20
0
  /** Create the window UI. */
  private void buildUI() {
    Container cPane = getContentPane();
    cPane.setLayout(new GridBagLayout());
    GridBagConstraints c;
    JLabel label;
    String msg;
    JTextField field;

    int row = 0;

    label = new JLabel(sTimeStampFormat.format(mInvite.getTimestamp()));
    label.setFont(new Font("SansSerif", Font.PLAIN, 9));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    msg = mInvite.getPlayerJID();
    msg = StringUtils.parseBareAddress(msg);
    field = new JTextField(msg);
    field.setEditable(false);
    field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(field, c);

    String gamename = mInvite.getGameName();
    if (gamename != null) gamename = gamename.trim();

    if (gamename != null && !gamename.equals("")) msg = "  " + localize("MessageInvitedOf");
    else msg = "  " + localize("MessageInvited");
    label = new JLabel(msg);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    if (gamename != null && !gamename.equals("")) {
      field = new JTextField(gamename);
      field.setEditable(false);
      field.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = row++;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.anchor = GridBagConstraints.WEST;
      c.insets = new Insets(SPACING, MARGIN, 0, MARGIN);
      cPane.add(field, c);
    }

    String message = mInvite.getMessage();
    if (message != null) message = message.trim();

    if (message != null && !message.equals("")) {
      JTextArea textarea = new JTextArea();
      textarea.setEditable(false);
      textarea.setRows(4);
      textarea.setLineWrap(true);
      textarea.setWrapStyleWord(true);
      textarea.setText(message);
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = row++;
      c.gridwidth = GridBagConstraints.REMAINDER;
      c.weightx = 1;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.WEST;
      c.insets = new Insets(GAP, MARGIN, 0, MARGIN);
      JScrollPane scroller = new JScrollPane(textarea);
      scroller.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4));
      cPane.add(scroller, c);
    }

    label = new JLabel(localize("LabelNickname"));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(GAP, MARGIN, 0, MARGIN);
    cPane.add(label, c);

    mNicknameField = new JTextField(20);
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = row++;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(GAP, SPACING, 0, MARGIN);
    cPane.add(mNicknameField, c);

    // Add panel with Cancel and Create buttons
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = row++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(GAP, MARGIN, MARGIN, MARGIN);
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    cPane.add(buttonPanel, c);

    mAcceptButton = new JButton(localize("ButtonAccept"));
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mAcceptButton, c);

    mChatButton = new JButton(localize("ButtonDeclineChat"));
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, SPACING, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mChatButton, c);

    mDeclineButton = new JButton(localize("ButtonDecline"));
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, SPACING, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    buttonPanel.add(mDeclineButton, c);
  }
コード例 #21
0
ファイル: Viajes.java プロジェクト: alejo120/Sustentacio
 public void LimpiarCampos() {
   jpError.setBackground(new Color(0, 123, 183));
   jlbValidar.setText("Los campos con (*) son obligatorios");
   jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
   jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
 }
コード例 #22
0
ファイル: AboutDialog.java プロジェクト: nsahoo/cmssw-1
  /** initialize GUI components */
  private JPanel initComponents() {
    JPanel panel = new JPanel();
    JScrollPane jScrollPane1 = new JScrollPane();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();

    jScrollPane1.setViewportView(jEditorPaneAbout);

    jButtonOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonOkActionPerformed(e);
          }
        });

    jButtonOk.setText("OK");
    jLabel1.setText("Application:");
    jLabel2.setText("Version:");

    jTextFieldApplication.setBackground(new Color(255, 255, 255));
    jTextFieldApplication.setEditable(false);
    jTextFieldApplication.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    jTextFieldVersion.setBackground(new Color(255, 255, 255));
    jTextFieldVersion.setEditable(false);
    jTextFieldVersion.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    jEditorPaneAbout.setEditable(false);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .add(
                                        layout
                                            .createParallelGroup(
                                                org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(
                                                jScrollPane1,
                                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                289,
                                                Short.MAX_VALUE)
                                            .add(
                                                layout
                                                    .createSequentialGroup()
                                                    .add(
                                                        layout
                                                            .createParallelGroup(
                                                                org.jdesktop.layout.GroupLayout
                                                                    .LEADING)
                                                            .add(
                                                                jTextFieldApplication,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .PREFERRED_SIZE,
                                                                145,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .PREFERRED_SIZE)
                                                            .add(jLabel1))
                                                    .add(4, 4, 4)
                                                    .add(
                                                        layout
                                                            .createParallelGroup(
                                                                org.jdesktop.layout.GroupLayout
                                                                    .LEADING)
                                                            .add(jLabel2)
                                                            .add(
                                                                jTextFieldVersion,
                                                                org.jdesktop.layout.GroupLayout
                                                                    .DEFAULT_SIZE,
                                                                140,
                                                                Short.MAX_VALUE)))))
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .add(106, 106, 106)
                                    .add(
                                        jButtonOk,
                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                        101,
                                        Short.MAX_VALUE)
                                    .add(94, 94, 94)))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1)
                            .add(jLabel2))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(
                                jTextFieldApplication,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(
                                jTextFieldVersion,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(
                        jScrollPane1,
                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                        300,
                        Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jButtonOk)
                    .addContainerGap()));
    return panel;
  }
コード例 #23
0
  public DefaultDnDSupport() {
    JFrame fen = new JFrame("DnD et CCP");
    fen.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
    fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Panel gauche
    JPanel panelgauche = new JPanel();
    panelgauche.setLayout(new BoxLayout(panelgauche, BoxLayout.Y_AXIS));

    // JTextField
    JTextField textField = new JTextField(10);
    textField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    textField.setDragEnabled(true);

    // JPasswordField
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JPasswordField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    passwordField.setDragEnabled(true);

    // JFormattedTextField
    JFormattedTextField ftf = new JFormattedTextField("Universite de Lille 1");
    ftf.setFont(new Font("Courier", Font.ITALIC, 12));
    ftf.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFormattedTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    ftf.setDragEnabled(true);

    // JTextArea
    JTextArea jta = new JTextArea("Master 1 informatique");
    jta.setFont(new Font("Arial", Font.BOLD, 12));
    jta.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextArea"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jta.setDragEnabled(true);

    // JEditorPane
    JEditorPane editorPane = createEditorPane();
    editorPane.setDragEnabled(true);
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JEditorPane"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // JColorChooser
    JColorChooser cc = new JColorChooser();
    cc.setDragEnabled(true);
    cc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JColorChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Panel droit
    JPanel paneldroit = new JPanel();
    paneldroit.setLayout(new BoxLayout(paneldroit, BoxLayout.Y_AXIS));

    // JList
    String[] data = {
      "AAC", "AEV", "ANG", "ASE", "COA", "PJE", "CAR", "PJI", "AeA", "BDA", "CALP", "FDD", "HECI",
      "IHM", "M3DS", "PAC", "PPD", "RdF", "SVL", "TI"
    };
    JList liste = new JList(data);
    JScrollPane jscrollListe = new JScrollPane(liste);
    jscrollListe.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JList"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    // liste.setDragEnabled(true);

    // JTree
    DefaultMutableTreeNode m1 = new DefaultMutableTreeNode("M1");
    DefaultMutableTreeNode s1 = new DefaultMutableTreeNode("S1");
    m1.add(s1);
    s1.add(new DefaultMutableTreeNode("AAC"));
    s1.add(new DefaultMutableTreeNode("AEV"));
    s1.add(new DefaultMutableTreeNode("ANG"));
    s1.add(new DefaultMutableTreeNode("ASE"));
    s1.add(new DefaultMutableTreeNode("COA"));
    s1.add(new DefaultMutableTreeNode("PJE"));
    DefaultMutableTreeNode s2 = new DefaultMutableTreeNode("S2");
    m1.add(s2);
    s2.add(new DefaultMutableTreeNode("CAR"));
    s2.add(new DefaultMutableTreeNode("PJI"));
    s2.add(new DefaultMutableTreeNode("AeA"));
    s2.add(new DefaultMutableTreeNode("BDA"));
    s2.add(new DefaultMutableTreeNode("CALP"));
    s2.add(new DefaultMutableTreeNode("FDD"));
    s2.add(new DefaultMutableTreeNode("HECI"));
    s2.add(new DefaultMutableTreeNode("IHM"));
    s2.add(new DefaultMutableTreeNode("M3DS"));
    s2.add(new DefaultMutableTreeNode("PAC"));
    s2.add(new DefaultMutableTreeNode("PPD"));
    s2.add(new DefaultMutableTreeNode("RdF"));
    s2.add(new DefaultMutableTreeNode("SVL"));
    s2.add(new DefaultMutableTreeNode("TI"));
    JTree tree = new JTree(m1);
    // tree.setDragEnabled(true);
    JScrollPane jscrollTree = new JScrollPane(tree);
    jscrollTree.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTree"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jscrollTree.setPreferredSize(new Dimension(200, 200));

    // JTable
    String[] columnNames = {"S1", "S2"};
    Object[][] data2 = {
      {"AAC", "CAR"},
      {"AEV", "PJI"},
      {"ANG", "AeA"},
      {"ASE", "BDA"},
      {"COA", "CALP"},
      {"PJE", "FDD"},
      {"", "HECI"},
      {"", "IHM"},
      {"", "M3DS"},
      {"", "PAC"},
      {"", "PPD"},
      {"", "RdF"},
      {"", "SVL"},
      {"", "TI"}
    };

    JTable table = new JTable(data2, columnNames);
    JScrollPane scrollPaneTable = new JScrollPane(table);
    table.setDragEnabled(true);

    // JFileChooser
    JFileChooser fc = new JFileChooser();
    fc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFileChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    fc.setDragEnabled(true);

    panelgauche.add(textField);
    panelgauche.add(passwordField);
    panelgauche.add(ftf);
    panelgauche.add(jta);
    panelgauche.add(cc);
    panelgauche.add(editorScrollPane);
    fen.getContentPane().add(panelgauche);

    paneldroit.add(fc);
    paneldroit.add(jscrollListe);
    paneldroit.add(jscrollTree);
    paneldroit.add(scrollPaneTable);

    fen.getContentPane().add(paneldroit);

    fen.pack();
    fen.setVisible(true);
  }
コード例 #24
0
  private void initComponents() {
    final TitledBorder border = BorderFactory.createTitledBorder(label);
    final Font titleFont = border.getTitleFont();
    if (titleFont != null) {
      border.setTitleFont(titleFont.deriveFont(Font.BOLD));
    }
    setBorder(border);

    jtext = new JTextField();
    // jtext.setText(defalt.getFile().getPath());
    jRelativneKProgramu = new JCheckBox("Relativně k umístění programu");
    jRelativneKProgramu.setEnabled(FConst.JAR_DIR_EXISTUJE);
    jActive = new JCheckBox("Aktivní");
    jActive.setEnabled(lzeDeaktivovat);
    jCurrVal = new JTextField();
    jCurrVal.setForeground(Color.BLUE);
    jCurrVal.setEditable(false);
    jCurrVal.setBorder(null);
    final JButton jbut = new JButton("...");
    // jtext.setText(defalt.getFile().getPath());
    jtext.setColumns(50);
    if (editovatelne) {
      final Box box2 = Box.createHorizontalBox();
      box2.setAlignmentX(LEFT_ALIGNMENT);
      box2.add(jtext);
      box2.add(jbut);
      final Box panel3 = Box.createHorizontalBox();
      if (FConst.JAR_DIR_EXISTUJE) {
        panel3.add(jRelativneKProgramu);
      }
      if (jActive.isEnabled()) {
        panel3.add(jActive);
      }
      if (panel3.getComponentCount() > 0) {
        add(panel3);
      }
      panel3.setAlignmentX(LEFT_ALIGNMENT);
      add(box2);
    }
    // panel.add(Box.createVerticalStrut(20));
    jCurrVal.setAlignmentX(LEFT_ALIGNMENT);
    add(jCurrVal);
    // add(panel);
    // add(Box.createVerticalStrut(20));
    jbut.addActionListener(
        new ActionListener() {
          private JFileChooser fc;

          @Override
          public void actionPerformed(final ActionEvent ae) {
            if (fc == null) { // dlouho to trvá, tak vytvoříme vždy nový
              fc = new JFileChooser();
            }
            fc.setCurrentDirectory(new File(jtext.getText()));
            if (jenAdresare) {
              fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            }
            final int result = fc.showDialog(JJedenSouborPanel.this, "Vybrat");
            if (result == JFileChooser.APPROVE_OPTION) {
              jtext.setText(fc.getSelectedFile().getPath());
            }
          }
        });

    prepocitej();
    jtext.getDocument().addDocumentListener(this);

    jRelativneKProgramu.addActionListener(e -> prepocitej());
    jActive.addActionListener(e -> prepocitej());
  }
コード例 #25
0
  public GUI() {

    // Frame
    frame = new JFrame("HardwareSwap Notifier");

    // Panels
    panel = new JPanel();
    group1 = new JPanel();
    group2 = new JPanel();
    group3 = new JPanel();
    group4 = new JPanel();
    group5 = new JPanel();
    group6 = new JPanel();
    group7 = new JPanel();
    group8 = new JPanel();

    // Menu Bar
    menus = new JMenuBar();
    fileMenu = new JMenu("File");
    clearCurrent = new JMenuItem("Clear");
    quitItem = new JMenuItem("Quit");
    load = new JMenuItem("Load");
    saveCurrent = new JMenuItem("Save All");
    clearSaved = new JMenuItem("Clear Saved");
    removeItem = new JMenuItem("Remove Item");
    removePhone = new JMenuItem("Remove Phone");
    saveCurrent = new JMenuItem("Save Current");
    helpMenu = new JMenu("Help");
    help = new JMenuItem("How To Use");
    about = new JMenuItem("About");

    // Buttons
    add1 = new JButton("Add");
    add2 = new JButton("Add");
    start = new JButton("Start");
    stop = new JButton("Stop");
    save1 = new JButton("Add/Save");
    save2 = new JButton("Add/Save");
    show = new JButton("Display Data");

    add1.setFocusPainted(false);
    add2.setFocusPainted(false);
    start.setFocusPainted(false);
    stop.setFocusPainted(false);
    save1.setFocusPainted(false);
    save2.setFocusPainted(false);
    show.setFocusPainted(false);

    stop.setEnabled(false);

    // CheckBox
    remove = new JCheckBox("Remove items when found");
    remove.setFocusable(false);

    // Listener
    ButtonListener listener = new ButtonListener();

    add1.addActionListener(listener);
    add2.addActionListener(listener);
    start.addActionListener(listener);
    stop.addActionListener(listener);
    load.addActionListener(listener);
    save1.addActionListener(listener);
    save2.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    show.addActionListener(listener);
    quitItem.addActionListener(listener);
    clearCurrent.addActionListener(listener);
    clearSaved.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    help.addActionListener(listener);
    about.addActionListener(listener);
    removePhone.addActionListener(listener);
    removeItem.addActionListener(listener);
    remove.addActionListener(listener);

    // Carrier Selection
    options = new String[10];
    options[0] = "AT&T";
    options[1] = "Boost Mobile";
    options[2] = "Cellular One";
    options[3] = "Nextel";
    options[4] = "T-Mobile";
    options[5] = "Tracfone";
    options[6] = "US Cellular";
    options[7] = "Sprint";
    options[8] = "Verizon";
    options[9] = "Virgin Mobile";

    carriers = new JComboBox<String>(options);

    // Text Fields
    searchName = new JTextField(15);
    item = new JTextField(15);
    phone = new JTextField(15);
    interval2 = new JTextField(15);
    results = new JTextArea(10, 20);

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

    // Interval
    intOptions = new SpinnerNumberModel(5, 1, 60, 1);
    interval = new JSpinner(intOptions);
    JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField();
    tf.setHorizontalAlignment(JFormattedTextField.LEFT);

    // Background
    panelBackground = new Color(237, 237, 237);

    panel.setBackground(panelBackground);
    searchName.setBackground(panelBackground);
    item.setBackground(panelBackground);
    phone.setBackground(panelBackground);
    interval.setBackground(panelBackground);

    // Panel Layouts
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS));
    group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS));
    group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS));
    group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS));
    group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS));
    group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS));
    group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS));
    group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS));

    // Borders
    searchName.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Search Name",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    item.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Item",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    phone.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Cell Phone",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    group5.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Check Interval (mins)",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));

    // Sizes
    panel.setPreferredSize(new Dimension(200, 0));
    searchName.setMaximumSize(new Dimension(190, 50));
    item.setMaximumSize(new Dimension(190, 50));
    phone.setMaximumSize(new Dimension(185, 50));
    carriers.setMaximumSize(new Dimension(175, 20));
    group5.setPreferredSize(new Dimension(190, 47));
    group5.setMaximumSize(new Dimension(190, 47));

    add1.setMaximumSize(new Dimension(90, 20));
    save1.setMaximumSize(new Dimension(90, 20));
    add2.setMaximumSize(new Dimension(90, 20));
    save2.setMaximumSize(new Dimension(90, 20));
    start.setMaximumSize(new Dimension(90, 20));
    stop.setMaximumSize(new Dimension(90, 20));
    show.setMaximumSize(new Dimension(120, 20));

    // Add file menu items
    fileMenu.add(clearCurrent);
    fileMenu.add(clearSaved);
    fileMenu.add(load);
    fileMenu.add(removeItem);
    fileMenu.add(removePhone);
    fileMenu.add(saveCurrent);
    fileMenu.add(quitItem);

    // Add help menu items
    helpMenu.add(help);
    helpMenu.add(about);

    // Add to menu bar
    menus.add(fileMenu);
    menus.add(helpMenu);

    // Add items to panel
    group1.add(searchName);
    group1.add(item);

    group2.add(add1);
    group2.add(Box.createHorizontalStrut(10));
    group2.add(save1);

    group6.add(remove);

    group3.add(phone);
    group3.add(Box.createVerticalStrut(10));
    group3.add(carriers);

    group4.add(add2);
    group4.add(Box.createHorizontalStrut(10));
    group4.add(save2);

    group5.add(interval);

    group7.add(show);

    group8.add(start);
    group8.add(Box.createHorizontalStrut(10));
    group8.add(stop);

    panel.add(Box.createVerticalStrut(10));
    panel.add(group1);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group2);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group3);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group4);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group5);
    panel.add(Box.createVerticalStrut(30));
    panel.add(group6);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group7);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group8);
    panel.add(Box.createVerticalStrut(10));

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }
コード例 #26
0
ファイル: CantorPanel.java プロジェクト: FlatmateProject/test
  private void create() {
    setBounds(0, 0, getWidth(), getHeight());
    setLayout(null);
    setMinimumSize(new Dimension(800, 600));
    setBackground(bgColor);
    setVisible(true);

    cantorPESJta = new JTextField("");

    cantorTable = createTable(cantor.createCurrencyTable());
    cantorScrollPane = new JScrollPane();
    cantorScrollPane.setBorder(border);
    cantorScrollPane.setViewportView(cantorTable);

    cantorScrollClientPane = new JScrollPane();
    cantorScrollClientPane.setBorder(border);

    cantorTable = new JTable();
    cantorClientTable = new JTable();
    cantorBuyLabel = new JLabel("Dostepność oraz kursy walut");
    cantorCurrL1 = new JLabel("Waluta wymieniana");
    cantorCurrL2 = new JLabel("Waluta ");
    cantorClientL = new JLabel("PESEL/KRS Klienta");
    cantorAmountJta = new JTextField("");
    cantorCostJta = new JTextField("");

    cantorAmountJta.setBorder(border);
    cantorCostJta.setBorder(border);
    cantorPESJta.setBorder(border);

    cantorPrice = new JLabel("Kwota transakcji:");
    cantorCostLabel = new JLabel("Do zap�aty:");

    cantorCurrBox1 = new JComboBox(CURRENCY.values());
    cantorCurrBox2 = new JComboBox(CURRENCY.values());
    cantorResButton = new JButton("Przelicz");
    cantorPESButton = new JButton("Szukaj");
    cantorDoIt = new JButton("Dokonaj transakcji");
    cantorResButton.setBackground(buttonColor);
    cantorPESButton.setBackground(buttonColor);
    cantorDoIt.setBackground(buttonColor);

    resizeCantor(getWidth(), getHeight());

    add(cantorPESJta);
    add(cantorPrice);
    add(cantorAmountJta);
    add(cantorCostJta);
    add(cantorTable);
    add(cantorClientTable);
    add(cantorCostLabel);
    add(cantorBuyLabel);
    add(cantorCurrL1);
    add(cantorCurrL2);
    add(cantorClientL);
    add(cantorPrice);
    add(cantorPay);
    add(cantorCurrBox1);
    add(cantorCurrBox2);
    add(cantorResButton);
    add(cantorPESButton);
    add(cantorDoIt);
    add(cantorScrollPane);
    add(cantorScrollClientPane);
  }
コード例 #27
0
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 2));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(4, 2, 3, 3));
    this.setLayout(new GridLayout(2, 1, 3, 3));
    this.add(firstPanel);

    proxyStackNameLabel = new JLabel("Proxy stack name:");
    proxyStackNameLabel.setToolTipText("The name of the stack to set");
    // Alignment of the text
    proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyStackNameLabel.setForeground(Color.black);
    // Size of the text
    proxyStackNameLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyStackNameLabel.setOpaque(true);
    proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder);
    proxyStackNameTextField = new JTextField(20);
    proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyStackNameTextField.setFont(new Font("Dialog", 0, 14));
    proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyStackNameTextField.setForeground(Color.black);
    proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyStackNameLabel);
    firstPanel.add(proxyStackNameTextField);

    proxyIPAddressLabel = new JLabel("Proxy IP address:");
    proxyIPAddressLabel.setToolTipText("The address of the proxy to set");
    // Alignment of the text
    proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyIPAddressLabel.setForeground(Color.black);
    // Size of the text
    proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyIPAddressLabel.setOpaque(true);
    proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder);
    proxyIPAddressTextField = new JTextField(20);
    proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14));
    proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyIPAddressTextField.setForeground(Color.black);
    proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyIPAddressLabel);
    firstPanel.add(proxyIPAddressTextField);

    outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):");
    outboundProxyLabel.setToolTipText(
        "Location where the message will be sent "
            + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied");
    // Alignment of the text
    outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    outboundProxyLabel.setForeground(Color.black);
    // Size of the text
    outboundProxyLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    outboundProxyLabel.setOpaque(true);
    outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    outboundProxyLabel.setBorder(ProxyLauncher.labelBorder);
    outboundProxyTextField = new JTextField(20);
    outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER);
    outboundProxyTextField.setFont(new Font("Dialog", 0, 14));
    outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor);
    outboundProxyTextField.setForeground(Color.black);
    outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(outboundProxyLabel);
    firstPanel.add(outboundProxyTextField);

    routerClassLabel = new JLabel("The Router class name:");
    routerClassLabel.setToolTipText(
        "The class name (full java package name) of the router" + " used to forward the messages");
    // Alignment of the text
    routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    routerClassLabel.setForeground(Color.black);
    // Size of the text
    routerClassLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    routerClassLabel.setOpaque(true);
    routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    routerClassLabel.setBorder(ProxyLauncher.labelBorder);
    routerClassTextField = new JTextField(20);
    routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER);
    routerClassTextField.setFont(new Font("Dialog", 0, 12));
    routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor);
    routerClassTextField.setForeground(Color.black);
    routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(routerClassLabel);
    firstPanel.add(routerClassTextField);

    JPanel panel = new JPanel();
    // top, left, bottom, right
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2));
    // If put to False: we see the container's background
    panel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    panel.setLayout(new BorderLayout());
    this.add(panel);

    JLabel lpLabel = new JLabel("Listening points list:");
    lpLabel.setVisible(true);
    lpLabel.setToolTipText("The listening points of the proxy");
    lpLabel.setHorizontalAlignment(AbstractButton.CENTER);
    lpLabel.setForeground(Color.black);
    lpLabel.setFont(new Font("Dialog", 1, 12));
    lpLabel.setOpaque(true);
    lpLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    lpLabel.setBorder(ProxyLauncher.labelBorder);
    panel.add(lpLabel, BorderLayout.NORTH);

    // this.add(listeningPointsList);
    JScrollPane scrollPane =
        new JScrollPane(
            listeningPointsList,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel.add(scrollPane, BorderLayout.CENTER);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0));
    thirdPanel.setLayout(new GridLayout(1, 2, 3, 3));

    JButton addLPButton = new JButton(" Add ");
    addLPButton.setToolTipText("Add a listening point");
    addLPButton.setFocusPainted(false);
    addLPButton.setFont(new Font("Dialog", 1, 16));
    addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    addLPButton.setBorder(ProxyLauncher.buttonBorder);
    addLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            addLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(addLPButton);

    JButton removeLPButton = new JButton(" Remove ");
    removeLPButton.setToolTipText("Remove a listening point");
    removeLPButton.setFocusPainted(false);
    removeLPButton.setFont(new Font("Dialog", 1, 16));
    removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    removeLPButton.setBorder(ProxyLauncher.buttonBorder);
    removeLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            removeLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(removeLPButton);

    panel.add(thirdPanel, BorderLayout.SOUTH);
  }
コード例 #28
0
ファイル: ServerDialog.java プロジェクト: chaddiller/turbovnc
  public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) {

    super(true);
    cc = cc_;
    opts = opts_;

    options = options_;

    JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT);
    String valueStr = null;
    if (opts.serverName != null) {
      String[] s = new String[1];
      s[0] = opts.serverName;
      server = new JComboBox(s);
    } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) {
      server = new JComboBox(valueStr.split(","));
    } else {
      server = new JComboBox();
    }

    // Hack to set the left inset on editable JComboBox
    if (UIManager.getLookAndFeel().getID() == "Windows") {
      server.setBorder(
          BorderFactory.createCompoundBorder(
              server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0)));
    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
      ComboBoxEditor editor = server.getEditor();
      JTextField jtf = (JTextField) editor.getEditorComponent();
      jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0)));
    }

    server.setEditable(true);
    editor = server.getEditor();
    editor
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              public void keyTyped(KeyEvent e) {}

              public void keyReleased(KeyEvent e) {}

              public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                  server.insertItemAt(editor.getItem(), 0);
                  server.setSelectedIndex(0);
                  commit();
                  endDialog();
                }
              }
            });

    topPanel = new JPanel(new GridBagLayout());

    Dialog.addGBComponent(
        new JLabel(VncViewer.logoIcon),
        topPanel,
        0,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_START,
        new Insets(5, 5, 5, 15));
    Dialog.addGBComponent(
        serverLabel,
        topPanel,
        1,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_END,
        new Insets(10, 0, 5, 5));
    Dialog.addGBComponent(
        server,
        topPanel,
        2,
        0,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(10, 0, 5, 20));

    optionsButton = new JButton("Options...");
    aboutButton = new JButton("About...");
    okButton = new JButton("Connect");
    cancelButton = new JButton("Cancel");
    buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setPreferredSize(new Dimension(350, 40));
    Dialog.addGBComponent(
        aboutButton,
        buttonPanel,
        0,
        3,
        1,
        1,
        0,
        0,
        0.8,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        optionsButton,
        buttonPanel,
        1,
        3,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        okButton,
        buttonPanel,
        2,
        3,
        1,
        1,
        0,
        0,
        0.7,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        cancelButton,
        buttonPanel,
        3,
        3,
        1,
        1,
        0,
        0,
        0.6,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));

    server.addActionListener(this);
    optionsButton.addActionListener(this);
    aboutButton.addActionListener(this);
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
  }
コード例 #29
0
  /** 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}));
  }
コード例 #30
0
ファイル: username.java プロジェクト: anuj1708/Practice
  public void actionPerformed(ActionEvent e) {
    p2.str1 = fn1.getText();
    p2.str2 = ln1.getText();
    p2.str3 = un1.getText();
    p2.str4 = ps11.getText();
    p2.str5 = eid1.getText();
    p2.str6 = ps21.getText();
    p2.str7 = mb1.getText();
    p2.str8 = cct1.getText();
    p2.str9 = hquali1.getText();
    p2.str10 = dober1.getText();
    p2.str11 = dober2.getText();
    p2.str12 = dober3.getText();
    p2.str13 = p2.str10 + "/" + p2.str11 + "/" + p2.str12;

    boolean bl1, bl2, bl3, bl4, bl5, bl6, bl7, bl8, bl9;
    bl1 = false;
    bl2 = false;
    bl3 = false;
    bl4 = false;
    bl5 = false;
    bl6 = false;
    bl7 = false;
    bl8 = false;

    if (str1.length() > 0) {
      // er1.setForeground(null);
      er1.setText("");
      fn1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl1 = true;
      repaint();
    } else {
      er1.setForeground(Color.red);
      er1.setText("(First name can't be null)");
      fn1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }

    if (str3.length() > 0) {
      er3.setText("");
      un1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl2 = true;
      repaint();

    } else {
      er3.setForeground(Color.red);
      er3.setText("(Username can't be null)");
      un1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }

    if (str5.length() > 0) {
      er6.setText("");
      eid1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl3 = true;
      repaint();

    } else {
      er6.setForeground(Color.red);
      er6.setText("(email id can't be null)");
      eid1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }

    if (str4.length() > 0) {
      er4.setText("");
      ps11.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl4 = true;
      repaint();

    } else {
      er4.setForeground(Color.red);
      er4.setText("(Password can't be null)");
      ps11.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }

    if ((str4.equals(str6))) {
      str6 = str4;
      er5.setForeground(null);
      er5.setText("");
      ps21.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl5 = true;
      repaint();

    } else {
      er5.setForeground(Color.red);
      er5.setText("(both pwd should be same)");
      ps21.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }
    if (str7.length() == 10) {
      er7.setText("");
      mb1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl6 = true;
      repaint();

    } else {
      er7.setForeground(Color.red);
      er7.setText("(number should be of 10 digit)");
      mb1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }
    if (str8.length() > 0) {
      er8.setText("");
      cct1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl7 = true;
      repaint();

    } else {
      er8.setForeground(Color.red);
      er8.setText("(Current City can't be null)");
      cct1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }
    if (str9.length() > 0) {
      er9.setText("");
      hquali1.setBorder(BorderFactory.createLineBorder(Color.GRAY));
      bl8 = true;
      repaint();

    } else {
      er9.setForeground(Color.red);
      er9.setText("(Highest Qualif. can't be null)");
      hquali1.setBorder(BorderFactory.createLineBorder(Color.red));
      repaint();
    }

    try {
      if ((bl1 && bl2 && bl3 && bl4 && bl5 && bl6 && bl7 && bl8) == true) {
        JOptionPane.showMessageDialog(null, "Data submitting ");
        p2.goer();
      }
    } catch (Exception e3) {
    }
  }