List of usage examples for java.awt GridBagConstraints REMAINDER
int REMAINDER
To view the source code for java.awt GridBagConstraints REMAINDER.
Click Source Link
From source file:org.rdv.ui.ExportVideoDialog.java
private void initComponents() { JPanel container = new JPanel(); setContentPane(container);/*w w w .j a v a 2 s . co m*/ InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and video channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = rbnb.getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Video Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); videoChannelList = new JList(videoChannelModel); videoChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); videoChannelList.setCellRenderer(new CheckListRenderer()); videoChannelList.setVisibleRowCount(10); videoChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = videoChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) videoChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = videoChannelList.getCellBounds(index, index); videoChannelList.repaint(rect); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(videoChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Choose Directory: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; directoryTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(directoryTextField, c); directoryTextField.setText(UIUtilities.getCurrentDirectory().getAbsolutePath()); directoryButton = new JButton("Browse"); directoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedDirectory = UIUtilities.getDirectory("Select export directory"); if (selectedDirectory != null) { directoryTextField.setText(selectedDirectory.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(directoryButton, c); exportProgressBar = new JProgressBar(0, 100000); exportProgressBar.setStringPainted(true); exportProgressBar.setValue(0); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.CENTER; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(exportProgressBar, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = 1547500154252213911L; public void actionPerformed(ActionEvent e) { exportVideo(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -7440298547807878651L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } directoryTextField.requestFocusInWindow(); setLocationByPlatform(true); setVisible(true); }
From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java
/** * Description://from ww w .ja va2 s. c om * * @param name */ protected void initComponent() { setLayout(new GridBagLayout()); setOpaque(false); setBorder(BorderFactory.createTitledBorder((Border) null)); GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.BOTH; gc.weightx = 1; gc.gridwidth = GridBagConstraints.REMAINDER; JPanel titlePanel = createTitlePanel(); add(titlePanel, gc); gc.gridwidth = 1; JPanel deviceTypePanel = createDeviceTypePanel(); add(deviceTypePanel, gc); gc.gridwidth = GridBagConstraints.REMAINDER; JPanel flowTypePanel = createFlowTypePanel(); add(flowTypePanel, gc); gc.weighty = 1; gc.fill = GridBagConstraints.BOTH; add(Box.createGlue(), gc); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java
ConfigurationDialog(final Component owner, final UploaderGuiController controller, final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel, final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs, final GiftCloudReporter reporter) { this.controller = controller; this.giftCloudProperties = giftCloudProperties; this.projectListModel = projectListModel; this.resourceBundle = resourceBundle; this.giftCloudDialogs = giftCloudDialogs; this.reporter = reporter; temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel, giftCloudProperties.getLastProject()); componentToCenterDialogOver = owner; dialog = new JDialog(); dialog.setModal(true);//from w w w. j a v a2 s.c o m dialog.setResizable(false); // Call custom dialog close code when the close button is clicked dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { closeDialog(); } }); dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen dialog.setTitle(resourceBundle.getString("configurationDialogTitle")); final GridBagConstraints sectionTitleConstraints = new GridBagConstraints(); sectionTitleConstraints.gridx = 0; sectionTitleConstraints.gridy = 1; sectionTitleConstraints.gridwidth = 2; sectionTitleConstraints.weightx = 1; sectionTitleConstraints.weighty = 1; sectionTitleConstraints.anchor = GridBagConstraints.CENTER; sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.gridwidth = 1; labelConstraints.weightx = 1; labelConstraints.weighty = 1; labelConstraints.anchor = GridBagConstraints.LINE_START; labelConstraints.fill = GridBagConstraints.NONE; final GridBagConstraints inputConstraints = new GridBagConstraints(); inputConstraints.gridx = 1; inputConstraints.gridy = 0; inputConstraints.gridwidth = 1; inputConstraints.weightx = 1; inputConstraints.weighty = 1; inputConstraints.anchor = GridBagConstraints.LINE_END; inputConstraints.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints separatorConstraint = new GridBagConstraints(); separatorConstraint.weightx = 1.0; separatorConstraint.fill = GridBagConstraints.HORIZONTAL; separatorConstraint.gridwidth = GridBagConstraints.REMAINDER; // The panel containing the GIFT-Cloud server configuration final JPanel giftCloudServerPanel = new JPanel(); { GridBagLayout projectUploadlayout = new GridBagLayout(); giftCloudServerPanel.setLayout(projectUploadlayout); JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"), SwingConstants.CENTER); giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints); // GIFT-Cloud server URL { labelConstraints.gridwidth = 1; labelConstraints.gridy = 2; final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"), SwingConstants.RIGHT); giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText")); giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints); giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""), textFieldLengthForGiftCloudServerUrl); inputConstraints.gridy = 2; giftCloudServerPanel.add(giftCloudServerText, inputConstraints); } // GIFT-Cloud username { labelConstraints.gridy = 3; final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"), SwingConstants.RIGHT); giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText")); giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints); final Optional<String> serverUrl = giftCloudProperties.getLastUserName(); final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : ""; giftCloudUsernameText = new AutoFocusTextField(initialServerText); inputConstraints.gridy = 3; giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints); } // GIFT-Cloud password { labelConstraints.gridy = 4; final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"), SwingConstants.RIGHT); giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText")); giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getLastPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 4; giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints); } // Project list { labelConstraints.gridy = 5; JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListLabel, labelConstraints); inputConstraints.gridy = 5; projectList = new BackwardsCompatibleComboBox(); projectList.setEditable(false); projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip")); giftCloudServerPanel.add(projectList, inputConstraints); labelConstraints.gridx = 1; projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints); labelConstraints.gridx = 0; } // Subject prefix { labelConstraints.gridy = 6; JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"), SwingConstants.RIGHT); subjectPrefixLabel .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip")); giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints); inputConstraints.gridy = 6; final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix(); subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse("")); giftCloudServerPanel.add(subjectPrefixField, inputConstraints); } } // Local Dicom node configuration final JPanel listenerPanel = new JPanel(); { GridBagLayout listenerPanellayout = new GridBagLayout(); listenerPanel.setLayout(listenerPanellayout); JSeparator separator = new JSeparator(); listenerPanel.add(separator, separatorConstraint); JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"), SwingConstants.CENTER); listenerPanel.add(listenerPanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"), SwingConstants.RIGHT); listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip")); listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints); listenerPanel.add(listeningAETitleJLabel); inputConstraints.gridy = 2; final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle(); listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText); listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints); listenerPanel.add(listeningAETitleField); } { labelConstraints.gridy = 3; JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"), SwingConstants.RIGHT); listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip")); listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints); listenerPanel.add(listeningPortJLabel); inputConstraints.gridy = 3; final int port = giftCloudProperties.getListeningPort(); final String portValue = Integer.toString(port); listeningPortField = new AutoFocusTextField(portValue); listenerPanellayout.setConstraints(listeningPortField, inputConstraints); listenerPanel.add(listeningPortField); } { labelConstraints.gridy = 4; JLabel patientListExportFolderLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListExportFolder"), SwingConstants.RIGHT); patientListExportFolderLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip")); listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints); listenerPanel.add(patientListExportFolderLabel); inputConstraints.gridy = 4; final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder(); patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse("")); listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints); listenerPanel.add(patientListExportFolderField); } // Patient list spreadsheet password { labelConstraints.gridy = 5; final JLabel patientListSpreadsheetPasswordLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"), SwingConstants.RIGHT); patientListSpreadsheetPasswordLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip")); listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getPatientListPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 5; listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints); } } // Remote PACS configuration final JPanel remoteAEPanel = new JPanel(); { GridBagLayout pacsPanellayout = new GridBagLayout(); remoteAEPanel.setLayout(pacsPanellayout); JSeparator separator = new JSeparator(); remoteAEPanel.add(separator, separatorConstraint); JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"), SwingConstants.CENTER); remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle(); remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : ""); inputConstraints.gridy = 2; remoteAEPanel.add(remoteAETitleField, inputConstraints); } { labelConstraints.gridy = 3; JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"), SwingConstants.RIGHT); remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip")); remoteAEPanel.add(remoteAeHostLabel, labelConstraints); remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse("")); inputConstraints.gridy = 3; remoteAEPanel.add(remoteAEHostName, inputConstraints); } { labelConstraints.gridy = 4; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort())); inputConstraints.gridy = 4; remoteAEPanel.add(remoteAEPortField, inputConstraints); } } // The panel containing the cancel and apply buttons JPanel buttonPanel = new JPanel(); JPanel closeButtonPanel = new JPanel(); { final GridBagLayout buttonPanellayout = new GridBagLayout(); buttonPanel.setLayout(buttonPanellayout); JSeparator separator = new JSeparator(); buttonPanel.add(separator, separatorConstraint); closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText")); cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText")); closeButtonPanel.add(cancelButton); cancelButton.addActionListener(new CancelActionListener()); JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText")); applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText")); closeButtonPanel.add(applyButton); applyButton.addActionListener(new ApplyActionListener()); JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText")); closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText")); closeButtonPanel.add(closeButton); closeButton.addActionListener(new CloseActionListener()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; buttonPanellayout.setConstraints(closeButtonPanel, constraints); buttonPanel.add(closeButtonPanel); } // The main panel of the configuration dialog JPanel configPanel = new JPanel(); { final GridBagLayout configPanelLayout = new GridBagLayout(); configPanel.setLayout(configPanelLayout); { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(giftCloudServerPanel, constraints); configPanel.add(giftCloudServerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(listenerPanel, constraints); configPanel.add(listenerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 2; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(remoteAEPanel, constraints); configPanel.add(remoteAEPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 3; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(buttonPanel, constraints); configPanel.add(buttonPanel); } } projectList.setModel(temporaryDropDownListModel); showProjectList(projectListModel.isEnabled()); // Create a listener to enable/disable the project list when it is set from the server. // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied. // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() { @Override public void statusChanged(final Boolean visibility) { showProjectList(projectListModel.isEnabled()); } }; projectListModel.addListener(projectListEnabledListener); GridBagLayout layout = new GridBagLayout(); dialog.setLayout(layout); Container content = dialog.getContentPane(); content.add(configPanel); dialog.pack(); dialog.setVisible(true); dialog.pack(); }
From source file:IconDemoApplet.java
public void init() { //Parse the applet parameters pictures = parseParameters();/*from www. j a va 2s .co m*/ //If the applet tag doesn't provide an "IMAGE0" parameter, //display an error message. if (pictures.size() == 0) { captionLabel = new JLabel("No images listed in applet tag."); captionLabel.setHorizontalAlignment(JLabel.CENTER); getContentPane().add(captionLabel); return; } //NOW CREATE THE GUI COMPONENTS //A label to identify XX of XX. numberLabel = new JLabel("Picture " + (current + 1) + " of " + pictures.size()); numberLabel.setHorizontalAlignment(JLabel.LEFT); numberLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 5)); //A label for the caption. final Photo first = (Photo) pictures.firstElement(); captionLabel = new JLabel(first.caption); captionLabel.setHorizontalAlignment(JLabel.CENTER); captionLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); //A label for displaying the photographs. photographLabel = new JLabel("Loading first image..."); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setVerticalAlignment(JLabel.CENTER); photographLabel.setVerticalTextPosition(JLabel.CENTER); photographLabel.setHorizontalTextPosition(JLabel.CENTER); photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); photographLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), photographLabel.getBorder())); //Set the preferred size for the picture, //with room for the borders. Insets i = photographLabel.getInsets(); photographLabel.setPreferredSize( new Dimension(widthOfWidest + i.left + i.right, heightOfTallest + i.bottom + i.top)); //Create the next and previous buttons. ImageIcon nextIcon = new ImageIcon(getURL(imagedir + "right.gif")); ImageIcon dimmedNextIcon = new ImageIcon(getURL(imagedir + "dimmedRight.gif")); ImageIcon previousIcon = new ImageIcon(getURL(imagedir + "left.gif")); ImageIcon dimmedPreviousIcon = new ImageIcon(getURL(imagedir + "dimmedLeft.gif")); previousButton = new JButton("Previous Picture", previousIcon); previousButton.setDisabledIcon(dimmedPreviousIcon); previousButton.setVerticalTextPosition(AbstractButton.CENTER); previousButton.setHorizontalTextPosition(AbstractButton.RIGHT); previousButton.setMnemonic(KeyEvent.VK_P); previousButton.setActionCommand("previous"); previousButton.addActionListener(this); previousButton.setEnabled(false); nextButton = new JButton("Next Picture", nextIcon); nextButton.setDisabledIcon(dimmedNextIcon); nextButton.setVerticalTextPosition(AbstractButton.CENTER); nextButton.setHorizontalTextPosition(AbstractButton.LEFT); nextButton.setMnemonic(KeyEvent.VK_N); nextButton.setActionCommand("next"); nextButton.addActionListener(this); //Lay out the GUI. GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(layout); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(numberLabel, c); contentPane.add(numberLabel); layout.setConstraints(captionLabel, c); contentPane.add(captionLabel); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; layout.setConstraints(photographLabel, c); contentPane.add(photographLabel); c.gridwidth = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(previousButton, c); contentPane.add(previousButton); c.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(nextButton, c); contentPane.add(nextButton); //Start loading the image for the first photograph now. //The loadImage method uses a SwingWorker //to load the image in a separate thread. loadImage(imagedir + first.filename, current); }
From source file:org.intermine.install.swing.source.SourcePropertiesPanel.java
/** * Set the source to edit. Replaces the components displayed in the panel with new * ones for the properties of the given source. * // w ww .j ava 2 s.c o m * @param projectHome The project home directory. * @param project The Project. * @param s The Source. */ public void setSource(File projectHome, Project project, Source s) { source = s; SourceInfo sourceInfo = null; if (source != null) { String sourceType = source.getType(); sourceInfo = SourceInfoLoader.getInstance().getSourceInfo(sourceType); if (sourceInfo == null) { try { sourceInfo = SourceInfoLoader.getInstance().findDerivedSourceInfo(sourceType, project, projectHome); if (sourceInfo == null) { logger.warn("There is no source type information for the type " + sourceType); } } catch (IOException e) { logger.warn("IOException while searching for derived type information for " + sourceType, e); /* String message = Messages.getMessage("sourcetype.loadfail.title", sourceType); logger.error(message, e); JOptionPane.showMessageDialog(this, message, Messages.getMessage("sourcetype.loadfail.title"), JOptionPane.ERROR_MESSAGE); return; */ } } } propertyNames.clear(); propertyInfo.clear(); sourceProperties.clear(); if (sourceInfo != null) { for (PropertyDescriptor p : sourceInfo.getSource().getProperty()) { propertyNames.add(p.getName()); propertyInfo.put(p.getName(), p); } } if (source != null) { for (Property p : source.getProperty()) { propertyNames.add(p.getName()); sourceProperties.put(p.getName(), p); } } int numProperties = propertyNames.size(); removeAll(); setPreferredSize(null); GridBagConstraints cons = GridBagHelper.defaultConstraints(); propertyWrappers = new PropertyComponentWrapper[numProperties]; Iterator<String> propIter = propertyNames.iterator(); for (int index = 0; propIter.hasNext(); index++) { String propertyName = propIter.next(); PropertyDescriptor descriptor = propertyInfo.get(propertyName); Property property = sourceProperties.get(propertyName); cons.gridx = 0; cons.gridy = index; cons.gridwidth = 1; cons.weightx = 0; add(new JLabel(propertyName), cons); boolean locationProperty = isLocation(descriptor, property); String value = null; if (property != null) { if (locationProperty) { value = property.getLocation(); } else { value = property.getValue(); } } PropertyComponentWrapper wrapper = PropertyComponentCreator.createComponentFor(propertyName, descriptor, value); propertyWrappers[index] = wrapper; cons.gridx = 1; cons.gridwidth = GridBagConstraints.REMAINDER; cons.weightx = 1; add(wrapper.getDisplayComponent(), cons); } // To provide flexible space. cons.gridx = 0; cons.gridy = numProperties; cons.weightx = 1; cons.weighty = 1; cons.gridwidth = GridBagConstraints.REMAINDER; cons.fill = GridBagConstraints.BOTH; add(spacerPanel, cons); revalidate(); Dimension min = getMinimumSize(); Dimension pref = getPreferredSize(); setPreferredSize(new Dimension(min.width + MIN_SIZE_MARGIN, pref.height)); }
From source file:org.ut.biolab.medsavant.client.filter.TabularFilterView.java
protected final void initContentPanel() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); if (availableValues == null) { JTextArea label = new JTextArea( "There are too many unique values to generate this list. You will not be able to filter on this column. "); label.setOpaque(false);// www. jav a 2s. c o m label.setLineWrap(true); label.setWrapStyleWord(true); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(label, gbc); this.showViewCard(); return; } applyButton = new JButton("Apply"); applyButton.setEnabled(false); AbstractListModel model = new SimpleListModel(); field = new QuickListFilterField(model); field.setHintText("Type here to filter options"); // the width of the field has to be less than the width // provided to the filter, otherwise, it will push the grid wider // and components will be inaccessible field.setPreferredSize(new Dimension(FIELD_WIDTH, 22)); filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) { @Override public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { return -1; } @Override public boolean isCheckBoxEnabled(int index) { return true; } }; filterableList.getCheckBoxListSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); if (model.getSize() > 0) { filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size. } SearchableUtils.installSearchable(filterableList); filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { applyButton.setEnabled(true); } } }); setAllSelected(true); applyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyFilter(); } }); JScrollPane jsp = new JScrollPane(filterableList) { @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize(); result = new Dimension(Math.min(result.width, TabularFilterView.this.getWidth() - 20), result.height); return result; } }; selectAll = ViewUtil.createHyperLinkButton("Select All"); selectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(true); applyButton.setEnabled(true); } }); JButton selectNone = ViewUtil.createHyperLinkButton("Select None"); selectNone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(false); applyButton.setEnabled(true); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 15, 3, 15); add(field, gbc); gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(jsp, gbc); gbc.gridwidth = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.NONE; add(selectAll, gbc); add(selectNone, gbc); gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.EAST; add(applyButton, gbc); this.showViewCard(); }
From source file:com.xmage.launcher.XMageLauncher.java
private XMageLauncher() { locale = Locale.getDefault(); //locale = new Locale("it", "IT"); messages = ResourceBundle.getBundle("MessagesBundle", locale); localize();/* w w w . j a va 2s . c om*/ serverConsole = new XMageConsole("XMage Server console"); clientConsole = new XMageConsole("XMage Client console"); frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(800, 500)); frame.setResizable(false); createToolbar(); ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png")); frame.setIconImage(icon.getImage()); Random r = new Random(); int imageNum = 1 + r.nextInt(17); ImageIcon background = new ImageIcon(new ImageIcon( XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage() .getScaledInstance(800, 480, Image.SCALE_SMOOTH)); mainPanel = new JLabel(background) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); Dimension lmPrefSize = getLayout().preferredLayoutSize(this); size.width = Math.max(size.width, lmPrefSize.width); size.height = Math.max(size.height, lmPrefSize.height); return size; } }; mainPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabPoint = e.getPoint(); mainPanel.getComponentAt(grabPoint); } }); mainPanel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { // get location of Window int thisX = frame.getLocation().x; int thisY = frame.getLocation().y; // Determine how much the mouse moved since the initial click int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x); int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y); // Move window to this position int X = thisX + xMoved; int Y = thisY + yMoved; frame.setLocation(X, Y); } }); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(10, 10, 10, 10); Font font16 = new Font("Arial", Font.BOLD, 16); Font font12 = new Font("Arial", Font.PLAIN, 12); Font font12b = new Font("Arial", Font.BOLD, 12); mainPanel.add(Box.createRigidArea(new Dimension(250, 50))); ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage() .getScaledInstance(150, 75, Image.SCALE_SMOOTH)); xmageLogo = new JLabel(logo); constraints.gridx = 3; constraints.gridy = 0; constraints.gridheight = 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; mainPanel.add(xmageLogo, constraints); textArea = new JTextArea(5, 40); textArea.setEditable(false); textArea.setForeground(Color.WHITE); textArea.setBackground(Color.BLACK); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); constraints.gridx = 2; constraints.gridy = 1; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(scrollPane, constraints); labelProgress = new JLabel(messages.getString("progress")); labelProgress.setFont(font12); labelProgress.setForeground(Color.WHITE); constraints.gridy = 2; constraints.weightx = 0.0; constraints.weighty = 0.0; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.WEST; mainPanel.add(labelProgress, constraints); progressBar = new JProgressBar(0, 100); constraints.gridx = 3; constraints.weightx = 1.0; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(progressBar, constraints); JPanel pnlButtons = new JPanel(); pnlButtons.setLayout(new GridBagLayout()); pnlButtons.setOpaque(false); constraints.gridx = 0; constraints.gridy = 3; constraints.gridheight = GridBagConstraints.REMAINDER; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(pnlButtons, constraints); btnLaunchClient = new JButton(messages.getString("launchClient")); btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip")); btnLaunchClient.setFont(font16); btnLaunchClient.setForeground(Color.GRAY); btnLaunchClient.setEnabled(false); btnLaunchClient.setPreferredSize(new Dimension(180, 60)); btnLaunchClient.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleClient(); } }); constraints.gridx = GridBagConstraints.RELATIVE; constraints.gridy = 0; constraints.gridwidth = 1; constraints.fill = GridBagConstraints.BOTH; pnlButtons.add(btnLaunchClient, constraints); btnLaunchClientServer = new JButton(messages.getString("launchClientServer")); btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip")); btnLaunchClientServer.setFont(font12b); btnLaunchClientServer.setEnabled(false); btnLaunchClientServer.setForeground(Color.GRAY); btnLaunchClientServer.setPreferredSize(new Dimension(80, 40)); btnLaunchClientServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); handleClient(); } }); constraints.fill = GridBagConstraints.HORIZONTAL; pnlButtons.add(btnLaunchClientServer, constraints); btnLaunchServer = new JButton(messages.getString("launchServer")); btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip")); btnLaunchServer.setFont(font12b); btnLaunchServer.setEnabled(false); btnLaunchServer.setForeground(Color.GRAY); btnLaunchServer.setPreferredSize(new Dimension(80, 40)); btnLaunchServer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleServer(); } }); pnlButtons.add(btnLaunchServer, constraints); btnUpdate = new JButton(messages.getString("update.xmage")); btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip")); btnUpdate.setFont(font12b); btnUpdate.setForeground(Color.BLACK); btnUpdate.setPreferredSize(new Dimension(80, 40)); btnUpdate.setEnabled(true); btnUpdate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleUpdate(); } }); pnlButtons.add(btnUpdate, constraints); btnCheck = new JButton(messages.getString("check.xmage")); btnCheck.setToolTipText(messages.getString("check.xmage.tooltip")); btnCheck.setFont(font12b); btnCheck.setForeground(Color.BLACK); btnCheck.setPreferredSize(new Dimension(80, 40)); btnCheck.setEnabled(true); btnCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleCheckUpdates(); } }); pnlButtons.add(btnCheck, constraints); frame.add(mainPanel); frame.pack(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); }
From source file:com.sshtools.common.ui.SshToolsConnectionPanel.java
/** * * * @param parent/*from w w w .jav a 2 s . co m*/ * @param profile * @param optionalTabs * * @return */ public static SshToolsConnectionProfile showConnectionDialog(Component parent, SshToolsConnectionProfile profile, SshToolsConnectionTab[] optionalTabs) { // If no properties are provided, then use the default if (profile == null) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile = new SshToolsConnectionProfile(); profile.setHost(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_HOST, "")); profile.setPort(PreferencesStore.getInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, port)); profile.setUsername(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_USER, "")); } final SshToolsConnectionPanel conx = new SshToolsConnectionPanel(true); if (optionalTabs != null) { for (int i = 0; i < optionalTabs.length; i++) { conx.addTab(optionalTabs[i]); } } conx.setConnectionProfile(profile); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Connection Profile", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Connection Profile", true); } else { d = new JDialog((JFrame) null, "Connection Profile", true); } final JDialog dialog = d; class UserAction { boolean connect; } final UserAction userAction = new UserAction(); // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { userAction.connect = false; dialog.setVisible(false); } }); final JButton connect = new JButton("Connect"); connect.setMnemonic('t'); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (conx.validateTabs()) { userAction.connect = true; dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(connect); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, connect, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(conx, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(false); UIUtil.positionComponent(SwingConstants.CENTER, dialog); //show the simple box and act on the answer. SshToolsSimpleConnectionPrompt stscp = SshToolsSimpleConnectionPrompt.getInstance(); StringBuffer sb = new StringBuffer(); userAction.connect = !stscp.getHostname(sb, profile.getHost()); boolean advanced = stscp.getAdvanced(); if (advanced) { userAction.connect = false; profile.setHost(sb.toString()); conx.hosttab.setConnectionProfile(profile); dialog.setVisible(true); } // Make sure we didn't cancel if (!userAction.connect) { return null; } conx.applyTabs(); if (!advanced) profile.setHost(sb.toString()); if (!advanced) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile.setPort(port); } if (!advanced) profile.setUsername(""); PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_HOST, profile.getHost()); // only save user inputed configuration if (advanced) { PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_USER, profile.getUsername()); PreferencesStore.putInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, profile.getPort()); } // Return the connection properties return profile; }
From source file:savant.ucsc.UCSCNavigationDialog.java
/** This method is called from within the constructor to * initialize the form.//from w ww .j a va 2 s . c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; javax.swing.JButton okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); javax.swing.JPanel navigationPanel = new javax.swing.JPanel(); javax.swing.JLabel cladeLabel = new javax.swing.JLabel(); cladeCombo = new javax.swing.JComboBox(); javax.swing.JLabel genomeLabel = new javax.swing.JLabel(); genomeCombo = new javax.swing.JComboBox(); javax.swing.JLabel groupLabel = new javax.swing.JLabel(); groupCombo = new javax.swing.JComboBox(); javax.swing.JLabel trackLabel = new javax.swing.JLabel(); trackCombo = new javax.swing.JComboBox(); javax.swing.JLabel formatLabelLabel = new javax.swing.JLabel(); formatLabel = new javax.swing.JLabel(); formatCombo = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("UCSC Genome Database"); getContentPane().setLayout(new java.awt.GridBagLayout()); okButton.setText("OK"); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); getContentPane().add(okButton, gridBagConstraints); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); getContentPane().add(cancelButton, gridBagConstraints); navigationPanel.setLayout(new java.awt.GridBagLayout()); cladeLabel.setText("Clade:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(cladeLabel, gridBagConstraints); cladeCombo.setMaximumSize(new java.awt.Dimension(300, 32767)); cladeCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cladeComboActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; navigationPanel.add(cladeCombo, gridBagConstraints); genomeLabel.setText("Genome:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(genomeLabel, gridBagConstraints); genomeCombo.setMaximumSize(new java.awt.Dimension(300, 32767)); genomeCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { genomeComboActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; navigationPanel.add(genomeCombo, gridBagConstraints); groupLabel.setText("Group:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(groupLabel, gridBagConstraints); groupCombo.setMaximumRowCount(9); groupCombo.setMaximumSize(new java.awt.Dimension(300, 32767)); groupCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { groupComboActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; navigationPanel.add(groupCombo, gridBagConstraints); trackLabel.setText("Track:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(trackLabel, gridBagConstraints); trackCombo.setMaximumSize(new java.awt.Dimension(300, 32767)); trackCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { trackComboActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; navigationPanel.add(trackCombo, gridBagConstraints); formatLabelLabel.setText("Format:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(formatLabelLabel, gridBagConstraints); formatLabel.setText("BED"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); navigationPanel.add(formatLabel, gridBagConstraints); formatCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { formatComboActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; navigationPanel.add(formatCombo, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(8, 8, 8, 8); getContentPane().add(navigationPanel, gridBagConstraints); pack(); }
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
public static JFrame createMessageFrame(String title, String msg) { final JFrame frame = new JFrame(title); final JTextArea message = createMultiLineLabel(msg); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); final JPanel messagePanel = new JPanel(); messagePanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.weighty = 0;//from ww w . j ava2s. c om cnstrs.gridheight = 1; messagePanel.add(message, cnstrs); final JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right panel.add(messagePanel, cnstrs); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); cnstrs.gridwidth = GridBagConstraints.REMAINDER; cnstrs.gridheight = 1; cnstrs.weighty = 0; cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right panel.add(buttonPanel, cnstrs); frame.getContentPane().add(panel); frame.pack(); return frame; }