예제 #1
0
    @Override
    public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub

      Object source = e.getSource();
      if (source == ok) {
        response = APPLY_OPTION;
        this.setVisible(false);
      } else if (source == cancel) {
        response = CANCEL_OPTION;
        this.setVisible(false);
      } else if (source == sizeCombo) {
        // get the number from the source
        JComboBox number = (JComboBox) source;
        String numberItem = (String) number.getSelectedItem();
        Font temp = example.getFont();
        // then set the font
        int newSize = Integer.parseInt(numberItem);
        example.setFont(new Font(temp.getFamily(), temp.getStyle(), newSize));
      } else if (source == fontCombo) {
        JComboBox font = (JComboBox) source;
        String s = (String) font.getSelectedItem();
        Font tmp = example.getFont();
        example.setFont(new Font(s, tmp.getStyle(), tmp.getSize()));
      } else if (source == foreground) {
        Color tmp = JColorChooser.showDialog(this, "Choose text color", example.getForeground());
        MenuBar.shapeLBG.setBackground(tmp);
        if (tmp != null) example.setForeground(tmp);
      }
    }
  /**
   * Create the pixel location panel
   *
   * @param labelFont the font for the labels
   * @return the location panel
   */
  public JPanel createLocationPanel(Font labelFont) {

    // create a location panel
    JPanel locationPanel = new JPanel();
    locationPanel.setLayout(new FlowLayout());
    Box hBox = Box.createHorizontalBox();

    // create the labels
    rowLabel = new JLabel("Row:");
    colLabel = new JLabel("Column:");

    // create the text fields
    colValue = new JTextField(Integer.toString(colIndex + numberBase), 6);
    colValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });
    rowValue = new JTextField(Integer.toString(rowIndex + numberBase), 6);
    rowValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });

    // set up the next and previous buttons
    setUpNextAndPreviousButtons();

    // set up the font for the labels
    colLabel.setFont(labelFont);
    rowLabel.setFont(labelFont);
    colValue.setFont(labelFont);
    rowValue.setFont(labelFont);

    // add the items to the vertical box and the box to the panel
    hBox.add(Box.createHorizontalGlue());
    hBox.add(rowLabel);
    hBox.add(rowPrevButton);
    hBox.add(rowValue);
    hBox.add(rowNextButton);
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(colLabel);
    hBox.add(colPrevButton);
    hBox.add(colValue);
    hBox.add(colNextButton);
    locationPanel.add(hBox);
    hBox.add(Box.createHorizontalGlue());

    return locationPanel;
  }
  /*
   * The following method creates the textfield to change the text
   *     and the button to update the label.
   * postcondition: returns the panel containing the textfield and button.
   */
  public JPanel createUpdateButton() {
    JLabel textLabel = new JLabel(new String("Change text to: "));

    textField = new JTextField(new String("Big Java"), 20);
    textField.setFont(new Font(("Times"), Font.PLAIN, 12));

    update = new JButton(new String("Update"));
    update.setDefaultCapable(true);

    // This class is used to create a special ActionListener for this menu item
    class ButtonListener implements ActionListener {
      /*
       * This method is called when the update button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        // Call the method to change the text on the screen.
        setSampleFont();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    update.addActionListener(listener);

    JPanel panel = new JPanel();

    panel.add(textLabel);
    panel.add(textField);
    panel.add(update);

    return panel;
  } // end createUpdateButton method
  public SurrenderUI() {
    setType(Type.UTILITY);

    ExitB = new JButton("Exit");
    ExitB.setFont(new Font("Tahoma", Font.BOLD, 12));
    ExitB.setBackground(new Color(255, 215, 0));
    ExitB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
            new HSmain();
          }
        });
    ExitB.setBounds(461, 427, 296, 60);

    setTitle("Surrendering a Pet");
    Container pane = getContentPane();
    getContentPane().setLayout(null);
    pane.add(ExitB);

    txtSurrender = new JTextField();
    txtSurrender.setEditable(false);
    txtSurrender.setForeground(new Color(0, 0, 0));
    txtSurrender.setBackground(new Color(255, 215, 0));
    txtSurrender.setBounds(10, 11, 764, 50);
    txtSurrender.setHorizontalAlignment(SwingConstants.CENTER);
    txtSurrender.setFont(new Font("Lucida Handwriting", Font.BOLD, 18));
    txtSurrender.setText("Surrendering a Pet");
    getContentPane().add(txtSurrender);
    txtSurrender.setColumns(10);

    BackB = new JButton("Back");
    BackB.setFont(new Font("Tahoma", Font.BOLD, 12));
    BackB.setBackground(new Color(255, 215, 0));
    BackB.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new AnimalServiceUI();
            dispose();
          }
        });
    BackB.setBounds(26, 427, 320, 60);
    getContentPane().add(BackB);

    scrollPane = new JScrollPane();
    scrollPane.setBounds(0, 72, 764, 329);
    getContentPane().add(scrollPane);

    JTextPane txtSurrenderInfo = new JTextPane();
    scrollPane.setViewportView(txtSurrenderInfo);
    txtSurrenderInfo.setForeground(new Color(0, 0, 0));
    txtSurrenderInfo.setEditable(false);
    txtSurrenderInfo.setFont(new Font("Times New Roman", Font.BOLD, 15));
    txtSurrenderInfo.setText(
        "\tThe Humane Society of Lamar cannot accept every animal brought to our shelter immediately. \r\nWe respect the difficult decision of owners to relinquish their pets, and the hard choices of those \r\ngood citizens who are trying to help a stray. We accept the surrender of pets as space allows. \r\nWe maintain a waiting list for all animals needing to be admitted to the shelter.\r\nAnimals are surrendered to our facility by appointment.\r\nWe admit at least 12 animals per week. We accept more animals as adoptions and space allow.\r\nNote that we cannot accept aggressive, sick or pregnant animals.\r\nPlease call 409-225-7981, and one of our adoption specialists will speak to you.\r\nAt times our waiting list will have up to 100 animals waiting for admission and it can take several weeks \r\nbefore we can admit your pet.\r\nPlease understand that our primary goal is to place as many animals in forever homes as possible, \r\ntherefore we must give every pet admitted to the shelter enough time to find a loving home. \r\nWe cannot guarantee placement of every animal admitted to the shelter.\r\n\t\r\n\tAdmission of any animal into the Humane Society of Lamar  is based on the animal\u2019s health, \r\nbehavior, and adoptability. When you bring your pets, please have:\r\n\r\n    *Any veterinary records\r\n    *Your pet\u2019s medications\r\n    *Special food or treats that your pet needs\r\n    *Your pet\u2019s bed, toys, leash and other belongings from home\r\n\r\nA staff member will evaluate the temperament of your pet. Once your pet has been screened, \r\nand the Humane Society of Lamar decides to accept your pet, we ask a donation to our shelter to be made. \r\nThis is not required, but will greatly help us care for your pet.");

    setSize(800, 553);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
예제 #5
0
  public RFIDGUI() {

    setLayout(new FlowLayout());
    // label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement);
    Question.setFont(new Font("Serif", Font.BOLD, 18));
    // Points.setFont(new Font("Serif", Font.BOLD, 50));
    // Question.setBounds(300, 250, 900, 300);
    // Points.setBounds(1200, 600, 300, 200);

    // Points.setHorizontalAlignment(JTextField.RIGHT);
    // Points.set
    Question.setForeground(Color.blue);
    // Points.setForeground(Color.red);
    add(Question);
    // Question.validate();
    // add(Points, BorderLayout.SOUTH);
    // Points.validate();
    // Question.setLocation(0, 0);
    // Points.setLocation(1600,900);

    /*while(count<70){
    //secondDoneYet = false;
    while (!secondDoneYet) {
    	//label = new JTextField(ThreadTwoTestTwo.randomQuestionStatement);
    	label.repaint();
    	secondDoneYet = true;
    	count++;

    	/*
    	 * while(ThreadTwoTestTwo.amountOfQuestions <=60){
    	 * label.repaint(); }
    	 */
  }
예제 #6
0
  public RoxSplash(Frame f, String initString) {
    super(f);

    jt.setFont(new Font("Verdana", Font.PLAIN, 9));
    jt.setText(initString);

    getContentPane().add(painel, BorderLayout.CENTER);
    getContentPane().add(jt, BorderLayout.SOUTH);

    pack();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setSize(500, 310);

    setLocation(screenSize.width / 2 - 250, screenSize.height / 2 - 150);

    Runnable waitRunner =
        new Runnable() {
          public void run() {
            try {
              Thread.sleep(10);
            } catch (Exception e) {
            }
          }
        };
    setVisible(true);
    Thread splashThread = new Thread(waitRunner, "RoxSplash");
    splashThread.start();
  }
예제 #7
0
  // methods
  public void updateMessage() {
    messageField.setText(message);
    messageField.setFont(messageFont);
    messageField.setForeground(foreground);
    messageField.setBackground(background);
    // tt = messageField.getText();

  }
예제 #8
0
 private JTextField initializeGoToTextField() {
   JTextField textField = new JTextField();
   textField.setFont(new Font("Arial", Font.ITALIC, 10));
   textField.setEnabled(false);
   textField.addActionListener(this);
   textField.addFocusListener(this);
   return textField;
 }
  private BindCardWithSidWindow() {

    int width = 230;
    int height = 190;

    setLayout(null);
    setBounds(
        (Utilities.getScreenWidth() - width) / 2,
        (Utilities.getScreenHeight() - height) / 2,
        width,
        height);
    setAlwaysOnTop(true);
    setResizable(false);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JLabel cardPromptLbl = new JLabel("卡号:");
    cardPromptLbl.setFont(new Font("Courier New", 0, 15));
    cardPromptLbl.setBounds(30, 20, 50, 30);
    add(cardPromptLbl);

    JLabel sidPromptLbl = new JLabel("学号:");
    sidPromptLbl.setFont(new Font("Courier New", 0, 15));
    sidPromptLbl.setBounds(30, 50, 50, 30);
    add(sidPromptLbl);

    cardLbl = new JLabel("");
    cardLbl.setBackground(Color.blue);
    cardLbl.setFont(new Font("黑体", 0, 15));
    cardLbl.setHorizontalAlignment(JLabel.CENTER);
    cardLbl.setBounds(80, 20, 120, 30);
    add(cardLbl);

    sidField = new JTextField("");
    sidField.setHorizontalAlignment(JTextField.CENTER);
    sidField.setFont(new Font("黑体", 0, 15));
    sidField.setBounds(80, 50, 120, 30);
    add(sidField);

    confirmBtn = new JButton("确定");
    confirmBtn.setBounds(75, 100, 80, 40);
    confirmBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            String text = sidField.getText();

            setVisible(false);

            if (text.length() != 0) {

              CardDatabase.bindCardWithStudent(cardLbl.getText(), text);
            }
          }
        });
    add(confirmBtn);
  }
예제 #10
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")));
  }
예제 #11
0
파일: Css.java 프로젝트: k9m/simplechat
  public static JTextField getTextField(int size) {
    JTextField component = new JTextField(size);
    component.setBackground(BACKGROUND_COLOR_TXTA);
    component.setForeground(TEXT_COLOR_TXTA);

    component.setFont(FONT_TYPE_TXTA);

    return component;
  }
예제 #12
0
  /** Affichage en mode GUI. */
  public void drawGUI() {
    panel.removeAll();
    // panel.updateUI();

    JLabel label = new JLabel("Choix pseudo joueurs");
    label.setFont(new Font("Serif", Font.BOLD, 22));
    panel.add(label);

    JLabel j1 = new JLabel("Joueur 1");
    j1.setFont(new Font("Serif", Font.PLAIN, 16));
    panel.add(j1);

    pseudoJ1 = new JTextField();
    pseudoJ1.setFont(new Font("Serif", Font.PLAIN, 16));
    pseudoJ1.setPreferredSize(new Dimension(150, 30));
    pseudoJ1.setForeground(Color.BLACK);

    panel.add(pseudoJ1);

    // Si on ne joue pas contre une IA, on demande au joueur 2 son pseudo aussi
    if (this.jeu.getTypeJeu() != Jeu.TYPE_JOUEUR_VS_IA) {
      JLabel j2 = new JLabel("Joueur 2");
      j2.setFont(new Font("Serif", Font.PLAIN, 16));
      panel.add(j2);

      pseudoJ2 = new JTextField();
      pseudoJ2.setFont(new Font("Serif", Font.PLAIN, 16));
      pseudoJ2.setPreferredSize(new Dimension(150, 30));
      pseudoJ2.setForeground(Color.BLACK);

      panel.add(pseudoJ2);
    }

    boutonOK = new JButton("Ok");
    boutonOK.addActionListener(this);
    panel.add(boutonOK);

    window.setContentPane(panel);
    window.pack();
    window.setVisible(true);
  }
예제 #13
0
  private void jbInit() throws Exception {
    // this.setResizable(false);
    this.setSize(ancho, alto);
    this.setLocation(0, 0);

    // this.setUndecorated(true);
    // this.getContentPane().setLayout(null);

    // limites de componentes
    labelFondo.setBounds(
        new Rectangle((int) (ancho / 5), 2 * (alto / 6), (int) (ancho / 1.5), alto / 4));
    botonCancelar.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonCancelar.setBorder(null);
    // botonAceptar.setBounds(new Rectangle(0, 0, 100, 30));
    botonAceptar.setBounds(
        new Rectangle(
            (int) (2.15 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonAceptar.setBorder(null);
    textNombre.setFont(new java.awt.Font("Serif", 3, 15));
    textNombre.setBounds(
        new Rectangle((int) (2.5 * (ancho / 5)), (int) (1.5 * (alto / 4)), ancho / 5, alto / 25));
    textNombre.addKeyListener(new PanelNick_textNombre_keyAdapter(this));

    textContra.setFont(new java.awt.Font("Serif", 3, 15));
    textContra.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (1.65 * (alto / 4)) + 20, ancho / 8, alto / 25));

    // imagenes de componentes
    labelFondo.setIcon(new ImageIcon("../imagenes/introduceNick.jpg"));
    botonCancelar.setIcon(new ImageIcon("../imagenes/botoncancelar.jpg"));
    botonCancelar.addMouseListener(new PanelNick_botonCancelar_mouseAdapter(this));
    botonAceptar.setIcon(new ImageIcon("../imagenes/botonaceptar.jpg"));
    botonAceptar.addMouseListener(new PanelNick_botonAceptar_mouseAdapter(this));

    // agregar componentes al panel
    this.add(textContra, null);
    this.add(botonCancelar, null);
    this.add(botonAceptar, null);
    this.add(textNombre, null);
    this.add(labelFondo, null);

    // acciones de botones
    botonAceptar.addActionListener(new PanelNick_botonAceptar_actionAdapter(this));
    botonCancelar.addActionListener(new PanelNick_botonCancelar_actionAdapter(this));
  }
예제 #14
0
    @Override
    public void itemStateChanged(ItemEvent e) {
      // TODO Auto-generated method stub
      Object source = e.getSource();
      Font tmp = example.getFont();
      int style = tmp.getStyle();

      if (source == italic)
        if (italic.isSelected()) style = style | Font.ITALIC; // turn italic on
        else style = style & ~Font.ITALIC; // turn italic off
      else if (source == bold)
        if (bold.isSelected()) style = style | Font.BOLD; // turn bold on
        else style = style & ~Font.BOLD; // turn bold off

      example.setFont(new Font(tmp.getFamily(), style, tmp.getSize()));
    }
  /** 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();
  }
예제 #16
0
  public void startGui() {
    JTerminalListener listener = new JTerminalListener();

    jFrame = new JFrame("Glowstone");
    jTerminal = new JTerminal();
    jInput =
        new JTextField(80) {
          @Override
          public void setBorder(Border border) {}
        };
    jInput.paint(null);
    jInput.setFont(new Font("Monospaced", Font.PLAIN, 12));
    jInput.setBackground(Color.BLACK);
    jInput.setForeground(Color.WHITE);
    jInput.setMargin(new Insets(0, 0, 0, 0));
    jInput.addKeyListener(listener);

    JLabel caret = new JLabel("> ");
    caret.setFont(new Font("Monospaced", Font.PLAIN, 12));
    caret.setForeground(Color.WHITE);

    JPanel ipanel = new JPanel();
    ipanel.add(caret, BorderLayout.WEST);
    ipanel.add(jInput, BorderLayout.EAST);
    ipanel.setBorder(BorderFactory.createEmptyBorder());
    ipanel.setBackground(Color.BLACK);
    ipanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    ipanel.setSize(jTerminal.getWidth(), ipanel.getHeight());

    jFrame.getContentPane().add(jTerminal, BorderLayout.NORTH);
    jFrame.getContentPane().add(ipanel, BorderLayout.SOUTH);
    jFrame.addWindowListener(listener);
    jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    jFrame.setLocationRelativeTo(null);
    jFrame.pack();
    jFrame.setVisible(true);

    sender = new ColoredCommandSender();
    logger.removeHandler(consoleHandler);
    logger.addHandler(
        new StreamHandler(new TerminalOutputStream(), new DateOutputFormatter(CONSOLE_DATE)));
  }
예제 #17
0
  public void propertyChange(PropertyChangeEvent event) {
    debug(this + " " + "propertyChange: " + event.getSource() + " " + event.getPropertyName());

    if (event.getSource() == searchnav) {
      String changeName = event.getPropertyName();
      if (changeName.equals("helpModel")) {

        reloadData((HelpModel) event.getNewValue());

      } else if (changeName.equals("font")) {
        debug("Font change");
        Font newFont = (Font) event.getNewValue();
        searchparams.setFont(newFont);
        RepaintManager.currentManager(searchparams).markCompletelyDirty(searchparams);
        tree.setFont(newFont);
        RepaintManager.currentManager(tree).markCompletelyDirty(tree);
      }
      // changes to UI property?
    }
  }
예제 #18
0
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
예제 #19
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);
  }
예제 #20
0
파일: GUI.java 프로젝트: sametkaya/BLM305
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
예제 #21
0
    public int showCustomDialog(Frame f, Font fontArg, Color foreColorArg, Color backColorArg) {
      this.setLocationRelativeTo(f);

      String s = fontArg.getName();
      fontCombo.setSelectedItem((Object) s);

      int style = fontArg.getStyle();
      if ((style & Font.ITALIC) == 0) italic.setSelected(false);
      else italic.setSelected(true);
      if ((style & Font.BOLD) == 0) bold.setSelected(false);
      else bold.setSelected(true);

      int size = fontArg.getSize();
      sizeCombo.setSelectedItem((Object) ("" + size));

      example.setFont(fontArg);
      example.setForeground(MenuBar.shapeLBG.getBackground());

      // show the dialog

      this.setVisible(true);

      return response;
    }
  /** 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}));
  }
예제 #23
0
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    CARD_BACK.add(new CardPanel("img/cards/BACK.png"));

    // The code below is just for reference
    //        dealerCards = new ArrayList<>();
    //        for (int i = 0; i < dealerInHand.size(); i++)
    //        {
    //            dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png"));
    //        }
    //
    //        playerCardsOne = new ArrayList<>();
    //        for (int i = 0; i < playerInHandOne.size(); i++)
    //        {
    //            playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png"));
    //        }
    //
    //        playerCardsTwo = new ArrayList<>();
    //        for (int i = 0; i < playerInHandTwo.size(); i++)
    //        {
    //            playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png"));
    //        }
    // The code above is just for reference

    dealerDeckContainer = new CardDeckContainer();
    dealerStatContainer = new JPanel(new BorderLayout());
    dealerStatContainer.setOpaque(false);
    JLabel dealerStatTitle = new JLabel("Dealer in Hand");
    dealerStatTitle.setForeground(Color.WHITE);
    dealerStatTitle.setHorizontalAlignment(JLabel.CENTER);
    dealerStatTitle.setFont(new Font("", Font.PLAIN, 12));
    dealerStatPoint.setForeground(Color.WHITE);
    dealerStatPoint.setHorizontalAlignment(JLabel.CENTER);
    dealerStatPoint.setFont(new Font("", Font.PLAIN, 12));
    dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH);
    dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER);

    playerDeckOneContainer = new CardDeckContainer();
    playerStatOneContainer = new JPanel(new BorderLayout());
    playerStatOneContainer.setOpaque(false);
    JLabel playerStatOneTitle = new JLabel("Player in Hand");
    playerStatOneTitle.setForeground(Color.WHITE);
    playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatOnePoint.setForeground(Color.WHITE);
    playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatOneDescription.setForeground(Color.WHITE);
    playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH);
    playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER);
    playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH);

    playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK));
    playerStatTwoContainer = new JPanel(new BorderLayout());
    playerStatTwoContainer.setOpaque(false);
    JLabel playerStatTwoTitle = new JLabel("Player Hand 2");
    playerStatTwoTitle.setForeground(Color.WHITE);
    playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoPoint.setForeground(Color.WHITE);
    playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoDescription.setForeground(Color.WHITE);
    playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH);
    playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER);
    playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH);

    gameStatPanel = new JPanel();
    gameStatPanelPlayerName = new JLabel();
    gameStatPanelCurrentChips = new JLabel();
    gameStatPanelCurrentBet = new JLabel();
    gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelPlayerName.setForeground(Color.WHITE);
    gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5));
    gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentChips.setForeground(Color.WHITE);
    gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5));
    gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentBet.setForeground(Color.WHITE);
    gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0));
    gameStatPanel.add(gameStatPanelPlayerName);
    gameStatPanel.add(gameStatPanelCurrentChips);
    gameStatPanel.add(gameStatPanelCurrentBet);
    gameStatPanel.setOpaque(false);

    gameButtonPanel = new JPanel(cardLayout);
    betButtonPanel = new JPanel();
    playButtonPanel = new JPanel();
    JLabel pleaseBet = new JLabel("Please bet: ");
    pleaseBet.setFont(new Font("", Font.PLAIN, 14));
    pleaseBet.setForeground(Color.WHITE);
    betButtonPanel.add(pleaseBet);
    betField = new JTextField();
    betField.setFont(new Font("", Font.PLAIN, 14));
    betField.setPreferredSize(new Dimension(80, 28));
    betButtonPanel.add(betField);
    JButton betButton = new JButton("Bet");
    JButton backButton = new JButton("Back");
    betButtonPanel.add(betButton);
    betButtonPanel.add(backButton);
    betButtonPanel.setOpaque(false);

    hitButton = new JButton("Hit");
    standButton = new JButton("Stand");
    doubleButton = new JButton("Double");
    // JButton splitButton = new JButton("Split");
    // splitButton.setEnabled(false);
    playButtonPanel.add(hitButton);
    playButtonPanel.add(standButton);
    playButtonPanel.add(doubleButton);
    // playButtonPanel.add(splitButton);
    playButtonPanel.setOpaque(false);
    gameButtonPanel.add("betbutton", betButtonPanel);
    gameButtonPanel.add("playbutton", playButtonPanel);
    gameButtonPanel.setOpaque(false);

    add(gameStatPanel);
    add(dealerDeckContainer);
    add(playerDeckTwoContainer);
    add(playerDeckOneContainer);
    add(gameButtonPanel);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            Game.initGame();
          }
        });

    betButtonPanel.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            betField.setText("");
            if (BlackJack.player.getChip() <= 0) {
              JOptionPane.showMessageDialog(
                  null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE);
              User.deleteUserByName(BlackJack.player.getName());
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
            hitButton.setEnabled(true);
            standButton.setEnabled(true);
            doubleButton.setEnabled(true);
            BlackJack.player.setBet(0);
            BlackJack.player.getHandOne().clear();
            BlackJack.player.getHandTwo().clear();
            BlackJack.dealer.getHandOne().clear();
            GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName());
            GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip());
            GamePanel.gameStatPanelCurrentBet.setText("Bet: 0");
            GamePanel.gameStatPanel.repaint();
          }
        });

    betField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            int keyChar = e.getKeyChar();
            if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) {
              e.consume();
            }
          }
        });

    betButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Game.bet(Integer.parseInt(betField.getText()));
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choice =
                JOptionPane.showConfirmDialog(
                    null,
                    "Do you want to go back to main menu?\nYour record will be saved.",
                    "Go Back",
                    JOptionPane.YES_NO_OPTION);
            if (choice == JOptionPane.YES_OPTION) {
              User.updateUser();
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
          }
        });

    hitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doubleButton.setEnabled(false);
            Game.hit();
          }
        });

    standButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            playerStatOneDescription.setText("Stand");
            playerStatOneDescription.repaint();
            Game.dealerGame();
          }
        });

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }
예제 #24
0
  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {

    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(null);

    this.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    setSize(new Dimension(400, 621));
    setTitle("实时通讯模块测试程序");
    jButton1.setBounds(new Rectangle(11, 412, 82, 26));
    jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton1.setText("召测接口");
    jButton1.addActionListener(new RealTimeTestFrame_jButton1_actionAdapter(this));
    jButton2.setBounds(new Rectangle(10, 366, 83, 26));
    jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton2.setText("创建对象");
    jButton2.addActionListener(new RealTimeTestFrame_jButton2_actionAdapter(this));
    jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel1.setText("接入IP:");
    jLabel1.setBounds(new Rectangle(23, 22, 63, 16));
    jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel2.setText("接入端口:");
    jLabel2.setBounds(new Rectangle(23, 67, 63, 16));
    jTextField1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jTextField1.setText("172.19.74.13");
    txt_port.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_port.setText("3000");
    txt_port.setBounds(new Rectangle(84, 64, 88, 22));
    jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel3.setText("AppID:");
    jLabel3.setBounds(new Rectangle(23, 113, 63, 16));
    contentPane.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setText("ZDLJDZ:");
    jLabel4.setBounds(new Rectangle(23, 158, 63, 16));
    jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel5.setText("规约号:");
    jLabel5.setBounds(new Rectangle(23, 186, 63, 16));
    jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel6.setText("发送内容:");
    jLabel6.setBounds(new Rectangle(23, 333, 63, 16));
    jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel7.setText("通讯方式:");
    jLabel7.setBounds(new Rectangle(21, 219, 63, 16));
    txt_AppID.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_AppID.setText("25");
    txt_AppID.setBounds(new Rectangle(84, 110, 83, 22));
    txt_zdljdz.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_zdljdz.setText("91010022");
    txt_zdljdz.setBounds(new Rectangle(84, 155, 88, 22));
    txt_gyh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gyh.setText("100");
    txt_gyh.setBounds(new Rectangle(84, 183, 63, 22));
    txt_txfs.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_txfs.setText("40");
    txt_txfs.setBounds(new Rectangle(84, 218, 63, 22));
    jTextField7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_ip.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    InetAddress localhost = java.net.InetAddress.getLocalHost();
    String hostIP = localhost.getHostAddress();
    txt_ip.setText(hostIP);
    txt_ip.setBounds(new Rectangle(84, 19, 159, 22));
    txt_content.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_content.setText("6000000100111107");
    txt_content.setBounds(new Rectangle(84, 330, 298, 22));
    txt_content.addActionListener(new RealTimeTestFrame_txt_content_actionAdapter(this));
    jButton3.setBounds(new Rectangle(200, 412, 89, 26));
    jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton3.setText("发送短信");
    jButton3.addActionListener(new RealTimeTestFrame_jButton3_actionAdapter(this));
    jButton4.setBounds(new Rectangle(295, 366, 96, 26));
    jButton4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton4.setText("自定义命令");
    jButton4.addActionListener(new RealTimeTestFrame_jButton4_actionAdapter(this));
    lab_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    lab_yxj.setText("优先级:");
    lab_yxj.setBounds(new Rectangle(23, 287, 61, 16));
    txt_gnm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gnm.setText("0D");
    txt_gnm.setBounds(new Rectangle(84, 251, 63, 22));
    jLabel9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel9.setText("手机号码:");
    jLabel9.setBounds(new Rectangle(190, 67, 67, 16));
    txt_sjhm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_sjhm.setText("13800571505");
    txt_sjhm.setBounds(new Rectangle(250, 64, 111, 22));
    jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel10.setText("命令序号:");
    jLabel10.setBounds(new Rectangle(190, 112, 73, 16));
    txt_mlxh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_mlxh.setText("1");
    txt_mlxh.setBounds(new Rectangle(250, 109, 110, 22));
    jButton5.setBounds(new Rectangle(105, 366, 83, 26));
    jButton5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton5.setText("连接");
    jButton5.addActionListener(new RealTimeTestFrame_jButton5_actionAdapter(this));
    jButton6.setBounds(new Rectangle(200, 366, 83, 26));
    jButton6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton6.setText("断开连接");
    jButton6.addActionListener(new RealTimeTestFrame_jButton6_actionAdapter(this));
    jLabel11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel11.setText("终端逻辑地址:");
    jLabel11.setBounds(new Rectangle(164, 199, 87, 16));
    txt_listterminal.setText("12041234");
    txt_listterminal.setBounds(new Rectangle(252, 196, 130, 22));
    jButton8.setBounds(new Rectangle(170, 248, 90, 26));
    jButton8.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton8.setText("加入队列");
    jButton8.addActionListener(new RealTimeTestFrame_jButton8_actionAdapter(this));
    jButton9.setBounds(new Rectangle(283, 248, 85, 26));
    jButton9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton9.setText("在线状态");
    jButton9.addActionListener(new RealTimeTestFrame_jButton9_actionAdapter(this));
    memo1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    memo1.setToolTipText("");
    memo1.setEditable(false);
    memo1.setLineWrap(true);
    memo1.setWrapStyleWord(true);
    memo1.setBounds(new Rectangle(17, 451, 361, 154));
    jButton7.setBounds(new Rectangle(226, 289, 92, 26));
    jButton7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton7.setText("设置掉线");
    jButton7.addActionListener(new RealTimeTestFrame_jButton7_actionAdapter(this));
    jButton10.setBounds(new Rectangle(192, 155, 90, 23));
    jButton10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton10.setText("手工建档");
    jButton10.addActionListener(new RealTimeTestFrame_jButton10_actionAdapter(this));
    jLabel12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel12.setText("功能码:");
    jLabel12.setBounds(new Rectangle(23, 254, 61, 16));
    txt_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_yxj.setText("08");
    txt_yxj.setBounds(new Rectangle(84, 283, 63, 22));
    jButton11.setBounds(new Rectangle(105, 412, 82, 26));
    jButton11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton11.setActionCommand("");
    jButton11.setText("获取结果");
    jButton11.addActionListener(new RealTimeTestFrame_jButton11_actionAdapter(this));
    jButton12.setBounds(new Rectangle(301, 412, 87, 26));
    jButton12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton12.setText("批量测试");
    jButton12.addActionListener(new RealTimeTestFrame_jButton12_actionAdapter(this));
    contentPane.add(jLabel1);
    contentPane.add(jLabel2);
    contentPane.add(txt_port);
    contentPane.add(jLabel3);
    contentPane.add(jLabel4);
    contentPane.add(jTextField1);
    contentPane.add(txt_AppID);
    contentPane.add(txt_zdljdz);
    contentPane.add(jTextField7);
    contentPane.add(txt_ip);
    contentPane.add(txt_content);
    contentPane.add(jLabel6);
    contentPane.add(jLabel9);
    contentPane.add(txt_sjhm);
    contentPane.add(jLabel10);
    contentPane.add(txt_mlxh);
    contentPane.add(txt_listterminal);
    contentPane.add(jLabel11);
    contentPane.add(jButton8);
    contentPane.add(jButton9);
    contentPane.add(memo1);
    contentPane.add(jButton7);
    contentPane.add(jButton10);
    contentPane.add(txt_gnm);
    contentPane.add(txt_txfs);
    contentPane.add(txt_gyh);
    contentPane.add(jLabel5);
    contentPane.add(jLabel7);
    contentPane.add(jLabel12);
    contentPane.add(lab_yxj);
    contentPane.add(txt_yxj);
    contentPane.add(jButton2);
    contentPane.add(jButton5);
    contentPane.add(jButton6);
    contentPane.add(jButton4);
    contentPane.add(jButton1);
    contentPane.add(jButton11);
    contentPane.add(jButton3);
    contentPane.add(jButton12);
  }
예제 #25
0
  // CONSTRUCTOR
  public FACFrame() {

    // SET PROPERTIES OF THE MAIN FRAME
    setTitle("Fully Associative Cache");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Toolkit.getDefaultToolkit().createImage(FACFrame.class.getResource("cam.gif")));

    // CREATE COMPONENTS AND SET THEIR PROPERTIES

    // NAVIGATION BUTTONS
    restart = new JButton("Restart");
    next = new JButton("Next");
    back = new JButton("Back");
    quit = new JButton("Quit");

    // CACHE HITS AND MISSES INFO.
    lCacheHits = new JLabel("Cache Hits");
    lCacheMisses = new JLabel("Cache Misses");
    tCacheHits = new JTextField(5);
    tCacheMisses = new JTextField(5);
    tCacheHits.setEditable(false);
    tCacheHits.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheHits.setText("  0");
    tCacheMisses.setEditable(false);
    tCacheMisses.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheMisses.setText("  0");

    // PROGRESS UPDATE AREA
    tProgress = new JTextArea(3, 45);
    tProgress.setEditable(false);
    tProgress.setLineWrap(true);
    tProgress.setWrapStyleWord(true);
    tProgress.setCaretPosition(0);
    tProgress.setFont(new Font("Serif", Font.BOLD + Font.ITALIC, 16));
    tProgress.setText(
        "Welcome to Fully Associative Cache!\nThe system specs are as follows -"
            + "\n  16 Blocks in Cache\n  32 Blocks in Main Memory\n  8 Words per Block"
            + "\n  The replacement algorithm shown is the Least-Recently-Used algorithm"
            + "\n  as it is the most commonly used one."
            + "\nPlease generate the Address Reference String."
            + "\nThen click on \"Next\" to continue.");
    progressScroll = new JScrollPane();
    progressScroll.getViewport().add(tProgress);
    progressScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    lProgress = new JLabel("PROGRESS UPDATE");

    // ADDRESS REFERENCE STRING
    addRefStrList = new JList();
    addRefStrList.setEnabled(false);
    addRefStrScroll = new JScrollPane();
    addRefStrScroll.getViewport().setView(addRefStrList);
    addRefStrScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    addRefStrScroll.setPreferredSize(new Dimension(140, 300));

    // BUTTONS USED TO ADDRESS GENERATION
    autoGen = new JButton("Auto Generate Add. Ref. Str.");
    selfGen = new JButton("Self Generate Add. Ref. Str.");

    // BITS IN MAIN MEMORY ADDRESS
    lBits = new JLabel("                   TAG                        WORD");

    tTag = new JTextField(9);
    tTag.setEditable(false);
    tWord = new JTextField(7);
    tWord.setEditable(false);

    // SET THE FONT STYLES FOR THE BITS IN MAIN MEMORY ADDRESS
    tTag.setFont(new Font("Monospaced", Font.BOLD, 14));
    tWord.setFont(new Font("Monospaced", Font.BOLD, 14));

    // REGISTER LISTENERS
    restart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            reStart();
          }
        });

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = true;
            step();
          }
        });

    back.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = false;
            step();
          }
        });

    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int confirmQuit =
                JOptionPane.showConfirmDialog(
                    null,
                    "Really Quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            switch (confirmQuit) {
              case JOptionPane.YES_OPTION:
                removeInstance();
              case JOptionPane.NO_OPTION:
                break;
            }
          }
        });

    autoGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            autoGenerateString();
          }
        });

    selfGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selfGenerateString();
          }
        });

    // DISABLE NAVIGATION BUTTONS FOR NOW
    next.setEnabled(false);
    back.setEnabled(false);

    // CREATE PANELS
    cachePanel = new FACachePanel();
    memoryPanel = new MemoryPanel();
    bottomPanel = new JPanel();
    cache = new JPanel();
    cacheHitsMisses = new JPanel();
    pAutoSelfGen = new JPanel();
    pAddRefStr = new JPanel();
    pEastPanel = new JPanel();
    pBitsInMM = new JPanel();

    // ADD COMPONENTS TO THE PANELS

    // PANEL WITH PROGRESS UPDATE TEXT AREA AND NAVIGATION BUTTONS
    bottomPanel.add(lProgress);
    bottomPanel.add(progressScroll);
    bottomPanel.add(restart);
    bottomPanel.add(next);
    bottomPanel.add(back);
    bottomPanel.add(quit);

    // PANEL WITH CACHE BLOCKS, HITS AND MISSES INFO.
    cacheHitsMisses.add(lCacheHits);
    cacheHitsMisses.add(tCacheHits);
    cacheHitsMisses.add(lCacheMisses);
    cacheHitsMisses.add(tCacheMisses);
    cacheHMBorder = BorderFactory.createEtchedBorder();
    cacheHitsMisses.setBorder(BorderFactory.createTitledBorder(cacheHMBorder, ""));

    cache.setLayout(new BorderLayout());
    cache.add(cachePanel, "Center");
    cache.add(cacheHitsMisses, "South");

    // PANEL WITH ADDRESS REFERENCE STRING AND STRING GENERATION BUTTONS
    pAutoSelfGen.setLayout(new GridLayout(2, 1));
    pAutoSelfGen.add(autoGen);
    pAutoSelfGen.add(selfGen);

    pAddRefStr.setLayout(new BorderLayout());
    pAddRefStr.setPreferredSize(new Dimension(160, 400));

    pAddRefStr.add(addRefStrScroll, "Center");
    pAddRefStr.add(pAutoSelfGen, "South");
    addRefStrBorder = BorderFactory.createEtchedBorder();
    pAddRefStr.setBorder(
        BorderFactory.createTitledBorder(addRefStrBorder, " Address Reference String "));

    // PANEL WITH THE MAIN MEMORY ADDRESS BITS INFO.
    pBitsInMM.setLayout(new BorderLayout());
    bitsInMMBorder = BorderFactory.createEtchedBorder();
    pBitsInMM.setBorder(BorderFactory.createTitledBorder(bitsInMMBorder, " Main Memory Address "));
    pBitsInMM.add(tTag, "Center");
    pBitsInMM.add(tWord, "East");
    pBitsInMM.add(lBits, "South");

    // PANEL CONTAINING THE ADDRESS REF. STRING PANEL AND BITS IN MM PANEL
    pEastPanel.setLayout(new BorderLayout());
    pEastPanel.setPreferredSize(new Dimension(310, 650));
    pEastPanel.add(pAddRefStr, "Center");
    pEastPanel.add(pBitsInMM, "South");

    // ADD COMPONENTS TO THE FRAME CONTAINER
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(cache, "West");
    c.add(memoryPanel, "Center");
    c.add(pEastPanel, "East");
    c.add(bottomPanel, "South");

    // INITIALIZE ARRAYS THAT HOLDS STATUS OF EMPTY AND LRU CACHE BLOCKS
    for (int i = 0; i < 16; i++) {
      statusCacheEmpty[i] = true;
      statusCacheLRU[i] = 0;
    }

    /*
     * CALL THE FUNCTION TO GENERATE THE ARRAY addresses, WHICH CONTAINS ALL THE POSSIBLE MEMORY ADDRESSES
     * THIS ARRAY WILL BE USEFUL IN THE AUTO GENERATION OF ADDRESSES AS WELL AS FOR VALIDATION OF
     * ADDRESS STRINGS INPUT BY THE USER IF HE/SHE CHOOSES SELF GENERATION.
     */
    createAddresses();

    pack();
  } // END CONSTRUCTOR
예제 #26
0
  private JPanel createShopPanel() {
    JPanel pan = new JPanel();
    pan.setLayout(new GridBagLayout());
    Font labelFont = new Font(Font.SERIF, Font.BOLD, 20);
    JLabel lCustomer = new JLabel("Customer");
    lCustomer.setFont(labelFont);
    JComboBox<String> tClient = new JComboBox<>();

    tClient.addItem("New Client");
    for (Client client : shop.getClients()) {
      tClient.addItem(client.getFullName());
    }
    //        tClient.setColumns(15);
    tClient.setBackground(Color.WHITE);

    pan.add(
        lCustomer,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(0, 0, 15, 15),
            0,
            0));
    pan.add(
        tClient,
        new GridBagConstraints(
            1, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 15, 0), 0, 0));

    JLabel model = new JLabel("Model");
    JLabel engineType = new JLabel("Engine Type");
    model.setFont(new Font(Font.SERIF, Font.BOLD, 15));
    engineType.setFont(new Font(Font.SERIF, Font.BOLD, 15));

    pan.add(
        model,
        new GridBagConstraints(
            1, 1, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0));
    pan.add(
        engineType,
        new GridBagConstraints(
            2, 1, 1, 1, 0, 0, GridBagConstraints.LINE_START, 0, new Insets(0, 25, 0, 0), 0, 0));

    //        ButtonGroup bg = new ButtonGroup();

    //        JPanel radioPanel = new JPanel();
    JLabel lProduct = new JLabel("Car");
    lProduct.setFont(labelFont);

    JComboBox<String> cars = new JComboBox<>();

    fillFieldCars(cars);

    //        radioPanel.setLayout(new GridLayout(3, 0));

    //        ActionListener rbListener = new RBListener();
    //        for (int i=0; i<shop.getCars().size(); i++) {
    //            Car car = shop.getCars().get(i);
    //
    //            JRadioButton rb = new JRadioButton(car.getManufacturer().toString() + "
    // "+car.getModel().toString());
    //            rb.setActionCommand(String.valueOf(i));
    //            rb.addActionListener(rbListener);
    //
    //            if (i==0) {
    //                rb.setSelected(true);
    //            }
    //
    //            bg.add(rb);
    //            radioPanel.add(rb);
    //
    //        }
    //        cars.addActionListener(new ActionListener() {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //
    //            }
    //        });
    JComboBox<EngineKind> engine = new JComboBox<>();
    engine.addItem(shop.getCars().get(indexProduct).getEngineKind());

    pan.add(
        lProduct,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    pan.add(
        cars,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    pan.add(
        engine,
        new GridBagConstraints(
            2,
            2,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(0, 25, 0, 0),
            0,
            0));

    JButton buy = new JButton("Buy");
    buy.setFont(labelFont);
    pan.add(
        buy,
        new GridBagConstraints(
            3,
            5,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(30, 0, 0, 0),
            0,
            0));

    JButton returns = new JButton("Back");
    returns.setFont(labelFont);
    pan.add(
        returns,
        new GridBagConstraints(
            0,
            5,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(30, 0, 0, 0),
            0,
            0));

    JLabel lPrice = new JLabel("Price");
    lPrice.setFont(labelFont);
    pan.add(
        lPrice,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(20, 0, 0, 0),
            0,
            0));

    double price = shop.getCars().get(indexProduct).getPrice();
    JTextField lPriceValue = new JTextField();
    lPriceValue.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20));
    lPriceValue.setText(Double.toString(price) + " $");
    lPriceValue.setEditable(false);

    pan.add(
        lPriceValue,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(20, 0, 0, 0),
            0,
            0));

    cars.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            String carName = cars.getItemAt(cars.getSelectedIndex());
            engine.removeAllItems();

            for (Car car : shop.getCars()) {

              if ((car.getManufacturer() + " " + car.getModel()).equals(carName)) {
                EngineKind en = car.getEngineKind();
                engine.addItem(en);
              }
            }
          }
        });

    engine.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String carName = cars.getItemAt(cars.getSelectedIndex());
            for (Car car : shop.getCars()) {
              if ((car.getManufacturer() + " " + car.getModel()).equals(carName)
                  && car.getEngineKind().equals(engine.getItemAt(engine.getSelectedIndex()))) {

                double price = car.getPrice();
                lPriceValue.setText(Double.toString(price) + " $");
                return;
              }
            }
          }
        });

    buy.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String name = tClient.getSelectedItem().toString();
            System.out.println(name);
            Client client = shop.findClient(name);
            //

            if (client == null) {
              new NewClientUI(shop);
              frame.dispose();
            } else {
              Car car = getCarFromStorage(cars, engine);

              if (car.getCount() == 0) {
                new CarIsNotAvailableUI();
                return;
              }
              shop.sellAuto(car, client);
              new TableTransaction(shop);
              frame.dispose();
            }
          }
        });
    returns.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            new TableTransaction(shop);
            frame.dispose();
          }
        });

    return pan;
  }
예제 #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
  /**
   * This method is used to display the window to interact with obix as well as colibri.
   *
   * @param chosenComponents The {@link ObixObject} which have been chosen in the previous windows.
   * @return The container which contains all elemtents that are used for interacting with obix as
   *     well as colibri.
   */
  private Container interactionWindow(List<ObixObject> chosenComponents) {
    Container pane = new Container();
    pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(30, 20, 0, 0);

    c.gridy++;
    pane.add(registeredColibriChannelCheckBox, c);

    JLabel label = new JLabel("OBIX Components");
    Font headerF = new Font("Courier", Font.BOLD, 25);
    label.setFont(headerF);
    c.gridy++;
    pane.add(label, c);

    /*
       Print lobby Data
    */
    for (ObixObject o : chosenComponents) {
      if (connector.getColibriChannel().getRegistered()) {
        connector.getColibriChannel().send(ColibriMessage.createAddServiceMessage(o));
      }

      c.gridy++;
      c.insets = new Insets(30, 10, 0, 0);

      JLabel uriLabel = new JLabel(o.getObixUri());
      uriLabel.setFont(new Font("Courier", Font.ITALIC, 15));
      c.gridx = 0;
      c.gridwidth = 10;
      pane.add(uriLabel, c);

      c.gridwidth = 1;
      c.insets = new Insets(5, 10, 0, 0);

      final JTextField textField = new JTextField("NOT OBSERVED", 20);
      Font tempF = new Font("Courier", Font.PLAIN, 15);
      textField.setFont(tempF);
      c.gridy++;
      pane.add(textField, c);

      JLabel unitLabel = new JLabel();
      if (o.hasUnit()) {
        String unitString = o.getUnit().symbol().get();
        int unitCode = unitString.codePointAt(0);
        if (unitCode == 65533) {
          unitString = "\u2103";
        }
        unitLabel.setText(unitString);
      }
      c.gridx++;
      pane.add(unitLabel, c);

      final JButton getObixButton = new JButton("GET from OBIX");
      c.gridx++;
      pane.add(getObixButton, c);

      final JButton getColibriButton = new JButton("GET from Colibri");
      c.gridx++;
      pane.add(getColibriButton, c);

      final JCheckBox writableCheckBox = new JCheckBox("Writable");
      writableCheckBox.setSelected(o.getObj().isWritable());
      writableCheckBox.setEnabled(false);
      c.gridx++;
      pane.add(writableCheckBox, c);

      final JCheckBox observeObixCheckBox = new JCheckBox("observe Obix Data");
      observeObixCheckBox.setMargin(new Insets(0, 20, 0, 20));
      c.gridx++;
      pane.add(observeObixCheckBox, c);

      final JCheckBox observedByColibriCheckBox = new JCheckBox("Colibri observes Data");
      observedByColibriCheckBox.setEnabled(false);
      commandFactory.addCommand(
          () -> observedByColibriCheckBox.setSelected(o.getObservedByColibri()));
      c.gridx++;
      pane.add(observedByColibriCheckBox, c);

      final JCheckBox addServiceCheckbox = new JCheckBox("Service Added to Colibri");
      commandFactory.addCommand(() -> addServiceCheckbox.setSelected(o.getAddedAsService()));
      commandFactory.addCommand(
          () -> addServiceCheckbox.setEnabled(connector.getColibriChannel().getRegistered()));
      c.gridx++;
      pane.add(addServiceCheckbox, c);

      final JCheckBox observeColibriActionsCheckbox = new JCheckBox("Observe Colibri Actions");
      if (o.getObj().isWritable()) {
        commandFactory.addCommand(
            () -> observeColibriActionsCheckbox.setEnabled(o.getAddedAsService()));
        commandFactory.addCommand(
            () -> observeColibriActionsCheckbox.setSelected(o.getObservesColibriActions()));
      } else {
        observeColibriActionsCheckbox.setEnabled(false);
      }
      c.gridx++;
      pane.add(observeColibriActionsCheckbox, c);

      representationRows.add(
          new RepresentationRow(
              uriLabel,
              observeObixCheckBox,
              textField,
              o,
              writableCheckBox,
              getObixButton,
              getColibriButton,
              addServiceCheckbox,
              observedByColibriCheckBox,
              observeColibriActionsCheckbox));
      PutToObixTask putToObixTask =
          new PutToObixTask(o, connector.getColibriChannel(), connector.getObixChannel(), null);
      connector.getColibriChannel().addPutToObixTask(o.getServiceUri(), putToObixTask);
      ObixObservationUpdates observationUpdates =
          new ObixObservationUpdates(observeObixCheckBox, textField, o, connector);

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is observed by the obix connector.
       */
      observeObixCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getObservedCheckBox().equals(observeObixCheckBox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                obixChannel.observe(object);
                commandFactory.addCommand(
                    object.getObixUri() + "ObserveCommand", observationUpdates::run);
              } else {
                commandFactory.removeCommand(object.getObixUri() + "ObserveCommand");
                object.getRelation().proactiveCancel();
              }
            }
          });

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is writeable.
       */
      writableCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getWritableCheckbox().equals(writableCheckBox)) {
                  object = r.getObixObject();
                }
              }

              if (e.getStateChange() == ItemEvent.SELECTED) {

              } else {
                object.getObj().setWritable(false);
              }
              object = obixChannel.put(object);
              writableCheckBox.setSelected(object.getObj().isWritable());
            }
          });

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is added as a service at colibri.
       */
      addServiceCheckbox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getAddedAsServiceCheckBox().equals(addServiceCheckbox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                if (!object.getAddedAsService()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createAddServiceMessage(object));
                }
              } else {
                if (object.getAddedAsService()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createRemoveServiceMessage(object));
                }
              }
            }
          });

      /**
       * Listener for the checkbox which indicates, if the connector observes the actions that the colibri
       * semantic core performs on an {@link ObixObject].
       */
      observeColibriActionsCheckbox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getObserveColibriActionsCheckbox().equals(observeColibriActionsCheckbox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                if (!object.getObservesColibriActions()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createObserveServiceMessage(object));
                }
              } else {
                if (object.getObservesColibriActions()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createDetachServiceMessage(object));
                }
              }
            }
          });

      /** GET Obix button listener */
      Action getObixAction =
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              JTextField textF = null;
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getGetObixButton().equals(getObixButton)) {
                  object = r.getObixObject();
                  textF = r.getValueTextField();
                }
              }
              textField.setText("");
              object = obixChannel.get(object.getObixUri());
              textF.setText(object.toString());
              if (o.getObservedByColibri()) {
                o.getPutMessageToColibriTask().execute(o);
              }
            }
          };
      getObixButton.addActionListener(getObixAction);

      /** GET Colibri button listener */
      Action getColibriAction =
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              JTextField textF = null;
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getGetColibriButton().equals(getColibriButton)) {
                  object = r.getObixObject();
                  textF = r.getValueTextField();
                }
              }
              connector.getColibriChannel().send(ColibriMessage.createGetMessage(object));
            }
          };
      getColibriButton.addActionListener(getColibriAction);

      /**
       * Listener for the textfield connected with an {@link ObixObject}, to send PUT messages to
       * obix on <Enter>.
       */
      textField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent e) {
              // intentionally empty
            }

            public void keyPressed(KeyEvent e) {
              // intentionally empty
            }

            public void keyReleased(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                ObixObject object = new ObixObject("", o.getObixChannelPort());
                for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                  if (r.getValueTextField().equals(textField)) {
                    object = r.getObixObject();
                  }
                }
                object.setValueParameter1(textField.getText());
                textField.setText("");
                object = obixChannel.put(object);
                textField.setText(object.toString());
              }
            }
          });
    }

    JTextArea receivedMessagesTextArea = new JTextArea("Received Messages");
    receivedMessagesTextArea.setLineWrap(true);
    receivedMessagesTextArea.setWrapStyleWord(true);
    c.gridy++;
    c.gridx = 0;
    c.insets = new Insets(50, 0, 0, 0);
    c.gridwidth = 10;
    pane.add(receivedMessagesTextArea, c);
    receivedMessagesTextArea.setEnabled(false);
    commandFactory.addCommand(
        () ->
            receivedMessagesTextArea.setText(
                connector.getColibriChannel().getLastMessageReceived()));

    c.gridy++;
    c.gridwidth = 1;

    JLabel sendMessageLabel = new JLabel("Send Message to Colibri Semantic Core:");
    pane.add(sendMessageLabel, c);

    c.gridy++;
    c.gridwidth = 10;
    JTextArea sendMessageArea = new JTextArea("");
    pane.add(sendMessageArea, c);

    c.gridy++;
    c.gridwidth = 2;
    JButton sendQueMessageButton = new JButton("Send Query Message");
    pane.add(sendQueMessageButton, c);
    c.gridx++;
    c.gridx++;
    c.gridwidth = 2;
    JButton sendUpdMessageButton = new JButton("Send Update Message");
    pane.add(sendUpdMessageButton, c);

    commandFactory.addCommand(
        () -> sendQueMessageButton.setEnabled(connector.getColibriChannel().getRegistered()));
    commandFactory.addCommand(
        () -> sendUpdMessageButton.setEnabled(connector.getColibriChannel().getRegistered()));

    /** QUE to Colibri button listener */
    Action sendQueMessageAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            connector
                .getColibriChannel()
                .send(
                    ColibriMessage.createQueryMessage(
                        sendMessageArea.getText(), new ArrayList<>()));
          }
        };
    sendQueMessageButton.addActionListener(sendQueMessageAction);

    /** UPD to Colibri button listener */
    Action sendUpdMessageAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            connector
                .getColibriChannel()
                .send(ColibriMessage.createUpdateMessage(sendMessageArea.getText()));
          }
        };
    sendUpdMessageButton.addActionListener(sendUpdMessageAction);
    return pane;
  }
예제 #29
0
  private void initComponents() {
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setTitle(I18n.getLocaleString("SETTINGS"));
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            formWindowClosing(evt);
          }
        });

    maxParallelDownloadsLabel = new JLabel(I18n.getLocaleString("MAX_PARALLEL_DOWNLOADS"));
    maxParallelDownloadsLabel.setFont(
        new Font(maxParallelDownloadsLabel.getFont().getName(), Font.BOLD, 11));

    downloadDirectoryLabel = new JLabel(I18n.getLocaleString("DOWNLOAD_DIRECTORY"));
    downloadDirectoryLabel.setFont(
        new Font(downloadDirectoryLabel.getFont().getName(), Font.BOLD, 11));

    downloadDirectoryTextField = new JTextField();
    downloadDirectoryTextField.setRequestFocusEnabled(false);

    maxParallelDownloadsSpinner = new JSpinner();
    maxParallelDownloadsSpinner.setModel(new SpinnerNumberModel(10, 1, null, 1));
    maxParallelDownloadsSpinner.setValue(10);

    saveSettingsButton = new JButton(I18n.getLocaleString("SAVE_AND_CLOSE"));
    saveSettingsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            saveSettingsButtonActionPerformed(evt);
          }
        });

    downloadDirectoryButton = new JButton("...");
    downloadDirectoryButton.setFocusable(false);
    downloadDirectoryButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            downloadDirectoryButtonActionPerformed(evt);
          }
        });

    fileNameSchemeTextField = new JTextField();
    fileNameSchemeTextField.setFont(new Font(Font.MONOSPACED, 0, 12));

    filenameSchemeLabel = new JLabel(I18n.getLocaleString("FILENAME_SCHEME"));
    filenameSchemeLabel.setFont(new Font(filenameSchemeLabel.getFont().getName(), Font.BOLD, 11));

    filenameSchemeDescriptionLabel = new JLabel();
    filenameSchemeDescriptionLabel.setFont(
        new Font(filenameSchemeDescriptionLabel.getFont().getName(), Font.PLAIN, 11));
    filenameSchemeDescriptionLabel.setLabelFor(fileNameSchemeTextField);
    String tagStyle = "font-family: Monospaced; font-weight: bold;";
    filenameSchemeDescriptionLabel.setText(
        "<html><body>"
            + I18n.getLocaleString("FILENAME_SCHEME_DESCRIPTION")
                .replace("&lt;", "<span style=\"" + tagStyle + "\">&lt;")
                .replace("&gt;", "&gt;</span>")
                .replaceFirst("/", "<span style=\"" + tagStyle + "\">/</span>")
            + "</body></html>");

    /*searchAutocompleteLabel = new JLabel(I18n.getLocaleString("SEARCH_AUTOCOMPLETE"));
    searchAutocompleteLabel.setFont(new Font(searchAutocompleteLabel.getFont().getName(), Font.BOLD, 11));

    searchAutocompleteCheckBox = new JCheckBox(I18n.getLocaleString("ENABLED"));
    searchAutocompleteCheckBox.setFont(new Font(searchAutocompleteCheckBox.getFont().getName(), Font.BOLD, 11));*/

    startTabLabel = new JLabel(I18n.getLocaleString("START_TAB"));
    startTabLabel.setFont(new Font(startTabLabel.getFont().getName(), Font.BOLD, 11));

    startTabComboBox = new JComboBox();

    downloadCompletedLabel = new JLabel(I18n.getLocaleString("DOWNLOAD_COMPLETED"));
    downloadCompletedLabel.setFont(
        new Font(downloadCompletedLabel.getFont().getName(), Font.BOLD, 11));

    downloadCompletedComboBox = new JComboBox();

    languageLabel = new JLabel(I18n.getLocaleString("LANGUAGE"));
    languageLabel.setFont(new Font(languageLabel.getFont().getName(), Font.BOLD, 11));

    languageComboBox = new JComboBox();
    DefaultComboBoxModel languageComboBoxModel = new DefaultComboBoxModel();
    languageComboBox.setModel(languageComboBoxModel);
    for (Locale locale : I18n.getLocales()) {
      languageComboBoxModel.addElement(locale);
      if (locale.equals(I18n.getCurrentLocale())) {
        languageComboBox.setSelectedItem(locale);
      }
    }
    languageComboBox.setRenderer(
        new DefaultListCellRenderer() {
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component comp =
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            JLabel label = new JLabel();
            label.setOpaque(false);
            if (isSelected) {
              label.setOpaque(true);
              label.setForeground(comp.getForeground());
              label.setBackground(comp.getBackground());
            } else {
              label.setBackground(comp.getBackground());
            }
            label.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6));
            list.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            list.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

            Locale locale = (Locale) value;

            String languageNameForeign = WordUtils.capitalize(locale.getDisplayName(locale));
            String languageNameOwn =
                WordUtils.capitalize(locale.getDisplayName(I18n.getCurrentLocale()));
            String languageCode = locale.toString().replace("_", "-");

            // fix not existent language names
            if (locale.toString().equals("en_PT")) {
              languageNameForeign = "Pirate English";
              languageNameOwn = languageNameForeign;
            }
            if (locale.toString().equals("lol")) {
              languageNameForeign = "LOLCAT";
              languageNameOwn = languageNameForeign;
            }

            // fix ISO3 codes
            if (locale.toString().equals("iw")) {
              languageCode = "he";
            }

            URL url = getClass().getResource("/gui/flags/" + languageCode + ".png");
            if (url != null) {
              ImageIcon icon = new ImageIcon(url);
              icon = GuiUtils.stretchImage(icon, 18, 18, this);
              label.setIcon(icon);
            }

            label.setText(
                "<html>"
                    + "\u202A"
                    + languageNameForeign
                    + (!isSelected ? "<font color=gray>" : "")
                    + " — "
                    + languageNameOwn
                    + (!isSelected ? "</font>" : "")
                    + "</html>");

            return label;
          }
        });

    resetOriginalSettingsButton = new JButton(I18n.getLocaleString("RESET_ORIGINAL_SETTINGS"));
    resetOriginalSettingsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            resetOriginalSettingsButtonActionPerformed(evt);
          }
        });

    fileExistsLabel = new JLabel();
    fileExistsLabel.setFont(new Font(fileExistsLabel.getFont().getName(), Font.BOLD, 11));
    fileExistsLabel.setText(I18n.getLocaleString("FILE_EXISTS"));

    fileExistsComboBox = new JComboBox();

    proxyHostLabel = new JLabel(I18n.getLocaleString("PROXY_HOST"));
    proxyHostLabel.setFont(new Font(proxyHostLabel.getFont().getName(), Font.BOLD, 11));

    proxyHostTextField = new JTextField();

    proxyPortLabel = new JLabel(I18n.getLocaleString("PROXY_PORT"));
    proxyPortLabel.setFont(new Font(proxyPortLabel.getFont().getName(), Font.BOLD, 11));

    proxyPortTextField = new JTextField();

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.LEADING)
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .add(
                                        resetOriginalSettingsButton,
                                        GroupLayout.PREFERRED_SIZE,
                                        227,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(LayoutStyle.RELATED)
                                    .add(
                                        saveSettingsButton,
                                        GroupLayout.PREFERRED_SIZE,
                                        250,
                                        GroupLayout.PREFERRED_SIZE))
                            .add(
                                layout
                                    .createSequentialGroup()
                                    .add(
                                        layout
                                            .createParallelGroup(GroupLayout.TRAILING, false)
                                            .add(
                                                languageLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                fileExistsLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                maxParallelDownloadsLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                filenameSchemeLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                downloadDirectoryLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                startTabLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                downloadCompletedLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                proxyHostLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE)
                                            .add(
                                                proxyPortLabel,
                                                GroupLayout.DEFAULT_SIZE,
                                                GroupLayout.DEFAULT_SIZE,
                                                Short.MAX_VALUE))
                                    .addPreferredGap(LayoutStyle.RELATED)
                                    .add(
                                        layout
                                            .createParallelGroup(GroupLayout.LEADING)
                                            .add(
                                                layout
                                                    .createSequentialGroup()
                                                    .add(downloadDirectoryTextField)
                                                    .addPreferredGap(LayoutStyle.RELATED)
                                                    .add(
                                                        downloadDirectoryButton,
                                                        GroupLayout.PREFERRED_SIZE,
                                                        48,
                                                        GroupLayout.PREFERRED_SIZE))
                                            .add(
                                                GroupLayout.TRAILING,
                                                filenameSchemeDescriptionLabel,
                                                GroupLayout.PREFERRED_SIZE,
                                                0,
                                                Short.MAX_VALUE)
                                            .add(GroupLayout.TRAILING, fileNameSchemeTextField)
                                            .add(
                                                layout
                                                    .createSequentialGroup()
                                                    .add(
                                                        layout
                                                            .createParallelGroup(
                                                                GroupLayout.LEADING, false)
                                                            .add(
                                                                downloadCompletedComboBox,
                                                                0,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                            .add(startTabComboBox)
                                                            .add(
                                                                maxParallelDownloadsSpinner,
                                                                GroupLayout.PREFERRED_SIZE,
                                                                60,
                                                                GroupLayout.PREFERRED_SIZE)
                                                            .add(
                                                                fileExistsComboBox,
                                                                0,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                            .add(
                                                                languageComboBox,
                                                                0,
                                                                GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                            .add(proxyHostTextField)
                                                            .add(proxyPortTextField))
                                                    .add(0, 0, Short.MAX_VALUE)))))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(
                                downloadDirectoryTextField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .add(downloadDirectoryButton)
                            .add(
                                downloadDirectoryLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addPreferredGap(LayoutStyle.UNRELATED)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.LEADING, false)
                            .add(maxParallelDownloadsSpinner)
                            .add(
                                maxParallelDownloadsLabel,
                                GroupLayout.PREFERRED_SIZE,
                                20,
                                GroupLayout.PREFERRED_SIZE))
                    .add(18, 18, 18)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(
                                filenameSchemeLabel,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .add(
                                fileNameSchemeTextField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(
                        filenameSchemeDescriptionLabel,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.UNRELATED)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(
                                startTabLabel,
                                GroupLayout.PREFERRED_SIZE,
                                23,
                                GroupLayout.PREFERRED_SIZE)
                            .add(startTabComboBox))
                    .add(18, 18, 18)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(downloadCompletedLabel)
                            .add(
                                downloadCompletedComboBox,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .add(15, 15, 15)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(fileExistsLabel)
                            .add(
                                fileExistsComboBox,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .add(18, 18, 18)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(languageLabel)
                            .add(
                                languageComboBox,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .add(18, 18, 18)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(proxyHostLabel)
                            .add(
                                proxyHostTextField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .add(18, 18, 18)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(proxyPortLabel)
                            .add(
                                proxyPortTextField,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .add(50, 50, 50)
                    .add(
                        layout
                            .createParallelGroup(GroupLayout.BASELINE)
                            .add(saveSettingsButton)
                            .add(resetOriginalSettingsButton))
                    .addContainerGap()));

    setMinimumSize(new Dimension(700, 620));

    pack();
  }
  /** Sets up the GUI (panels, buttons, etc) and displays it on the screen. */
  private void init() {
    DecimalFormat df;
    int xUnits;
    String unitStr;
    String distStr;
    setForeground(Color.black);
    setTitle("Center Distances version 2  07/14/08");

    df = new DecimalFormat("0.000E0");

    GridBagConstraints gbc = new GridBagConstraints();
    int yPos = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    gbc.insets = new Insets(3, 3, 3, 3);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = yPos++;

    JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setForeground(Color.black);
    mainPanel.setBorder(buildTitledBorder("Input parameters"));

    blueMinLabel = new JLabel("Minimum number of blue pixels per nucleus");
    blueMinLabel.setForeground(Color.black);
    blueMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(blueMinLabel, gbc);

    blueMinText = new JTextField(5);
    if (image.getNDims() == 2) {
      blueMinText.setText("1000");
    } else {
      blueMinText.setText("20000");
    }
    blueMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(blueMinText, gbc);

    redMinLabel = new JLabel("Minimum red pixel count");
    redMinLabel.setForeground(Color.black);
    redMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(redMinLabel, gbc);

    redMinText = new JTextField(5);
    redMinText.setText("50");
    redMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(redMinText, gbc);

    redFractionLabel = new JLabel("Fraction of red pixels to consider");
    redFractionLabel.setForeground(Color.black);
    redFractionLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(redFractionLabel, gbc);

    redFractionText = new JTextField(5);
    redFractionText.setText("0.15");
    redFractionText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(redFractionText, gbc);

    xUnits = image.getFileInfo(0).getUnitsOfMeasure()[0];
    if (xUnits != Unit.UNKNOWN_MEASURE.getLegacyNum()) {
      unitStr = (Unit.getUnitFromLegacyNum(xUnits)).toString();
      greenMergingLabel = new JLabel("Green merging radius around peak (" + unitStr + ")");
    } else {
      greenMergingLabel = new JLabel("Green merging radius around peak");
    }
    greenMergingLabel.setForeground(Color.black);
    greenMergingLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenMergingLabel, gbc);

    if (image.getNDims() == 2) {
      // mergingDistance = 8.0f * image.getFileInfo(0).getResolutions()[0];
      mergingDistance = 0.0f;
    } else {
      // mergingDistance = 4.0f * image.getFileInfo(0).getResolutions()[0];
      mergingDistance = 0.0f;
    }
    distStr = df.format(mergingDistance);
    greenMergingText = new JTextField(10);
    greenMergingText.setText(distStr);
    greenMergingText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenMergingText, gbc);

    greenMinLabel = new JLabel("Minimum green pixel count");
    greenMinLabel.setForeground(Color.black);
    greenMinLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenMinLabel, gbc);

    greenMinText = new JTextField(5);
    greenMinText.setText("10");
    greenMinText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenMinText, gbc);

    greenFractionLabel = new JLabel("Fraction of green pixels to consider");
    greenFractionLabel.setForeground(Color.black);
    greenFractionLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenFractionLabel, gbc);

    greenFractionText = new JTextField(5);
    greenFractionText.setText("0.01");
    greenFractionText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(greenFractionText, gbc);

    greenRegionsLabel = new JLabel("Green regions per cell");
    greenRegionsLabel.setForeground(Color.black);
    greenRegionsLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(greenRegionsLabel, gbc);

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    greenGroup = new ButtonGroup();

    oneButton = new JRadioButton("1", false);
    oneButton.setForeground(Color.black);
    oneButton.setFont(serif12);
    greenGroup.add(oneButton);
    gbc.gridx = 0;
    gbc.gridy = 0;
    buttonPanel.add(oneButton, gbc);

    twoButton = new JRadioButton("2", true);
    twoButton.setForeground(Color.black);
    twoButton.setFont(serif12);
    greenGroup.add(twoButton);
    gbc.gridx = 1;
    gbc.gridy = 0;
    buttonPanel.add(twoButton, gbc);

    threeButton = new JRadioButton("3", false);
    threeButton.setForeground(Color.black);
    threeButton.setFont(serif12);
    greenGroup.add(threeButton);
    gbc.gridx = 2;
    gbc.gridy = 0;
    buttonPanel.add(threeButton, gbc);

    fourButton = new JRadioButton("4", false);
    fourButton.setForeground(Color.black);
    fourButton.setFont(serif12);
    greenGroup.add(fourButton);
    gbc.gridx = 3;
    gbc.gridy = 0;
    buttonPanel.add(fourButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(buttonPanel, gbc);

    twoBox = new JCheckBox("Use 2 top gray levels in green segmentation", true);
    twoBox.setForeground(Color.black);
    twoBox.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos++;
    mainPanel.add(twoBox, gbc);

    blueValueLabel =
        new JLabel("Fraction of blue transition from image min to max at nucleus boundary");
    blueValueLabel.setForeground(Color.black);
    blueValueLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(blueValueLabel, gbc);

    blueValueText = new JTextField(5);
    blueValueText.setText("0.15");
    blueValueText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(blueValueText, gbc);

    blueSmoothBox = new JCheckBox("Smooth blue VOI contours with AlgorithmBSmooth", true);
    blueSmoothBox.setForeground(Color.black);
    blueSmoothBox.setFont(serif12);
    blueSmoothBox.addActionListener(this);
    gbc.gridx = 0;
    gbc.gridy = yPos++;
    mainPanel.add(blueSmoothBox, gbc);

    interpolationLabel = new JLabel("Number of interpolation points determined by divisor (> 1.0)");
    interpolationLabel.setForeground(Color.black);
    interpolationLabel.setFont(serif12);
    gbc.gridx = 0;
    gbc.gridy = yPos;
    mainPanel.add(interpolationLabel, gbc);

    interpolationText = new JTextField(5);
    interpolationText.setText("24.0");
    interpolationText.setFont(serif12);
    gbc.gridx = 1;
    gbc.gridy = yPos++;
    mainPanel.add(interpolationText, gbc);

    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(buildButtons(), BorderLayout.SOUTH);

    pack();
    setVisible(true);
    setResizable(false);
    System.gc();
  } // end init()