public CopyFileToTable() { JPanel jPane1 = new JPanel(); jPane1.setLayout(new BorderLayout()); jPane1.add(new JLabel("Filename"), BorderLayout.WEST); jPane1.add(jbtViewFile, BorderLayout.EAST); jPane1.add(jtfFilename, BorderLayout.CENTER); JPanel jPane2 = new JPanel(); jPane2.setLayout(new BorderLayout()); jPane2.setBorder(new TitledBorder("Source Text File")); jPane2.add(jPane1, BorderLayout.NORTH); jPane2.add(new JScrollPane(jtaFile), BorderLayout.CENTER); JPanel jPane3 = new JPanel(); jPane3.setLayout(new GridLayout(5, 0)); jPane3.add(new JLabel("JDBC Driver")); jPane3.add(new JLabel("Database URL")); jPane3.add(new JLabel("Username")); jPane3.add(new JLabel("Password")); jPane3.add(new JLabel("Table Name")); JPanel jPane4 = new JPanel(); jPane4.setLayout(new GridLayout(5, 0)); jcboDriver.setEditable(true); jPane4.add(jcboDriver); jcboURL.setEditable(true); jPane4.add(jcboURL); jPane4.add(jtfUsername); jPane4.add(jtfPassword); jPane4.add(jtfTableName); JPanel jPane5 = new JPanel(); jPane5.setLayout(new BorderLayout()); jPane5.setBorder(new TitledBorder("Target Database Table")); jPane5.add(jbtCopy, BorderLayout.SOUTH); jPane5.add(jPane3, BorderLayout.WEST); jPane5.add(jPane4, BorderLayout.CENTER); add(jlblStatus, BorderLayout.SOUTH); add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPane2, jPane5), BorderLayout.CENTER); jbtViewFile.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { showFile(); } }); jbtCopy.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { copyFile(); } catch (Exception ex) { jlblStatus.setText(ex.toString()); } } }); }
private void createComponents(JPanel p) { String tt = "Any of these: 45.5 -120.2 or 45 30 0 n 120 12 0 w or Seattle"; JComboBox field = new JComboBox(); field.setOpaque(false); field.setEditable(true); field.setLightWeightPopupEnabled(false); field.setPreferredSize(new Dimension(200, field.getPreferredSize().height)); field.setToolTipText(tt); JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png")); // new // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png"))); label.setOpaque(false); label.setToolTipText(tt); p.add(label, BorderLayout.WEST); p.add(field, BorderLayout.CENTER); field.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { performGazeteerAction(actionEvent); } }); }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }
public Mapper() { super("Action/Input Mapper"); setSize(500, 600); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel setupPane = new JPanel(new GridLayout(0, 1)); JPanel classPane = new JPanel(new BorderLayout()); classPane.add(new JLabel("Class: "), BorderLayout.WEST); classPane.add(nameF, BorderLayout.CENTER); classPane.add(stateC, BorderLayout.EAST); JPanel mapPane = new JPanel(); mapPane.add(inputB); mapPane.add(actionB); mapPane.add(bindingB); setupPane.add(classPane); setupPane.add(mapPane); getContentPane().add(setupPane, BorderLayout.NORTH); getContentPane().add(new JScrollPane(results), BorderLayout.CENTER); nameF.addActionListener(this); stateC.addActionListener(this); stateC.setEditable(false); new Probe().loadAudioActions(); // !!! setVisible(true); }
public ComboBoxDemo2() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); JComboBox patternList = new JComboBox(patternExamples); patternList.setEditable(true); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); } // constructor
private static JComboBox<String> makeComboBox(final boolean isDefault, boolean isEditable) { ComboBoxModel<String> m = new DefaultComboBoxModel<>(new String[] {"aaa", "bbb", "ccc"}); JComboBox<String> comboBox; if (isDefault) { comboBox = new JComboBox<>(m); } else { comboBox = new RemoveButtonComboBox<String>(m); } comboBox.setEditable(isEditable); return comboBox; }
public CustomizableComboBox() { super(new BorderLayout()); myThemedCombo.setEditable(true); PopupMouseListener listener = new PopupMouseListener(); // GTK always draws a border on the textbox. It cannot be removed, // so to compensate, we remove our own border so we don't have a double border. if (UIUtil.isUnderGTKLookAndFeel()) { this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); } else { this.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createLineBorder(getBorderColor(), 1))); } // Try to turn off the border on the JTextField. myTextField = new JBTextField() { @Override public void setBorder(Border border) { super.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); } }; myTextField.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); myTextField.addMouseListener(listener); myTextField.addFocusListener( new FocusListener() { @Override public void focusGained(FocusEvent e) { myTextField.selectAll(); } @Override public void focusLost(FocusEvent e) { // no-op } }); JButton popupButton = createArrowButton(); popupButton.addMouseListener(listener); this.add(popupButton, BorderLayout.EAST); this.add(myTextField, BorderLayout.CENTER); }
public FindProf() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Search your campus!"); JLabel patternLabel2 = new JLabel(""); patternList = new JComboBox<Object>(searchNames); patternList.setEditable(true); patternList.setMaximumRowCount(5); patternList.addActionListener(this); // Create the UI for displaying result. JLabel resultLabel = new JLabel("Building Initials & Room Number:", JLabel.LEADING); // == LEFT result = new JLabel(" "); result.setHorizontalAlignment(SwingConstants.CENTER); result.setForeground(Color.black); result.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything. JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); patternPanel.add(patternList); JPanel resultPanel = new JPanel(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT); resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT); add(patternPanel); add(Box.createRigidArea(new Dimension(0, 10))); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } // constructor
protected void addMyControls() { // add browser-style control buttons JButton home = new JButton(new ImageIcon("data/Home24.gif")); JButton back = new JButton(new ImageIcon("data/Back24.gif")); JButton fwd = new JButton(new ImageIcon("data/Forward24.gif")); home.setToolTipText("Home"); home.addActionListener(this); home.setActionCommand(homeCmd); back.setToolTipText("Back"); back.addActionListener(this); back.setActionCommand(backCmd); back.setEnabled(false); // initially disabled fwd.setToolTipText("Forward"); fwd.addActionListener(this); fwd.setActionCommand(forwardCmd); fwd.setEnabled(false); // initially disabled add(home); add(back); add(fwd); add(new JToolBar.Separator()); // set built-in index variables homeIndex = getComponentIndex(home); backIndex = getComponentIndex(back); forwardIndex = getComponentIndex(fwd); JComboBox comboBox = new JComboBox(); comboBox.setEditable(true); comboBox.addActionListener(this); comboBox.setActionCommand(comboCmd); comboBox.setMaximumRowCount(3); // don't let it get too long comboBox.insertItemAt(mainBrowserURL, 0); // don't start it out empty add(comboBox); comboBoxIndex = getComponentIndex(comboBox); }
/* * The following method creates the combo box with font size choices * postcondition: returns the panel containing the size combo box. */ public JPanel createSizeComboBox() { sizeCombo = new JComboBox(); sizeCombo.addItem(SMALLEST); sizeCombo.addItem(SMALL); sizeCombo.addItem(SMALL_MEDIUM); sizeCombo.addItem(MEDIUM); sizeCombo.addItem(MEDIUM_LARGE); sizeCombo.addItem(LARGE); sizeCombo.addItem(LARGEST); sizeCombo.addItem(HUGE); sizeCombo.addItem(WOW); sizeCombo.setEditable(true); // facenameCombo.addActionListener(this); sizeCombo.setSelectedIndex(2); JPanel panel = new JPanel(); panel.add(sizeCombo); panel.setBorder(new TitledBorder(new EtchedBorder(), "Font Name")); return panel; } // end createComboBox method
public ResourceEditor( @Nullable ResourceType[] types, Set<AttributeFormat> formats, @Nullable String[] values) { myTypes = types; myIsDimension = formats.contains(AttributeFormat.Dimension); if (formats.contains(AttributeFormat.Boolean)) { myCheckBox = new JCheckBox(); myEditor = new ComponentWithBrowseButton<JCheckBox>(myCheckBox, null) { @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myCheckBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (!myIgnoreCheckBoxValue) { myBooleanResourceValue = null; fireValueCommitted(false, true); } } }); } else if (formats.contains(AttributeFormat.Enum)) { ComboboxWithBrowseButton editor = new ComboboxWithBrowseButton(SystemInfo.isWindows ? new MyComboBox() : new JComboBox()) { @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; final JComboBox comboBox = editor.getComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(values); model.insertElementAt(StringsComboEditor.UNSET, 0); comboBox.setModel(model); comboBox.setEditable(true); ComboEditor.installListeners( comboBox, new ComboEditor.ComboEditorListener(this) { @Override protected void onValueChosen() { if (comboBox.getSelectedItem() == StringsComboEditor.UNSET) { comboBox.setSelectedItem(null); } super.onValueChosen(); } }); myEditor = editor; comboBox.setSelectedIndex(0); } else { myEditor = new TextFieldWithBrowseButton() { @Override protected void installPathCompletion( FileChooserDescriptor fileChooserDescriptor, @Nullable Disposable parent) {} @Override public Dimension getPreferredSize() { return getComponentPreferredSize(); } }; myEditor.registerKeyboardAction( new ActionListener() { @Override public void actionPerformed(ActionEvent e) {} }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); JTextField textField = getComboText(); textField.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireValueCommitted(false, true); } }); textField .getDocument() .addDocumentListener( new DocumentAdapter() { @Override protected void textChanged(final DocumentEvent e) { preferredSizeChanged(); } }); selectTextOnFocusGain(textField); } if (myCheckBox == null) { myEditor.registerKeyboardAction( new ActionListener() { @Override public void actionPerformed(ActionEvent e) {} }, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } myEditor.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showDialog(); } }); myEditor.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent e) { myEditor.getChildComponent().requestFocus(); } }); }
/** setup page2 of the wizard */ protected void makePageTwo() { FontResource fonts = FontResource.getInstance(); // grid bag constraints GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(2, 2, 2, 0); gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.BOTH; // >>>>> Page 2 wizardPages[1].setLayout(new GridBagLayout()); wizardPages[1].setAutoscrolls(true); // the following needed for the autoscrolls features wizardPages[1].addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); ((JPanel) e.getSource()).scrollRectToVisible(r); } }); // add a label for description descriptionLabel2 = new JLabel(stepDescriptions[1], JLabel.LEFT); descriptionLabel2.setFont(fonts.getDescriptionFont()); gbc.insets = new Insets(2, 2, 6, 0); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.SOUTH; wizardPages[1].add(descriptionLabel2, gbc); // and add the options automatedFragmentation = new JComboBox(); automatedFragmentation.setEditable(false); automatedFragmentation.addItem("No, thanks; Show me other options."); automatedFragmentation.addItem("Yes, Please!"); automatedFragmentation.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (ie.getItem().equals("Yes, Please!")) { methodDescription.setText("Allows you to do automated fragmentation."); } else { methodDescription.setText("Allows you to do manual selection of fragments."); } // end if } }); gbc.gridx = 0; gbc.gridy = 1; wizardPages[1].add(automatedFragmentation, gbc); // and add the description lable for the fragmentation method methodDescription = new JLabel("Allows you to do manual selection of fragments.", JLabel.LEFT); methodDescription.setFont(fonts.getSmallFont()); gbc.insets = new Insets(6, 2, 6, 0); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.SOUTH; wizardPages[1].add(methodDescription, gbc); }
/* * The following method creates the combo box with font style choices * postcondition: returns the panel containing the combo box. */ public JPanel createFacenameComboBox() { // YOU MUST ALTER THESE BASED ON YOUR SYSTEM. facenameCombo = new JComboBox(); facenameCombo.addItem(new String("Times")); facenameCombo.addItem(new String("Agent Orange")); facenameCombo.addItem(new String("Aldo's Nova")); facenameCombo.addItem(new String("American Typewriter")); facenameCombo.addItem(new String("American Typewriter Condensed")); facenameCombo.addItem(new String("American Typewriter Light")); facenameCombo.addItem(new String("Andale Mono")); facenameCombo.addItem(new String("AntsyPants")); facenameCombo.addItem(new String("Apple Chancery")); facenameCombo.addItem(new String("Arial")); facenameCombo.addItem(new String("Arial Black")); facenameCombo.addItem(new String("Arial Narrow")); facenameCombo.addItem(new String("Aristocrat LET")); facenameCombo.addItem(new String("AstigamaTizm")); facenameCombo.addItem(new String("BASEHEAD")); facenameCombo.addItem(new String("Baskerville")); facenameCombo.addItem(new String("BellBottom")); facenameCombo.addItem(new String("Bertram LET")); facenameCombo.addItem(new String("BiauKai")); facenameCombo.addItem(new String("Bickley Script LET")); facenameCombo.addItem(new String("Bite me")); facenameCombo.addItem(new String("Bizarro")); facenameCombo.addItem(new String("Bodoni Ornaments ITC TT")); facenameCombo.addItem(new String("Calaveras")); facenameCombo.addItem(new String("Capitals")); facenameCombo.addItem(new String("Century Gothic")); facenameCombo.addItem(new String("Chalkboard")); facenameCombo.addItem(new String("Charcoal")); facenameCombo.addItem(new String("Chicago")); facenameCombo.addItem(new String("Cochin")); facenameCombo.addItem(new String("Comic Sans MS")); facenameCombo.addItem(new String("Copperplate")); facenameCombo.addItem(new String("Courier")); facenameCombo.addItem(new String("Courier New")); facenameCombo.addItem(new String("Curlz MT")); facenameCombo.addItem(new String("Didot")); facenameCombo.addItem(new String("Edwardian Script ITC")); facenameCombo.addItem(new String("Fang Song")); facenameCombo.addItem(new String("Fortuna Dot")); facenameCombo.addItem(new String("Futura")); facenameCombo.addItem(new String("Gadget")); facenameCombo.addItem(new String("Geeza Pro")); facenameCombo.addItem(new String("Geneva")); facenameCombo.addItem(new String("Georgia")); facenameCombo.addItem(new String("Gill Sans")); facenameCombo.addItem(new String("Gringo Nights")); facenameCombo.addItem(new String("Hei")); facenameCombo.addItem(new String("Helvetica")); facenameCombo.addItem(new String("Herculanum")); facenameCombo.addItem(new String("Hypmotizin")); facenameCombo.addItem(new String("Impact")); facenameCombo.addItem(new String("Jokerman LET")); facenameCombo.addItem(new String("MadisonSquare")); facenameCombo.addItem(new String("MammaGamma")); facenameCombo.addItem(new String("Mathmos Original")); facenameCombo.addItem(new String("MammaGamma")); facenameCombo.addItem(new String("Marker Felt")); facenameCombo.addItem(new String("MassiveHeadache3")); facenameCombo.addItem(new String("Parry Hotter")); facenameCombo.setEditable(true); // facenameCombo.addActionListener(this); JPanel panel = new JPanel(); panel.add(facenameCombo); panel.setBorder(new TitledBorder(new EtchedBorder(), "Font Name")); return panel; } // end createComboBox method
/** * Creates basic controls for a type (AUDIO or VIDEO). * * @param type the type. * @return the build Component. */ public static Component createBasicControls(final int type) { final JComboBox deviceComboBox = new JComboBox(); deviceComboBox.setEditable(false); deviceComboBox.setModel( new DeviceConfigurationComboBoxModel( deviceComboBox, mediaService.getDeviceConfiguration(), type)); JLabel deviceLabel = new JLabel(getLabelText(type)); deviceLabel.setDisplayedMnemonic(getDisplayedMnemonic(type)); deviceLabel.setLabelFor(deviceComboBox); final Container devicePanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); devicePanel.setMaximumSize(new Dimension(WIDTH, 25)); devicePanel.add(deviceLabel); devicePanel.add(deviceComboBox); final JPanel deviceAndPreviewPanel = new TransparentPanel(new BorderLayout()); int preferredDeviceAndPreviewPanelHeight; switch (type) { case DeviceConfigurationComboBoxModel.AUDIO: preferredDeviceAndPreviewPanelHeight = 225; break; case DeviceConfigurationComboBoxModel.VIDEO: preferredDeviceAndPreviewPanelHeight = 305; break; default: preferredDeviceAndPreviewPanelHeight = 0; break; } if (preferredDeviceAndPreviewPanelHeight > 0) deviceAndPreviewPanel.setPreferredSize( new Dimension(WIDTH, preferredDeviceAndPreviewPanelHeight)); deviceAndPreviewPanel.add(devicePanel, BorderLayout.NORTH); final ActionListener deviceComboBoxActionListener = new ActionListener() { public void actionPerformed(ActionEvent event) { boolean revalidateAndRepaint = false; for (int i = deviceAndPreviewPanel.getComponentCount() - 1; i >= 0; i--) { Component c = deviceAndPreviewPanel.getComponent(i); if (c != devicePanel) { deviceAndPreviewPanel.remove(i); revalidateAndRepaint = true; } } Component preview = null; if ((deviceComboBox.getSelectedItem() != null) && deviceComboBox.isShowing()) { preview = createPreview(type, deviceComboBox, deviceAndPreviewPanel.getPreferredSize()); } if (preview != null) { deviceAndPreviewPanel.add(preview, BorderLayout.CENTER); revalidateAndRepaint = true; } if (revalidateAndRepaint) { deviceAndPreviewPanel.revalidate(); deviceAndPreviewPanel.repaint(); } } }; deviceComboBox.addActionListener(deviceComboBoxActionListener); /* * 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. */ deviceComboBox.addHierarchyListener( new HierarchyListener() { public void hierarchyChanged(HierarchyEvent event) { if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { SwingUtilities.invokeLater( new Runnable() { public void run() { deviceComboBoxActionListener.actionPerformed(null); } }); } } }); return deviceAndPreviewPanel; }
/** * 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; }
public JComponent buildCommon() { String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.EMPTY_BORDER); builder.setOpaque(false); CellConstraints cc = new CellConstraints(); maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize()); maxbuffer.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(maxbuffer.getText()); configuration.setMaxMemoryBufferSize(ab); } catch (NumberFormatException nfe) { LOGGER.debug( "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\""); } } }); JComponent cmp = builder.addSeparator( Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel( Messages.getString("NetworkTab.6") .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()), FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation)); builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation)); String nCpusLabel = String.format( Messages.getString("NetworkTab.7"), Runtime.getRuntime().availableProcessors()); builder.addLabel(nCpusLabel, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation)); String[] guiCores = new String[MAX_CORES]; for (int i = 0; i < MAX_CORES; i++) { guiCores[i] = Integer.toString(i + 1); } nbcores = new JComboBox(guiCores); nbcores.setEditable(false); int nbConfCores = configuration.getNumberOfCpuCores(); if (nbConfCores > 0 && nbConfCores <= MAX_CORES) { nbcores.setSelectedItem(Integer.toString(nbConfCores)); } else { nbcores.setSelectedIndex(0); } nbcores.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString())); } }); builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation)); chapter_interval = new JTextField("" + configuration.getChapterInterval()); chapter_interval.setEnabled(configuration.isChapterSupport()); chapter_interval.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(chapter_interval.getText()); configuration.setChapterInterval(ab); } catch (NumberFormatException nfe) { LOGGER.debug( "Could not parse chapter interval from \"" + chapter_interval.getText() + "\""); } } }); chapter_support = new JCheckBox(Messages.getString("TrTab2.52")); chapter_support.setContentAreaFilled(false); chapter_support.setSelected(configuration.isChapterSupport()); chapter_support.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED)); chapter_interval.setEnabled(configuration.isChapterSupport()); } }); builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation)); cmp = builder.addSeparator( Messages.getString("TrTab2.3"), FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); channels = new JComboBox( new Object[] { Messages.getString("TrTab2.55"), Messages.getString("TrTab2.56") /*, "8 channels 7.1" */ }); // 7.1 not supported by Mplayer :\ channels.setEditable(false); if (configuration.getAudioChannelCount() == 2) { channels.setSelectedIndex(0); } else { channels.setSelectedIndex(1); } channels.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setAudioChannelCount( Integer.parseInt(e.getItem().toString().substring(0, 1))); } }); builder.addLabel( Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation)); builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation)); forcePCM = new JCheckBox(Messages.getString("TrTab2.27")); forcePCM.setContentAreaFilled(false); if (configuration.isMencoderUsePcm()) { forcePCM.setSelected(true); } forcePCM.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation)); ac3remux = new JCheckBox( Messages.getString("MEncoderVideo.32") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); ac3remux.setContentAreaFilled(false); if (configuration.isRemuxAC3()) { ac3remux.setSelected(true); } ac3remux.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation)); forceDTSinPCM = new JCheckBox( Messages.getString("TrTab2.28") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); forceDTSinPCM.setContentAreaFilled(false); if (configuration.isDTSEmbedInPCM()) { forceDTSinPCM.setSelected(true); } forceDTSinPCM.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected()); if (configuration.isDTSEmbedInPCM()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("TrTab2.10"), "Information", JOptionPane.INFORMATION_MESSAGE); } } }); builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation)); abitrate = new JTextField("" + configuration.getAudioBitrate()); abitrate.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { try { int ab = Integer.parseInt(abitrate.getText()); configuration.setAudioBitrate(ab); } catch (NumberFormatException nfe) { LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\""); } } }); builder.addLabel( Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation)); builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation)); mpeg2remux = new JCheckBox( Messages.getString("MEncoderVideo.39") + (Platform.isWindows() ? Messages.getString("TrTab2.21") : "")); mpeg2remux.setContentAreaFilled(false); if (configuration.isMencoderRemuxMPEG2()) { mpeg2remux.setSelected(true); } mpeg2remux.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation)); cmp = builder.addSeparator( Messages.getString("TrTab2.4"), FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel( Messages.getString("TrTab2.32"), FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation)); Object data[] = new Object[] { configuration.getMencoderMainSettings(), /* default */ String.format( "keyint=5:vqscale=1:vqmin=2 /* %s */", Messages.getString("TrTab2.60")), /* great */ String.format( "keyint=5:vqscale=1:vqmin=1 /* %s */", Messages.getString("TrTab2.61")), /* lossless */ String.format( "keyint=5:vqscale=2:vqmin=3 /* %s */", Messages.getString("TrTab2.62")), /* good (wired) */ String.format( "keyint=25:vqmax=5:vqmin=2 /* %s */", Messages.getString("TrTab2.63")), /* good (wireless) */ String.format( "keyint=25:vqmax=7:vqmin=2 /* %s */", Messages.getString("TrTab2.64")), /* medium (wireless) */ String.format( "keyint=25:vqmax=8:vqmin=3 /* %s */", Messages.getString("TrTab2.65")) /* low */ }; MyComboBoxModel cbm = new MyComboBoxModel(data); vq = new JComboBox(cbm); vq.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { String s = (String) e.getItem(); if (s.indexOf("/*") > -1) { s = s.substring(0, s.indexOf("/*")).trim(); } configuration.setMencoderMainSettings(s); } } }); vq.getEditor() .getEditorComponent() .addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { vq.getItemListeners()[0].itemStateChanged( new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED)); } }); vq.setEditable(true); builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation)); String help1 = Messages.getString("TrTab2.39"); help1 += Messages.getString("TrTab2.40"); help1 += Messages.getString("TrTab2.41"); help1 += Messages.getString("TrTab2.42"); help1 += Messages.getString("TrTab2.43"); help1 += Messages.getString("TrTab2.44"); JTextArea decodeTips = new JTextArea(help1); decodeTips.setEditable(false); decodeTips.setBorder(BorderFactory.createEtchedBorder()); decodeTips.setBackground(new Color(255, 255, 192)); builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation)); disableSubs = new JCheckBox(Messages.getString("TrTab2.51")); disableSubs.setContentAreaFilled(false); cmp = builder.addSeparator( Messages.getString("TrTab2.7"), FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation)); builder.addLabel( Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation)); notranscode = new JTextField(configuration.getNoTranscode()); notranscode.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { configuration.setNoTranscode(notranscode.getText()); } }); builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation)); builder.addLabel( Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation)); forcetranscode = new JTextField(configuration.getForceTranscode()); forcetranscode.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent e) {} @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) { configuration.setForceTranscode(forcetranscode.getText()); } }); builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); return panel; }
/** * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>. * * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details * are to be created * @param container the <tt>JComponent</tt> into which the UI controls which are to control the * details of the specified <tt>audioSystem</tt> are to be added */ public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) { GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weighty = 0; int audioSystemFeatures = audioSystem.getFeatures(); boolean featureNotifyAndPlaybackDevices = ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0); constraints.gridx = 0; constraints.insets = new Insets(3, 0, 3, 3); constraints.weightx = 0; constraints.gridy = 0; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints); if (featureNotifyAndPlaybackDevices) { constraints.gridy = 2; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints); constraints.gridy = 3; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints); } constraints.gridx = 1; constraints.insets = new Insets(3, 3, 3, 0); constraints.weightx = 1; JComboBox captureCombo = null; if (featureNotifyAndPlaybackDevices) { captureCombo = new JComboBox(); captureCombo.setEditable(false); captureCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)); constraints.gridy = 0; container.add(captureCombo, constraints); } int anchor = constraints.anchor; SoundLevelIndicator capturePreview = new SoundLevelIndicator( SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL); constraints.anchor = GridBagConstraints.CENTER; constraints.gridy = (captureCombo == null) ? 0 : 1; container.add(capturePreview, constraints); constraints.anchor = anchor; constraints.gridy = GridBagConstraints.RELATIVE; if (featureNotifyAndPlaybackDevices) { JComboBox playbackCombo = new JComboBox(); playbackCombo.setEditable(false); playbackCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)); container.add(playbackCombo, constraints); JComboBox notifyCombo = new JComboBox(); notifyCombo.setEditable(false); notifyCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)); container.add(notifyCombo, constraints); } if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) { final SIPCommCheckBox echoCancelCheckBox = new SIPCommCheckBox( NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL")); /* * First set the selected one, then add the listener in order to * avoid saving the value when using the default one and only * showing to user without modification. */ echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel()); echoCancelCheckBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected()); } }); container.add(echoCancelCheckBox, constraints); } if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) { final SIPCommCheckBox denoiseCheckBox = new SIPCommCheckBox( NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE")); /* * First set the selected one, then add the listener in order to * avoid saving the value when using the default one and only * showing to user without modification. */ denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise()); denoiseCheckBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected()); } }); container.add(denoiseCheckBox, constraints); } createAudioPreview(audioSystem, captureCombo, capturePreview); }
public QueryDBFrame() { setTitle("QueryDB"); setSize(400, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); authors = new JComboBox(); authors.setEditable(false); authors.addItem("Any"); publishers = new JComboBox(); publishers.setEditable(false); publishers.addItem("Any"); result = new JTextArea(4, 50); result.setEditable(false); priceChange = new JTextField(8); priceChange.setText("-5.00"); try { // 连接数据库 con = getConnection(); stmt = con.createStatement(); // 将数据库中的作者名添加到组合框 String query = "SELECT Name FROM Authors"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) authors.addItem(rs.getString(1)); // 将出版社名添加到组合框 query = "SELECT Name FROM Publishers"; rs = stmt.executeQuery(query); while (rs.next()) publishers.addItem(rs.getString(1)); } catch (Exception e) { result.setText("Error " + e); } gbc.fill = GridBagConstraints.NONE; gbc.weightx = 100; gbc.weighty = 100; add(authors, gbc, 0, 0, 2, 1); add(publishers, gbc, 2, 0, 2, 1); gbc.fill = GridBagConstraints.NONE; JButton queryButton = new JButton("Query"); queryButton.addActionListener(this); add(queryButton, gbc, 0, 1, 1, 1); JButton changeButton = new JButton("Change prices"); changeButton.addActionListener(this); add(changeButton, gbc, 2, 1, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; add(priceChange, gbc, 3, 1, 1, 1); gbc.fill = GridBagConstraints.BOTH; add(result, gbc, 0, 2, 4, 1); }
/** setup page1 of the wizard */ protected void makePageOne() { FontResource fonts = FontResource.getInstance(); // grid bag constraints GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(2, 2, 2, 0); gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.BOTH; // >>>>> Page 1 wizardPages[0].setLayout(new GridBagLayout()); wizardPages[0].setAutoscrolls(true); // the following needed for the autoscrolls features wizardPages[0].addMouseMotionListener( new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); ((JPanel) e.getSource()).scrollRectToVisible(r); } }); fragmentSchemeNameGroup = new ButtonGroup(); // scheme name choosers... first a new name newFragmentSchemeName = new JRadioButton("Specify name for Fragmentation Scheme: *"); fragmentSchemeNameGroup.add(newFragmentSchemeName); newFragmentSchemeName.setSelected(true); newFragmentSchemeName.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { // enable the relevent components fragmentSchemeName.setEnabled(true); fragmentSchemeNameHelpLabel.setEnabled(true); // and disable the irrelevent ones fragmentSchemes.setEnabled(false); } }); gbc.gridx = 0; gbc.gridy = 0; wizardPages[0].add(newFragmentSchemeName, gbc); fragmentSchemeName = new JTextField(); gbc.gridx = 0; gbc.gridy = 1; wizardPages[0].add(fragmentSchemeName, gbc); // instruction ... fragmentSchemeNameHelpLabel = new JLabel( "* A name helps you identify" + " a scheme and compare with others.", JLabel.LEFT); fragmentSchemeNameHelpLabel.setFont(fonts.getSmallFont()); gbc.insets = new Insets(1, 5, 2, 0); gbc.gridx = 0; gbc.gridy = 2; wizardPages[0].add(fragmentSchemeNameHelpLabel, gbc); // OR... orLabel = new JLabel("Or", JLabel.LEFT); orLabel.setFont(fonts.getTaskGroupFont()); gbc.insets = new Insets(2, 2, 2, 0); gbc.gridx = 0; gbc.gridy = 3; wizardPages[0].add(orLabel, gbc); // scheme name choosers... from an existing name existingFragmentSchemeName = new JRadioButton("Choose an existing Fragmentation Scheme to add the new fragment: "); fragmentSchemeNameGroup.add(existingFragmentSchemeName); existingFragmentSchemeName.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { // enable the relevent components fragmentSchemes.setEnabled(true); // and disable the irrelevent ones fragmentSchemeName.setEnabled(false); fragmentSchemeNameHelpLabel.setEnabled(false); } }); gbc.gridx = 0; gbc.gridy = 4; wizardPages[0].add(existingFragmentSchemeName, gbc); // and then show the fragment schemes // TODO ... fill up this combo fragmentSchemes = new JComboBox(); fragmentSchemes.setEditable(false); fragmentSchemes.setEnabled(false); gbc.gridx = 0; gbc.gridy = 5; wizardPages[0].add(fragmentSchemes, gbc); // and finally add a label for description descriptionLabel1 = new JLabel(stepDescriptions[0], JLabel.LEFT); descriptionLabel1.setFont(fonts.getDescriptionFont()); gbc.insets = new Insets(6, 2, 2, 0); gbc.gridx = 0; gbc.gridy = 6; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.SOUTH; wizardPages[0].add(descriptionLabel1, gbc); }
/** Display a frame for browsing issues. */ private JPanel constructView() { // sort the original issues list final SortedList<Issue> issuesSortedList = new SortedList<Issue>(issuesEventList, null); // filter the sorted issues FilterList<Issue> filteredIssues = new FilterList<Issue>(issuesSortedList, filterPanel.getMatcherEditor()); SeparatorList<Issue> separatedIssues = new SeparatorList<Issue>( filteredIssues, GlazedLists.beanPropertyComparator(Issue.class, "subcomponent"), 0, Integer.MAX_VALUE); EventList<Issue> separatedIssuesProxyList = GlazedListsSwing.swingThreadProxyList(separatedIssues); // build the issues table issuesTableModel = GlazedListsSwing.eventTableModel(separatedIssuesProxyList, new IssueTableFormat()); final TableColumnModel issuesTableColumnModel = new EventTableColumnModel<TableColumn>(new BasicEventList<TableColumn>()); JSeparatorTable issuesJTable = new JSeparatorTable(issuesTableModel, issuesTableColumnModel); issuesJTable.setAutoCreateColumnsFromModel(true); issuesJTable.setSeparatorRenderer(new IssueSeparatorTableCell(separatedIssues)); issuesJTable.setSeparatorEditor(new IssueSeparatorTableCell(separatedIssues)); issuesSelectionModel = GlazedListsSwing.eventSelectionModel(separatedIssuesProxyList); issuesSelectionModel.setSelectionMode( ListSelection .MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); // multi-selection best demos our awesome // selection management issuesSelectionModel.addListSelectionListener(new IssuesSelectionListener()); issuesJTable.setSelectionModel(issuesSelectionModel); issuesJTable.getColumnModel().getColumn(0).setPreferredWidth(150); issuesJTable.getColumnModel().getColumn(1).setPreferredWidth(400); issuesJTable.getColumnModel().getColumn(2).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(3).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(4).setPreferredWidth(250); issuesJTable.getColumnModel().getColumn(5).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(6).setPreferredWidth(300); issuesJTable.getColumnModel().getColumn(7).setPreferredWidth(1000); // turn off cell focus painting issuesJTable.setDefaultRenderer( String.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(String.class))); issuesJTable.setDefaultRenderer( Integer.class, new NoFocusRenderer(issuesJTable.getDefaultRenderer(Integer.class))); issuesJTable.setDefaultRenderer( Priority.class, new NoFocusRenderer(new PriorityTableCellRenderer())); LookAndFeelTweaks.tweakTable(issuesJTable); TableComparatorChooser.install( issuesJTable, issuesSortedList, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); JScrollPane issuesTableScrollPane = new JScrollPane( issuesJTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); issuesTableScrollPane.getViewport().setBackground(UIManager.getColor("EditorPane.background")); issuesTableScrollPane.setBorder(BorderFactory.createEmptyBorder()); issueDetails = new IssueDetailsComponent(filteredIssues); // projects EventList<Project> projects = Project.getProjects(); TransformedList<Project, Project> projectsProxyList = GlazedListsSwing.swingThreadProxyList(projects); // project select combobox DefaultEventComboBoxModel projectsComboModel = new DefaultEventComboBoxModel<Project>(projectsProxyList); JComboBox projectsCombo = new JComboBox(projectsComboModel); projectsCombo.setEditable(false); projectsCombo.setOpaque(false); projectsCombo.addItemListener(new ProjectChangeListener()); projectsComboModel.setSelectedItem(new Project(null, "Select a Java.net project...")); // build a label to display the number of issues in the issue table issueCounter = new IssueCounterLabel(filteredIssues); issueCounter.setHorizontalAlignment(SwingConstants.CENTER); issueCounter.setForeground(Color.WHITE); // throbber throbber = new JLabel(THROBBER_STATIC); throbber.setHorizontalAlignment(SwingConstants.RIGHT); // header bar JPanel iconBar = new GradientPanel(GLAZED_LISTS_MEDIUM_BROWN, GLAZED_LISTS_DARK_BROWN, true); iconBar.setLayout(new GridLayout(1, 3)); iconBar.add(projectsCombo); iconBar.add(issueCounter); iconBar.add(throbber); iconBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // assemble all data components on a common panel JPanel dataPanel = new JPanel(); JComponent issueDetailsComponent = issueDetails; dataPanel.setLayout(new GridLayout(2, 1)); dataPanel.add(issuesTableScrollPane); dataPanel.add(issueDetailsComponent); // draw lines between components JComponent filtersPanel = filterPanel.getComponent(); filtersPanel.setBorder(BorderFactory.createEmptyBorder()); // filtersPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, // IssuesBrowser.GLAZED_LISTS_DARK_BROWN)); issueDetailsComponent.setBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, GLAZED_LISTS_DARK_BROWN)); // the outermost panel to layout the icon bar with the other panels final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.add( iconBar, new GridBagConstraints( 0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( filtersPanel, new GridBagConstraints( 0, 1, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( Box.createHorizontalStrut(240), new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); mainPanel.add( dataPanel, new GridBagConstraints( 1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return mainPanel; }
public Editor(JFrame parent, Evaluator evaluator) { super(parent, "Structure"); setModal(true); this.evaluator = evaluator; getContentPane().setLayout(new BorderLayout()); // name and type JPanel pNameType = new JPanel(new GridLayout(2, 1)); JPanel pName = new JPanel(new BorderLayout()); pName.add(new JLabel("Name: "), BorderLayout.WEST); tfName = new JTextField(evaluator.getName()); pName.add(tfName, BorderLayout.CENTER); pNameType.add(pName); JPanel pType = new JPanel(new BorderLayout()); pType.add(new JLabel("Type: "), BorderLayout.WEST); cbType = new JComboBox(types); cbType.setEditable(false); cbType.setSelectedIndex(evaluator.type); cbType.addItemListener(this); pType.add(cbType, BorderLayout.CENTER); pNameType.add(pType); getContentPane().add(pNameType, BorderLayout.NORTH); // options panel this.clOptions = new CardLayout(); this.pOptions = new JPanel(clOptions); JPanel pConstraintRoot = new JPanel(new BorderLayout()); Box pConstraintOpts = new Box(BoxLayout.Y_AXIS); JPanel pDiagonals = new JPanel(new BorderLayout()); cbDiagonals = new JCheckBox("Ignore Diagonals", evaluator.ignoreDiagonals); pDiagonals.add(cbDiagonals, BorderLayout.CENTER); pConstraintOpts.add(pDiagonals); JPanel pInvestment = new JPanel(new BorderLayout()); pInvestment.add(new Label("Investments "), BorderLayout.WEST); cbInvestment = new JComboBox(investments); cbInvestment.setEditable(false); cbInvestment.setSelectedIndex(evaluator.investments); pInvestment.add(cbInvestment, BorderLayout.CENTER); pConstraintOpts.add(pInvestment); JPanel pOrganization = new JPanel(new GridLayout(2, 1)); lOrgFileName = new JLabel("File: <none selected>"); pOrganization.add(lOrgFileName); JPanel pFileChoose = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton bFileChoose = new JButton("Choose File..."); bFileChoose.addActionListener(this); bFileChoose.setActionCommand(CMD_CHOOSE_FILE); pFileChoose.add(bFileChoose); pOrganization.add(pFileChoose); pConstraintOpts.add(pOrganization); pConstraintRoot.add(pConstraintOpts, BorderLayout.NORTH); pOptions.add(pConstraintRoot, types[CONSTRAINT]); JPanel pSizeRoot = new JPanel(new BorderLayout()); pOptions.add(pSizeRoot, types[EFFECTIVE_SIZE]); clOptions.first(pOptions); getContentPane().add(BorderLayout.CENTER, pOptions); // ok/cancel panel JOkCancelPanel okCancelPanel = new JOkCancelPanel(); okCancelPanel.addActionListener(this); getContentPane().add(BorderLayout.SOUTH, okCancelPanel); pack(); }
/** * Create a choicebox for link line style options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the link style options. */ private JPanel createLinkDashedChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLinkDashed = new JComboBox(); cbLinkDashed.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$ cbLinkDashed.setOpaque(true); cbLinkDashed.setEditable(false); cbLinkDashed.setEnabled(false); cbLinkDashed.setMaximumRowCount(10); cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$ cbLinkDashed.validate(); cbLinkDashed.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLinkDashed.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateLinkDashed(cbLinkDashed.getSelectedIndex()); } }; cbLinkDashed.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLinkDashed, BorderLayout.CENTER); return drawPanel; }
/** Create the arrow head choicebox. */ private JPanel createArrowChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbArrows = new JComboBox(); cbArrows.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$ cbArrows.setOpaque(true); cbArrows.setEditable(false); cbArrows.setEnabled(false); cbArrows.setMaximumRowCount(4); cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ Vector arrows = new Vector(5); arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"), 0); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"), 1); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"), 2); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"), 3); //$NON-NLS-1$ DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows); cbArrows.setModel(comboModel); cbArrows.setSelectedIndex(0); DefaultListCellRenderer comboRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText((String) value); return this; } }; cbArrows.setRenderer(comboRenderer); cbArrows.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateArrowType(cbArrows.getSelectedIndex()); } }); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbArrows, BorderLayout.CENTER); return drawPanel; }
public FrontEnd() { setLocation(0, 0); setSize(1285, 750); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); table = new JTable(dtm) { @Override public boolean isCellEditable(int row, int column) { if (column == 0 || column == 1) return false; else return true; } }; final JComboBox comboBoxRun = new JComboBox(); comboBoxRun.setEditable(true); comboBoxRun.addItem("Run all tests"); comboBoxRun.addItem("Run all tests and then rerun Failed tests"); comboBoxRun.addItem("Only run Failed tests"); table.getColumnModel().getColumn(0).setPreferredWidth(422); table.getColumnModel().getColumn(1).setPreferredWidth(460); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setRowSelectionAllowed(false); table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setPreferredSize(new Dimension(100, HEADER_HEIGHT)); table.getTableHeader().setFont(new Font(null, Font.BOLD, 12)); table.getTableHeader().setBackground(Color.LIGHT_GRAY); table.getTableHeader().setPreferredSize(new Dimension(10000, 32)); JScrollPane sp = new JScrollPane(table); JPanel subPanel = new JPanel(); JPanel subPanel1 = new JPanel(); openF = new JButton("Choose File"); openFo = new JButton("Choose Folder"); selFo = new JButton("Select Single Folder"); canF = new JButton("Cancel"); canF.setEnabled(false); resLab = new JLabel("Results Path"); Launch = new JButton("Launch"); foSel = new JButton("..."); foSel.setPreferredSize(new Dimension(18, 18)); resBox = new JTextField(placeS); resBox.setPreferredSize(new Dimension(500, 24)); resBox.setEditable(false); duplC = new JCheckBox("Remove Duplicates"); duplC.setSelected(true); subPanel.add(openF); subPanel.add(openFo); subPanel.add(selFo); subPanel.add(canF); subPanel.add(Launch); subPanel.add(duplC); subPanel.add(comboBoxRun); subPanel1.add(resLab); subPanel1.add(resBox); subPanel1.add(foSel); initUI(); getContentPane().add(sp, BorderLayout.CENTER); getContentPane().add(subPanel, BorderLayout.SOUTH); getContentPane().add(subPanel1, BorderLayout.NORTH); sValue = (String) comboBoxRun.getSelectedItem(); comboBoxRun.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String sValue = (String) comboBoxRun.getSelectedItem(); if (sValue.equals("Run all Tests")) { flagF = 1; } if (sValue.contains("Run all tests and then rerun Failed tests")) { flagF = 2; } if (sValue.contains("Only run Failed tests")) { flagF = 3; } System.out.println(flagF); } }); openF.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { openFile(); } }); openFo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { openFolder(); } }); selFo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { selFolder(); } }); canF.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { cancelSel(); } }); foSel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { resFol(); resBox.setText(placeS); } }); Launch.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { doLaunch(); } catch (IOException ex) { Logger.getLogger(FrontEnd.class.getName()).log(Level.SEVERE, null, ex); } } }); table.addMouseListener( new java.awt.event.MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { // Bring up pop up on row/col of right click JTable source = (JTable) e.getSource(); int row = source.rowAtPoint(e.getPoint()); int column = source.columnAtPoint(e.getPoint()); if (!source.isRowSelected(row) || !source.isColumnSelected(column)) source.changeSelection(row, column, false, false); doPop(e); } } }); }
public static void enable(JComboBox comboBox) { // has to be editable comboBox.setEditable(true); // change the editor's document new AutoCompletion(comboBox); }
/** * Create an AddeChooser associated with an IdvChooser * * @param mgr The chooser manager * @param root The chooser.xml node */ public AddeChooser(IdvChooserManager mgr, Element root) { super(mgr, root); simpleMode = !getProperty(IdvChooser.ATTR_SHOWDETAILS, true); this.addeServers = getIdv().getIdvChooserManager().getAddeServers(getGroupType()); serverSelector = new JComboBox(new Vector(addeServers)) { public void paint(Graphics g) { if (myServerTimeStamp != serverTimeStamp) { myServerTimeStamp = serverTimeStamp; Misc.runInABit(10, AddeChooser.this, "updateServerList", null); } super.paint(g); } }; serverSelector.setEditable(true); serverSelector.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (!ignoreStateChangedEvents) { setGroups(); } } }); serverSelector .getEditor() .getEditorComponent() .addMouseListener( new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e)) { return; } AddeServer server = getAddeServer(); if (server == null) { return; } List items = new ArrayList(); if (MARK_AS_INACTIVE || server.getIsLocal()) { items.add( GuiUtils.makeMenuItem( "Remove local server: " + server.getName(), AddeChooser.this, "removeServer", server)); } else { items.add(new JMenuItem("Not a local server")); } JPopupMenu popup = GuiUtils.makePopupMenu(items); popup.show(serverSelector, e.getX(), e.getY()); } }); groupSelector = new JComboBox(); groupSelector.setToolTipText("Right click to remove group"); groupSelector.setEditable(true); groupSelector .getEditor() .getEditorComponent() .addMouseListener( new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { Object selected = groupSelector.getSelectedItem(); if ((selected == null) || !(selected instanceof AddeServer.Group)) { return; } AddeServer.Group group = (AddeServer.Group) selected; List items = new ArrayList(); if (MARK_AS_INACTIVE || group.getIsLocal()) { items.add( GuiUtils.makeMenuItem( "Remove local group: " + group.getName(), AddeChooser.this, "removeGroup", group)); } final AddeServer server = getAddeServer(); if (server != null) { List groups = server.getGroupsWithType(getGroupType(), false); for (int i = 0; i < groups.size(); i++) { final AddeServer.Group inactiveGroup = (AddeServer.Group) groups.get(i); if (inactiveGroup.getActive()) { continue; } JMenuItem mi = new JMenuItem("Re-activate group: " + inactiveGroup); items.add(mi); mi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { getIdv() .getIdvChooserManager() .activateAddeServerGroup(server, inactiveGroup); setGroups(); groupSelector.setSelectedItem(inactiveGroup); } }); } } if (items.size() == 0) { items.add(new JMenuItem("Not a local group")); } JPopupMenu popup = GuiUtils.makePopupMenu(items); popup.show(groupSelector, e.getX(), e.getY()); } } }); loadServerState(); setGroups(); }
/** * Create a choicbox for link line thickness options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the line thickness options. */ private JPanel createWeightChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLineWeight = new JComboBox(); cbLineWeight.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$ cbLineWeight.setOpaque(true); cbLineWeight.setEditable(false); cbLineWeight.setEnabled(false); cbLineWeight.setMaximumRowCount(10); cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$ cbLineWeight.validate(); cbLineWeight.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLineWeight.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int ind = cbLineWeight.getSelectedIndex(); if (ind == 0) onUpdateLinkWeight(1); else if (ind == 1) onUpdateLinkWeight(2); else if (ind == 2) onUpdateLinkWeight(3); else if (ind == 3) onUpdateLinkWeight(4); else if (ind == 4) onUpdateLinkWeight(5); else if (ind == 5) onUpdateLinkWeight(6); else if (ind == 6) onUpdateLinkWeight(7); else if (ind == 7) onUpdateLinkWeight(8); else if (ind == 8) onUpdateLinkWeight(9); else if (ind == 9) onUpdateLinkWeight(10); } }; cbLineWeight.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLineWeight, BorderLayout.CENTER); return drawPanel; }
/** * Конструктор * * @param mediator Посредник родитьельского окна */ public ButtonToolBar(final IGuiMediator mediator) { this.mediator = mediator; try { locale = ((WBDrawing) mediator).getLocalizer(); } catch (Exception e) { logger.debug(e.getMessage(), e); } mouseMenu = new JPopupMenu(); imagePanel = new JPanel(); imagePanel.setLayout(new GridLayout(4, 2)); mouseMenu.add(imagePanel); imagePanel.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { System.out.println("Focus Gained"); } public void focusLost(FocusEvent e) { mouseMenu.setVisible(false); System.out.println("Focus Lost"); } }); URL url = ClassLoader.getSystemResource("img/open.gif"); Icon iconOpen = new ImageIcon(url); JButton btnOpen = new JButton(iconOpen); btnOpen.setToolTipText(locale.getString("btntoolbar.open")); url = ClassLoader.getSystemResource("img/save.gif"); Icon iconSave = new ImageIcon(url); JButton btnSave = new JButton(iconSave); btnSave.setToolTipText(locale.getString("btntoolbar.save")); url = ClassLoader.getSystemResource("img/undo.gif"); Icon iconUndo = new ImageIcon(url); btnUndo = new JButton(iconUndo); btnUndo.setToolTipText(locale.getString("btntoolbar.undo")); url = ClassLoader.getSystemResource("img/redo.gif"); Icon iconRedo = new ImageIcon(url); btnRedo = new JButton(iconRedo); btnRedo.setToolTipText(locale.getString("btntoolbar.redo")); url = ClassLoader.getSystemResource("img/draw.gif"); Icon iconDraw = new ImageIcon(url); btnDraw = new JToggleButton(iconDraw, true); btnDraw.setToolTipText(locale.getString("btntoolbar.draw")); url = ClassLoader.getSystemResource("img/pen.gif"); Icon iconPen = new ImageIcon(url); btnPen = new JToggleButton(iconPen); btnPen.setToolTipText(locale.getString("btntoolbar.pen")); url = ClassLoader.getSystemResource("img/calibrate.gif"); Icon iconCalibrate = new ImageIcon(url); btnCalibrate = new JToggleButton(iconCalibrate); btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration")); url = ClassLoader.getSystemResource("img/gridMove.gif"); Icon iconGridMove = new ImageIcon(url); JToggleButton btnGrigMove = new JToggleButton(iconGridMove); url = ClassLoader.getSystemResource("img/hand.gif"); Icon iconHand = new ImageIcon(url); JToggleButton btnHand = new JToggleButton(iconHand); btnHand.setToolTipText(locale.getString("btntoolbar.hand")); url = ClassLoader.getSystemResource("img/selTool.gif"); Icon iconSelTool = new ImageIcon(url); JToggleButton btnSelTool = new JToggleButton(iconSelTool); url = ClassLoader.getSystemResource("img/spline.gif"); Icon iconQuadTool = new ImageIcon(url); btnSpline = new JToggleButton(iconQuadTool); btnSpline.setToolTipText(locale.getString("btntoolbar.spline")); btnTools = new JToggleButton("T"); btnTextTool = new JToggleButton("A"); url = ClassLoader.getSystemResource("img/ruler.gif"); Icon iconRulerTool = new ImageIcon(url); btnRulerTool = new JToggleButton(iconRulerTool); url = ClassLoader.getSystemResource("img/sendFile.gif"); Icon iconSendFile = new ImageIcon(url); JToggleButton btnFileTransmit = new JToggleButton(iconSendFile); btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit")); url = ClassLoader.getSystemResource("img/nodesEdit.gif"); Icon iconNodesEdit = new ImageIcon(url); JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit); btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit")); JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test")); btnTest.setEnabled(false); url = ClassLoader.getSystemResource("img/send.gif"); Icon iconSend = new ImageIcon(url); JButton btnSendArq = new JButton(iconSend); btnSendArq.setToolTipText(locale.getString("btntoolbar.send")); url = ClassLoader.getSystemResource("img/clear.gif"); Icon iconClear = new ImageIcon(url); JButton btnClearTab = new JButton(iconClear); btnClearTab.setToolTipText(locale.getString("btntoolbar.clear")); JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel")); btnRequestModel.setEnabled(false); JComboBox cmbTools = new JComboBox(); cmbTools.addItem("Thick Line"); cmbTools.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = btnTools.getModel().isSelected(); if (selected) { mode = getToolsMode(); guiChanged(); } } }); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(btnDraw); buttonGroup.add(btnPen); buttonGroup.add(btnCalibrate); buttonGroup.add(btnGrigMove); buttonGroup.add(btnHand); buttonGroup.add(btnSelTool); buttonGroup.add(btnSpline); buttonGroup.add(btnTextTool); buttonGroup.add(btnRulerTool); buttonGroup.add(btnNodesEdit); // buttonGroup.add( btnTools ); btnDraw.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_DRAWING; } guiChanged(); } }); btnPen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_PEN; } guiChanged(); } }); btnCalibrate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_CALIBRATING; } guiChanged(); } }); btnGrigMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_GRID_MOVING; } guiChanged(); } }); btnHand.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_HAND_MAP; } guiChanged(); } }); btnSelTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_SELECT_TOOL; } guiChanged(); } }); btnSpline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_QUAD_TOOL; } guiChanged(); } }); btnTextTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_TEXT_TOOL; } guiChanged(); } }); btnRulerTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_RULER_TOOL; } guiChanged(); } }); btnNodesEdit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_NODES_EDIT; } guiChanged(); } }); btnTools.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mode = getToolsMode(); guiChanged(); } }); btnOpen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnOpenPressed(); } }); btnSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSavePressed(); } }); btnUndo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnUndoPressed(); } }); btnRedo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnRedoPressed(); } }); btnTest.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnTestPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendModelPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendArqModelPressed(); } }); btnClearTab.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnClearTabPressed(); } }); btnRequestModel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); btnFileTransmit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); add(btnOpen); add(btnSave); // add( btnUndo ); // add( btnRedo ); addSeparator(); // add(lblMode); actionButton = new JToggleButton(btnDraw.getIcon()); actionButton.setToolTipText(btnDraw.getToolTipText()); actionButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseMenu.show(e.getComponent(), e.getX(), e.getY()); } }); addButton(btnDraw); addButton(btnPen); addButton(btnCalibrate); // add( btnGrigMove ); addButton(btnHand); // add(btnSelTool); addButton(btnSpline); addButton(btnNodesEdit); // add( btnTextTool ); addButton(btnRulerTool); // addSeparator(); // add(cmbTools); add(actionButton); cmbScale = new JComboBox(); cmbScale.setEditable(true); cmbScale.addItem("1:1000"); cmbScale.addItem("1:2000"); cmbScale.addItem("1:5000"); cmbScale.addItem("1:10000"); cmbScale.addItem("1:25000"); cmbScale.addItem("1:50000"); cmbScale.addItem("1:100000"); cmbScale.setSelectedIndex(3); cmbScale.setToolTipText(locale.getString("btntoolbar.scale")); cmbScale.setPreferredSize(cmbScale.getMinimumSize()); cmbScale.setMaximumSize(cmbScale.getMinimumSize()); cmbScale.addItemListener(new ZoomListener()); addSeparator(); chbVisibleGrid = new JCheckBox(); chbVisibleGrid.setSelected(true); chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid")); // addSeparator(); chbVisibleGrid.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { guiChanged(); } }); add(btnFileTransmit); add(btnSendArq); add(btnClearTab); add(chbVisibleGrid); add(cmbScale); // addSeparator(); // add( lblControl ); // add( btnSend ); // add( btnRequestModel ); // add( btnTest ); }
public SelectStudentWindow() { setContentPane(contentPane); setModal(true); getRootPane().setDefaultButton(buttonOK); studentList = ReportGenerator.staticList; buttonOK.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onOK(); } }); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }); editButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onEditButtonClick(); } }); deleteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onDeleteButtonClick(); } }); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onAddButtonClick(); } }); studentsComboBox.setEditable(false); setStudentsComboBox(); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); contentPane.registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { onCancel(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); }
protected void dolayout(String strDir, String strFreq, String strTraynum) { // TopBar String strTitle = gettitle(strFreq); Color color = DisplayOptions.getColor("Heading3"); // Center Panel JPanel panelCenter = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); ImageIcon icon = getImageIcon(); // panelCenter.add(new JLabel(icon)); addComp(panelCenter, new JLabel(icon), gbc, 0, 0); strTitle = getSampleName(strDir, strTraynum); m_lblSampleName = new JLabel(strTitle); if (strTitle == null || !strTitle.trim().equals("")) strTitle = "3"; Font font = m_lblSampleName.getFont(); font = DisplayOptions.getFont(font.getName(), Font.BOLD, 300); m_lblSampleName.setFont(font); m_lblSampleName.setForeground(color); // panelCenter.add(m_lblSampleName); m_pnlSampleName = new JPanel(new CardLayout()); m_pnlSampleName.add(m_lblSampleName, OTHER); addComp(panelCenter, m_pnlSampleName, gbc, 1, 0); m_pnlSampleName.setVisible(false); m_pnlTrays = new JPanel(new GridLayout(1, 0)); // Vast panels VBox pnlVast1 = new VBox(m_pnlTrays, "1"); m_pnlTrays.add(pnlVast1); m_pnlVast[0] = pnlVast1; VBox pnlVast2 = new VBox(m_pnlTrays, "2"); m_pnlTrays.add(pnlVast2); m_pnlVast[1] = pnlVast2; VBox pnlVast3 = new VBox(m_pnlTrays, "3"); m_pnlTrays.add(pnlVast3); m_pnlVast[2] = pnlVast3; VBox pnlVast4 = new VBox(m_pnlTrays, "4"); m_pnlTrays.add(pnlVast4); m_pnlVast[3] = pnlVast4; VBox pnlVast5 = new VBox(m_pnlTrays, "5"); m_pnlTrays.add(pnlVast5); m_pnlVast[4] = pnlVast5; m_pnlSampleName.add(m_pnlTrays, VAST); // Login Panel JPanel panelThird = new JPanel(new BorderLayout()); JPanel panelLogin = new JPanel(new GridBagLayout()); gbc = new GridBagConstraints(); panelThird.add(panelLogin); Object[] aStrUser = getOperators(); m_cmbUser = new JComboBox(aStrUser); BasicComboBoxRenderer renderer = new BasicComboBoxRenderer(); m_cmbUser.setRenderer(renderer); m_cmbUser.setEditable(true); m_passwordField = new JPasswordField(); // *Warning, working around a Java problem* // When we went to the T3500 running Redhat 5.3, the JPasswordField // fields sometimes does not allow ANY entry of characters. Setting // the enableInputMethods() to true fixed this problem. There are // comments that indicate that this could cause the typed characters // to be visible. I have not found that to be a problem. // This may not be required in the future, or could cause characters // to become visible in the future if Java changes it's code. // GRS 8/20/09 m_passwordField.enableInputMethods(true); m_lblLogin = new VLoginLabel(null, "Incorrect username/password \n Please try again ", 0, 0); m_lblLogin.setVisible(false); okButton.setActionCommand("enter"); okButton.addActionListener(this); cancelButton.setActionCommand("cancel"); cancelButton.addActionListener(this); helpButton.setActionCommand("help"); helpButton.addActionListener(this); m_passwordField.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) enterLogin(); } }); // These is some wierd problem such that sometimes, the vnmrj command // area gets the focus and these items in the login box do not get // the focus. Even clicking in these items does not bring focus to // them. Issuing requestFocus() does not bring focus to them. // I can however, determing if either the operator entry box or // the password box has focus and if neither does, I can unshow and // reshow the panel and that fixes the focus. So, I have added this // to the mouseClicked action. If neither has focus, it will // take focus with setVisible false then true. comboTextField = m_cmbUser.getEditor().getEditorComponent(); m_passwordField.addMouseListener(this); comboTextField.addMouseListener(this); m_lblUsername = new JLabel(Util.getLabel("_Operator")); addComp(panelLogin, m_lblUsername, gbc, 0, 0); addComp(panelLogin, m_cmbUser, gbc, 1, 0); m_lblPassword = new JLabel(Util.getLabel("_Password")); addComp(panelLogin, m_lblPassword, gbc, 0, 1); addComp(panelLogin, m_passwordField, gbc, 1, 1); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; addComp(panelLogin, m_lblLogin, gbc, 2, 0); setPref(); Container container = getContentPane(); JPanel panelLoginBox = new JPanel(new BorderLayout()); panelLoginBox.add(panelCenter, BorderLayout.CENTER); panelLoginBox.add(panelThird, BorderLayout.SOUTH); container.add(panelLoginBox, BorderLayout.CENTER); }