コード例 #1
0
  private void createZoomTextField() {
    mZoomTextField = new JFormattedTextField(new DecimalFormat("##0.00%"));
    mZoomTextField.setFocusLostBehavior(JFormattedTextField.REVERT);
    mZoomTextField.setHorizontalAlignment(SwingConstants.CENTER);
    mZoomTextField.setColumns(6);
    mZoomTextField.setMinimumSize(mZoomTextField.getPreferredSize());

    mZoomTextField.addActionListener(
        (x) -> mImagePresentationModel.setZoom(((Number) mZoomTextField.getValue()).doubleValue()));

    mImagePresentationModel.addListener(
        new ImagePresentationModel.Listener() {
          @Override
          public void onVisibleImageContentUpdate() {
            mZoomTextField.setValue(mImagePresentationModel.getZoom());
          }

          @Override
          public void onImageChange() {
            onVisibleImageContentUpdate();
          }
        });
  }
コード例 #2
0
  private void addInformationPanel() {
    // Create UI elements for connection information.
    JPanel informationPanel = new JPanel();
    informationPanel.setLayout(new BorderLayout());

    // Add the Host information
    JPanel connPanel = new JPanel();
    connPanel.setLayout(new GridBagLayout());
    connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));

    JLabel label = new JLabel("Host: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the Port information
    label = new JLabel("Port: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(connection.getPort());
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's User information
    label = new JLabel("User: "******"Creation time: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss:SS aaa"));
    field.setMinimumSize(new java.awt.Dimension(150, 20));
    field.setMaximumSize(new java.awt.Dimension(150, 20));
    field.setValue(creationTime);
    field.setEditable(false);
    field.setBorder(null);
    connPanel.add(
        field, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));

    // Add the connection's creationTime information
    label = new JLabel("Status: ");
    label.setMinimumSize(new java.awt.Dimension(150, 14));
    label.setMaximumSize(new java.awt.Dimension(150, 14));
    connPanel.add(
        label, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
    statusField = new JFormattedTextField();
    statusField.setMinimumSize(new java.awt.Dimension(150, 20));
    statusField.setMaximumSize(new java.awt.Dimension(150, 20));
    statusField.setValue("Active");
    statusField.setEditable(false);
    statusField.setBorder(null);
    connPanel.add(
        statusField,
        new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
    // Add the connection panel to the information panel
    informationPanel.add(connPanel, BorderLayout.NORTH);

    // Add the Number of sent packets information
    JPanel packetsPanel = new JPanel();
    packetsPanel.setLayout(new GridLayout(1, 1));
    packetsPanel.setBorder(BorderFactory.createTitledBorder("Transmitted Packets"));

    statisticsTable =
        new DefaultTableModel(
            new Object[][] {
              {"IQ", 0, 0}, {"Message", 0, 0}, {"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}
            },
            new Object[] {"Type", "Received", "Sent"}) {
          private static final long serialVersionUID = -6793886085109589269L;

          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    JTable table = new JTable(statisticsTable);
    // Allow only single a selection
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    packetsPanel.add(new JScrollPane(table));

    // Add the packets panel to the information panel
    informationPanel.add(packetsPanel, BorderLayout.CENTER);

    tabbedPane.add("Information", new JScrollPane(informationPanel));
    tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
  }
コード例 #3
0
ファイル: Calculator.java プロジェクト: artemok1/Box
  /** Create the frame. */
  public Calculator() {
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 384, 259);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(7, 3));

    displayField = new JFormattedTextField();
    displayField.setFont(new Font("Tahoma", Font.PLAIN, 14));
    displayField.setPreferredSize(new Dimension(6, 30));
    displayField.setMinimumSize(new Dimension(10, 10));
    displayField.setEditable(false);
    displayField.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(displayField, BorderLayout.NORTH);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(new GridLayout(4, 3, 3, 3));

    CalculatorActionsListener calcListener = new CalculatorActionsListener(this);

    JButton btnNewButton7 = new JButton("7");
    btnNewButton7.setFont(new Font("Tahoma", Font.PLAIN, 14));
    btnNewButton7.setSize(new Dimension(25, 23));
    btnNewButton7.setMaximumSize(new Dimension(23, 23));
    btnNewButton7.setPreferredSize(new Dimension(25, 23));
    panel.add(btnNewButton7);
    btnNewButton7.addActionListener(calcListener);

    JButton btnNewButton8 = new JButton("8");
    btnNewButton8.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton8);
    btnNewButton8.addActionListener(calcListener);

    JButton btnNewButton9 = new JButton("9");
    btnNewButton9.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton9);
    btnNewButton9.addActionListener(calcListener);

    JButton btnNewButton4 = new JButton("4");
    btnNewButton4.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton4);
    btnNewButton4.addActionListener(calcListener);

    JButton btnNewButton5 = new JButton("A");
    btnNewButton5.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton5);
    btnNewButton5.addActionListener(calcListener);

    JButton btnNewButton6 = new JButton("6");
    btnNewButton6.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton6);
    btnNewButton6.addActionListener(calcListener);

    JButton btnNewButton1 = new JButton("1");
    btnNewButton1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton1);
    btnNewButton1.addActionListener(calcListener);

    JButton btnNewButton2 = new JButton("2");
    btnNewButton2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton2);
    btnNewButton2.addActionListener(calcListener);

    JButton btnNewButton3 = new JButton("3");
    btnNewButton3.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton3);
    btnNewButton3.addActionListener(calcListener);

    JButton btnNewButtonZero = new JButton("0");
    btnNewButtonZero.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonZero);
    btnNewButtonZero.addActionListener(calcListener);

    JButton btnNewButtonDot = new JButton(".");
    btnNewButtonDot.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonDot);
    btnNewButtonDot.addActionListener(calcListener);

    btnNewButtonEqual = new JButton("=");
    btnNewButtonEqual.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonEqual);
    btnNewButtonEqual.addActionListener(calcListener);

    JPanel panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(80, 10));
    panel_1.setBounds(new Rectangle(5, 5, 5, 5));
    contentPane.add(panel_1, BorderLayout.EAST);
    panel_1.setLayout(new GridLayout(4, 1, 3, 3));

    btnNewButtonDiv = new JButton("/");
    btnNewButtonDiv.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonDiv);
    btnNewButtonDiv.addActionListener(calcListener);

    btnNewButtonMult = new JButton("*");
    btnNewButtonMult.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonMult);
    btnNewButtonMult.addActionListener(calcListener);

    btnNewButtonSub = new JButton("-");
    btnNewButtonSub.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonSub);
    btnNewButtonSub.addActionListener(calcListener);

    btnNewButtonAdd = new JButton("+");
    btnNewButtonAdd.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonAdd);
    btnNewButtonAdd.addActionListener(calcListener);
  }