/** * Implements <code>ApplicationWindow.show</code> method. * * @param isVisible specifies whether the frame is to be visible or not. */ @Override public void setVisible(boolean isVisible) { if (isVisible && configList.getSelectedIndex() < 0) { this.configList.setSelectedIndex(0); } super.setVisible(isVisible); }
/** * Adds action buttons. * * @param buttonsPanel the panel to add to. * @param listener the listener for actions * @param text the text on the button. * @param name name of the button. * @param linkColor the color of the link. */ private static void addActionButton( TransparentPanel buttonsPanel, ActionListener listener, String text, String name, Color linkColor) { SIPCommLinkButton button = new SIPCommLinkButton(text); button.setName(name); button.addActionListener(listener); button.setOpaque(false); button.setLinkColor(linkColor); TransparentPanel panel = new TransparentPanel(new BorderLayout()); panel.add(button, BorderLayout.WEST); buttonsPanel.add(panel); }
/** * Creates the video advanced settings. * * @return video advanced settings panel. */ private static Component createVideoAdvancedSettings() { ResourceManagementService resources = NeomediaActivator.getResources(); final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration(); TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout()); centerPanel.setMaximumSize(new Dimension(WIDTH, 150)); JButton resetDefaultsButton = new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET")); JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); resetButtonPanel.add(resetDefaultsButton); final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout()); centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH); centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 0); constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; constraints.gridy = 0; centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 0); final JCheckBox frameRateCheck = new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE")); centerPanel.add(frameRateCheck, constraints); constraints.gridy = 2; constraints.insets = new Insets(5, 5, 0, 0); centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")), constraints); constraints.weightx = 1; constraints.gridx = 1; constraints.gridy = 0; constraints.insets = new Insets(5, 0, 0, 5); Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1]; System.arraycopy( DeviceConfiguration.SUPPORTED_RESOLUTIONS, 0, resolutionValues, 1, DeviceConfiguration.SUPPORTED_RESOLUTIONS.length); final JComboBox sizeCombo = new JComboBox(resolutionValues); sizeCombo.setRenderer(new ResolutionCellRenderer()); sizeCombo.setEditable(false); centerPanel.add(sizeCombo, constraints); // default value is 20 final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1)); frameRate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } }); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 5); centerPanel.add(frameRate, constraints); frameRateCheck.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (frameRateCheck.isSelected()) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } else // unlimited framerate deviceConfig.setFrameRate(-1); frameRate.setEnabled(frameRateCheck.isSelected()); } }); final JSpinner videoMaxBandwidth = new JSpinner( new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1)); videoMaxBandwidth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setVideoMaxBandwidth( ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue()); } }); constraints.gridx = 1; constraints.gridy = 2; constraints.insets = new Insets(0, 0, 5, 5); centerPanel.add(videoMaxBandwidth, constraints); resetDefaultsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // reset to defaults sizeCombo.setSelectedIndex(0); frameRateCheck.setSelected(false); frameRate.setEnabled(false); frameRate.setValue(20); // unlimited framerate deviceConfig.setFrameRate(-1); videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH); } }); // load selected value or auto Dimension videoSize = deviceConfig.getVideoSize(); if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT) && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH)) sizeCombo.setSelectedItem(deviceConfig.getVideoSize()); else sizeCombo.setSelectedIndex(0); sizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem(); if (selectedVideoSize == null) { // the auto value, default one selectedVideoSize = new Dimension( DeviceConfiguration.DEFAULT_VIDEO_WIDTH, DeviceConfiguration.DEFAULT_VIDEO_HEIGHT); } deviceConfig.setVideoSize(selectedVideoSize); } }); frameRateCheck.setSelected( deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE); frameRate.setEnabled(frameRateCheck.isSelected()); if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate()); return centerAdvancedPanel; }
/** Init visible components. */ private void init() { TransparentPanel panel = new TransparentPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Title label JLabel titleLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.avatar.RECENT_ICONS")); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); // fix for displaying text in menu // when using a dark OS theme (as default one in ubuntu) titleLabel.setForeground(new JMenuItem().getForeground()); panel.add(titleLabel, BorderLayout.NORTH); // Init recent images grid TransparentPanel recentImagesGrid = new TransparentPanel(); recentImagesGrid.setLayout(new GridLayout(0, IMAGES_PER_COLUMN)); Dimension thumbsize = new Dimension(THUMB_WIDTH, THUMB_HEIGHT); for (int i = 0; i < MAX_STORED_IMAGES; i++) { this.recentImagesButtons[i] = new SIPCommButton(null); this.recentImagesButtons[i].setBorder(BorderFactory.createEtchedBorder()); this.recentImagesButtons[i].setMaximumSize(thumbsize); this.recentImagesButtons[i].setMinimumSize(thumbsize); this.recentImagesButtons[i].setPreferredSize(thumbsize); this.recentImagesButtons[i].addActionListener(this); this.recentImagesButtons[i].setName("" + i); recentImagesGrid.add(this.recentImagesButtons[i]); } panel.add(recentImagesGrid, BorderLayout.CENTER); // Action buttons TransparentPanel buttonsPanel = new TransparentPanel(); buttonsPanel.setLayout(new GridLayout(0, 1)); // we use this menu item just to get its foreground color. Color linkColor = new JMenuItem().getForeground(); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CHOOSE_ICON"), CHOSE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.REMOVE_ICON"), REMOVE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CLEAR_RECENT"), CLEAR_BUTTON_NAME, linkColor); panel.add(buttonsPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); }