コード例 #1
0
    private void myDoubleClick(int row, TreePath path) {
      if (path != null) {
        JFrame infoFrame = new JFrame("Object Info for: " + path);
        JLabel objectLabel;
        JLabel parentPathLabel;

        // Display Selected Object Name;
        objectLabel = new JLabel("Object: " + path.getLastPathComponent().toString());
        objectLabel.setHorizontalAlignment(SwingConstants.CENTER);

        // Display specific object information
        parentPathLabel = new JLabel("Parent Path: " + path.getParentPath());
        parentPathLabel.setHorizontalAlignment(SwingConstants.CENTER);

        // Construct infoFrame
        infoFrame.getContentPane().add(objectLabel, BorderLayout.CENTER);
        infoFrame.getContentPane().add(parentPathLabel, BorderLayout.SOUTH);
        infoFrame.pack();
        infoFrame.setVisible(true);
      }
    }
コード例 #2
0
ファイル: Ballot.java プロジェクト: alecmagnani/CS0401
  // Constructor
  public Ballot(int index, int ID, int numCandidates, String title, ArrayList<String> candidates)
      throws IOException {
    _index = index;
    _ID = ID;
    _numCandidates = numCandidates;
    _votes = new int[_numCandidates];
    _title = title;
    _candidates = candidates;
    _usrVotes = new String[numCandidates];

    // if the ballot file already exists, read in the votes for that ballot
    // otherwise the number of votes for each candidate will default to 0
    file = new File(_ID + ".txt");
    if (file.exists()) {
      Scanner reader = new Scanner(file);
      int i = 0;
      while (reader.hasNextLine()) {
        String strLine = reader.nextLine();
        String arrLine[] = strLine.split(":");
        int vote = Integer.parseInt(arrLine[1]);
        _votes[i] = vote;

        i++;
      }
      reader.close();
    }

    _ballotPanel = new JPanel();
    _ballotPanel.setLayout(new GridLayout(_candidates.size() + 1, 1));

    _titleLabel = new JLabel(_title);
    _titleLabel.setHorizontalAlignment(JLabel.CENTER);
    _titleLabel.setFont(new Font("CourierNew", Font.PLAIN, 15));
    _ballotPanel.add(_titleLabel);

    for (int i = 0; i < _candidates.size(); i++) {
      // Make a JButton for each candidate in the ballot
      // Disable it by default. Will enable when the user logs in
      String cText = _candidates.get(i);
      JButton candidate = new JButton(cText);
      candidate.setEnabled(false);
      candidate.addActionListener(_buttonListener);

      _candidateButtons.add(candidate);
      _ballotPanel.add(candidate);
    }
  }
コード例 #3
0
ファイル: MediaConfiguration.java プロジェクト: onsip/jitsi
  /**
   * Create preview component.
   *
   * @param type type
   * @param comboBox the options.
   * @param prefSize the preferred size
   * @return the component.
   */
  private static Component createPreview(int type, final JComboBox comboBox, Dimension prefSize) {
    JComponent preview = null;

    if (type == DeviceConfigurationComboBoxModel.AUDIO) {
      Object selectedItem = comboBox.getSelectedItem();

      if (selectedItem instanceof AudioSystem) {
        AudioSystem audioSystem = (AudioSystem) selectedItem;

        if (!NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
          preview = new TransparentPanel(new GridBagLayout());
          createAudioSystemControls(audioSystem, preview);
        }
      }
    } else if (type == DeviceConfigurationComboBoxModel.VIDEO) {
      JLabel noPreview =
          new JLabel(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));

      noPreview.setHorizontalAlignment(SwingConstants.CENTER);
      noPreview.setVerticalAlignment(SwingConstants.CENTER);

      preview = createVideoContainer(noPreview);
      preview.setPreferredSize(prefSize);

      Object selectedItem = comboBox.getSelectedItem();
      CaptureDeviceInfo device = null;
      if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)
        device = ((DeviceConfigurationComboBoxModel.CaptureDevice) selectedItem).info;

      Exception exception;
      try {
        createVideoPreview(device, preview);
        exception = null;
      } catch (IOException ex) {
        exception = ex;
      } catch (MediaException ex) {
        exception = ex;
      }
      if (exception != null) {
        logger.error("Failed to create preview for device " + device, exception);
        device = null;
      }
    }

    return preview;
  }
コード例 #4
0
  public void init() {

    // <Begin_init>
    if (getParameter("RESOURCE_PROPERTIES") != null) {
      localePropertiesFileName = getParameter("RESOURCE_PROPERTIES");
    }
    resourceBundle =
        com.adventnet.apiutils.Utility.getBundle(
            localePropertiesFileName, getParameter("RESOURCE_LOCALE"), applet);
    if (initialized) return;
    this.setSize(getPreferredSize().width + 495, getPreferredSize().height + 480);
    setTitle(resourceBundle.getString("ViewConfig"));
    Container container = getContentPane();
    container.setLayout(new BorderLayout());
    try {
      initVariables();
      setUpGUI(container);
      setUpProperties();
      setUpConnections();
    } catch (Exception ex) {
      showStatus(resourceBundle.getString("Error in init method"), ex);
    }
    // let us set the initialized variable to true so
    // we dont initialize again even if init is called
    initialized = true;

    // <End_init>
    setTitle(resourceBundle.getString("View Configuration"));
    setIconImage(AuthMain.getBuilderUiIfInstance().getFrameIcon());
    JLabel1.setIcon(AuthMain.getBuilderUiIfInstance().getImage("viewconfig.png"));
    com.adventnet.security.ui.ViewListCellRenderer ViewListCellRenderer1 =
        new com.adventnet.security.ui.ViewListCellRenderer();
    JTable1.setDefaultRenderer(JTable1.getColumnClass(0), ViewListCellRenderer1);

    JLabel2.setIcon(AuthMain.getBuilderUiIfInstance().getImage("addview1.png"));
    JTable1.getCellEditor(0, 0)
        .getTableCellEditorComponent(JTable1, null, true, 0, 0)
        .setEnabled(false);
    DefaultCellEditor te = (DefaultCellEditor) JTable1.getCellEditor(0, 0);
    te.setClickCountToStart(10);
    JTable1.setCellEditor(te);

    JViewport vp = new JViewport();
    JLabel lab = new JLabel(resourceBundle.getString("List of available views"));
    lab.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT);
    lab.setForeground(Color.black);
    vp.setView(lab);

    AuthMain.getBuilderUiIfInstance().centerWindow(this);
    setData();

    viewc = this;

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            close();
          }
        });

    /*
    TableColumn col2  = JTable1.getColumnModel().getColumn(1);
    DefaultTableCellRenderer ren = new DefaultTableCellRenderer();
    ren.setIcon(AuthMain.getBuilderUiIfInstance().getImage("task1.png"));
    	col2.setCellRenderer(ren);
     	col2.setMaxWidth(30);
    */

    DefaultListSelectionModel selModel = new DefaultListSelectionModel();
    selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JTable1.setSelectionModel(selModel);
  }
コード例 #5
0
ファイル: TestWav.java プロジェクト: lmbvarela/cat200-9-2010
  private void makeFrame(String[] audioFiles) {
    // the following makes sure that our application exits when
    // the user closes its window
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(new EmptyBorder(6, 10, 10, 10));

    // Specify the layout manager with nice spacing
    contentPane.setLayout(new BorderLayout(8, 8));

    // Create the left side with combobox and scroll list
    JPanel leftPane = new JPanel();
    {
      leftPane.setLayout(new BorderLayout(8, 8));

      fileList = new JList(audioFiles);
      fileList.setForeground(new Color(140, 171, 226));
      fileList.setBackground(new Color(0, 0, 0));
      fileList.setSelectionBackground(new Color(87, 49, 134));
      fileList.setSelectionForeground(new Color(140, 171, 226));
      JScrollPane scrollPane = new JScrollPane(fileList);
      scrollPane.setColumnHeaderView(new JLabel("Audio files"));
      leftPane.add(scrollPane, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, BorderLayout.CENTER);

    // Create the center with image, text label, and slider
    JPanel centerPane = new JPanel();
    {
      centerPane.setLayout(new BorderLayout(8, 8));

      infoLabel = new JLabel("  ");
      infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
      infoLabel.setForeground(new Color(140, 171, 226));
      centerPane.add(infoLabel, BorderLayout.CENTER);
    }
    contentPane.add(centerPane, BorderLayout.EAST);

    // Create the toolbar with the buttons
    JPanel toolbar = new JPanel();
    {
      toolbar.setLayout(new GridLayout(1, 0));

      JButton button = new JButton("Play");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              play();
            }
          });
      toolbar.add(button);

      button = new JButton("Stop");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              stop();
            }
          });
      toolbar.add(button);

      button = new JButton("Pause");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              pause();
            }
          });
      toolbar.add(button);

      button = new JButton("Resume");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              resume();
            }
          });
      toolbar.add(button);
    }

    contentPane.add(toolbar, BorderLayout.NORTH);

    // building is done - arrange the components
    pack();

    // place this frame at the center of the screen and show
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);
    setVisible(true);
  }
コード例 #6
0
ファイル: SwingComponentUtils.java プロジェクト: piopawlu/ols
 /**
  * Creates a JLabel which text is right aligned.
  *
  * @param aText the text of the JLabel to create, may be <code>null</code>.
  * @return a JLabel instance, never <code>null</code>.
  */
 public static final JLabel createRightAlignedLabel(final String aText) {
   final JLabel label = new JLabel(aText);
   label.setHorizontalAlignment(SwingConstants.RIGHT);
   return label;
 }
コード例 #7
0
  /**
   * Create preview component.
   *
   * @param comboBox the options.
   * @return the component.
   */
  private static Component createPreview(final JComboBox comboBox) {
    final JComponent preview;

    JLabel noPreview =
        new JLabel(GuiActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));
    noPreview.setHorizontalAlignment(SwingConstants.CENTER);
    noPreview.setVerticalAlignment(SwingConstants.CENTER);

    preview = createVideoContainer(noPreview);

    preview.setPreferredSize(new Dimension(WIDTH, 280));
    preview.setMaximumSize(new Dimension(WIDTH, 280));

    final ActionListener comboBoxListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            MediaDevice device = (MediaDevice) comboBox.getSelectedItem();

            if ((device != null) && device.equals(videoDeviceInPreview)) return;

            Exception exception;
            try {
              createPreview(device, preview);
              exception = null;
            } catch (IOException ex) {
              exception = ex;
            } catch (MediaException ex) {
              exception = ex;
            }
            if (exception != null) {
              logger.error("Failed to create preview for device " + device, exception);

              device = null;
            }

            videoDeviceInPreview = device;
          }
        };
    comboBox.addActionListener(comboBoxListener);

    /*
     * We have to initialize the controls to reflect the configuration
     * at the time of creating this instance. Additionally, because the
     * video preview will stop when it and its associated controls
     * become unnecessary, we have to restart it when the mentioned
     * controls become necessary again. We'll address the two goals
     * described by pretending there's a selection in the video combo
     * box when the combo box in question becomes displayable.
     */
    comboBox.addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent event) {
            if (((event.getChangeFlags() & HierarchyEvent.DISPLAYABILITY_CHANGED) != 0)
                && comboBox.isDisplayable()) {
              // let current changes end their execution
              // and after that trigger action on combobox
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      comboBoxListener.actionPerformed(null);
                    }
                  });
            } else {
              if (!comboBox.isDisplayable()) videoDeviceInPreview = null;
            }
          }
        });

    return preview;
  }
コード例 #8
0
  public void execute_TestCase2() throws Exception {
    setUndecorated(true);
    setRootPaneCheckingEnabled(false);
    setForeground(Color.BLACK);
    setBackground(Color.WHITE);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 774, 353);
    setLocationRelativeTo(null);
    setVisible(true);

    contentPane = new JPanel();
    contentPane.setFocusCycleRoot(true);
    contentPane.setDebugGraphicsOptions(DebugGraphics.NONE_OPTION);
    contentPane.setBounds(new Rectangle(100, 100, 130, 100));
    contentPane.setBackground(Color.WHITE);
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblEnterThePath = new JLabel("Select Path of Working Folder");
    lblEnterThePath.setForeground(new Color(128, 128, 128));
    lblEnterThePath.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblEnterThePath.setBackground(new Color(0, 0, 0));
    lblEnterThePath.setBounds(63, 104, 187, 31);
    contentPane.add(lblEnterThePath);

    txtHello = new JTextField();
    txtHello.setName("");
    txtHello.setBounds(271, 104, 296, 31);
    txtHello.setEditable(false);
    contentPane.add(txtHello);
    txtHello.setColumns(10);

    JLabel lblSelectPathOf = new JLabel("Select Path of Configuration File");
    lblSelectPathOf.setForeground(new Color(128, 128, 128));
    lblSelectPathOf.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblSelectPathOf.setBounds(63, 149, 187, 28);
    contentPane.add(lblSelectPathOf);

    textField_1 = new JTextField();
    textField_1.setBounds(271, 146, 296, 31);
    textField_1.setEditable(false);
    contentPane.add(textField_1);
    textField_1.setColumns(10);

    JLabel lblWelcomeToVitalhealth = new JLabel("Welcome to VitalHealth Test Automation Framework");
    lblWelcomeToVitalhealth.setHorizontalTextPosition(SwingConstants.CENTER);
    lblWelcomeToVitalhealth.setForeground(new Color(128, 128, 128));
    lblWelcomeToVitalhealth.setFont(new Font("Tahoma", Font.BOLD, 14));
    lblWelcomeToVitalhealth.setHorizontalAlignment(SwingConstants.CENTER);
    lblWelcomeToVitalhealth.setBackground(Color.BLACK);
    lblWelcomeToVitalhealth.setBounds(191, 22, 465, 34);
    contentPane.add(lblWelcomeToVitalhealth);

    Button button = new Button("Browse");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            showOpenFileDialog();
          }
        });
    button.setForeground(Color.WHITE);
    button.setFont(new Font("Dialog", Font.BOLD, 12));
    button.setBackground(new Color(51, 153, 255));
    button.setBounds(573, 104, 113, 31);
    contentPane.add(button);

    Button button_1 = new Button("Browse");
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showOpenFileDialog1();
          }
        });
    button_1.setForeground(Color.WHITE);
    button_1.setFont(new Font("Dialog", Font.BOLD, 12));
    button_1.setBackground(new Color(51, 153, 255));
    button_1.setBounds(573, 146, 113, 31);
    contentPane.add(button_1);

    Button button_2 = new Button("RUN TEST");
    button_2.setForeground(Color.WHITE);
    button_2.setFont(new Font("Dialog", Font.BOLD, 12));
    button_2.setBackground(new Color(30, 144, 255));
    button_2.setBounds(63, 205, 623, 34);
    contentPane.add(button_2);

    Button button_3 = new Button("DOWNLOAD SAMPLE EXCEL WEB");
    button_3.setActionCommand("DOWNLOAD SAMPLE EXCEL WEB");
    button_3.setForeground(new Color(128, 128, 128));
    button_3.setFont(new Font("Dialog", Font.BOLD, 12));
    button_3.setBackground(Color.WHITE);
    button_3.setBounds(564, 309, 200, 34);
    contentPane.add(button_3);

    Button button_4 = new Button("DOWNLOAD SAMPLE EXCEL MOBILE");
    button_4.setForeground(new Color(128, 128, 128));
    button_4.setFont(new Font("Dialog", Font.BOLD, 12));
    button_4.setBackground(Color.WHITE);
    button_4.setActionCommand("DOWNLOAD SAMPLE EXCEL MOBILE");
    button_4.setBounds(23, 309, 227, 34);
    contentPane.add(button_4);

    JLabel icon = new JLabel("");
    Image img = new ImageIcon(this.getClass().getResource("/VitalHealth.png")).getImage();
    icon.setIcon(new ImageIcon(img));
    icon.setBounds(23, 11, 173, 71);
    contentPane.add(icon);

    // L1 l1 = new L1();
    L2 l2 = new L2();
    button_4.addActionListener(new L1(Constants.Download_ExcelWeb, Constants.Excel_NameMobile));
    button_3.addActionListener(new L1(Constants.Download_ExcelWeb, Constants.Excel_NameWeb));
    button_2.addActionListener(l2);
  }