List of usage examples for javax.swing JLabel setText
@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.") public void setText(String text)
From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java
public JPanel instantiatePanel() { final JPanel generalQuestionCont = new JPanel(); generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS)); generalQuestionCont.setBackground(UIHelper.BG_COLOR); JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>" + assay.getTechnologyType() + "</b></html>", JLabel.LEFT); UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false); if (assay.getTechnologyType().equals("")) { info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>"); }//from w w w. j a v a 2 s. c o m info.setPreferredSize(new Dimension(300, 40)); JPanel infoPanel = new JPanel(new GridLayout(1, 1)); infoPanel.setBackground(UIHelper.BG_COLOR); infoPanel.add(info); generalQuestionCont.add(infoPanel); JPanel labelPanel = new JPanel(new GridLayout(1, 2)); labelPanel.setBackground(UIHelper.BG_COLOR); labelCapture = new LabelCapture("Label"); labelCapture.setVisible(false); labelUsed = new JCheckBox("Label used?", false); UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); labelUsed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { labelCapture.setVisible(labelUsed.isSelected()); } }); labelPanel.add(labelUsed); labelPanel.add(labelCapture); generalQuestionCont.add(labelPanel); final JPanel extractPanel = new JPanel(new GridLayout(2, 2)); extractPanel.setBackground(UIHelper.BG_COLOR); extractDetails.clear(); JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *"); extractsUsedLab.setHorizontalAlignment(JLabel.LEFT); extractsUsedLab.setVerticalAlignment(JLabel.TOP); final JPanel extractNameContainer = new JPanel(); extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS)); extractNameContainer.setBackground(UIHelper.BG_COLOR); extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT); UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addButton.setVerticalAlignment(JLabel.TOP); addButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1), ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment()); extractDetails.add(extract); extractNameContainer.add(extract); extractNameContainer.revalidate(); generalQuestionCont.revalidate(); } }); addButton.setToolTipText( "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>"); JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT); removeButton.setVerticalAlignment(JLabel.TOP); UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeButton.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { if (extractDetails.size() > 1) { extract = extractDetails.get(extractDetails.size() - 1); extractDetails.remove(extract); extractNameContainer.remove(extract); generalQuestionCont.revalidate(); } } }); removeButton.setToolTipText( "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>"); extractPanel.add(extractsUsedLab); extractPanel.add(extractNameContainer); JPanel buttonContainer = new JPanel(new GridLayout(1, 2)); buttonContainer.setBackground(UIHelper.BG_COLOR); buttonContainer.add(addButton); buttonContainer.add(removeButton); extractPanel.add(new JLabel()); extractPanel.add(buttonContainer); generalQuestionCont.add(extractPanel); generalQuestionCont.add(Box.createVerticalStrut(5)); generalQuestionCont.add(Box.createHorizontalGlue()); generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9), assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR)); return generalQuestionCont; }
From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java
private void createOntologySelectionPanel() { OntologyListRenderer listRenderer = new OntologyListRenderer(); JPanel westPanel = new JPanel(new BorderLayout()); JPanel selectedOntologiesContainer = new JPanel(new BorderLayout()); selectedOntologiesContainer.setOpaque(false); // create List containing selected ontologies selectedOntologyListModel = new DefaultListModel(); selectedOntologyList = new JList(selectedOntologyListModel); selectedOntologyList.setCellRenderer(new SelectedOntologyListRenderer()); selectedOntologyList.setBackground(UIHelper.BG_COLOR); selectedOntologyList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent listSelectionEvent) { setOntologySelectionPanelPlaceholder(infoImage); setSelectedOntologyButtonVisibility(selectedOntologyList.isSelectionEmpty()); }//from w ww. j a v a 2 s. c om }); JScrollPane selectedOntologiesScroller = new JScrollPane(selectedOntologyList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); selectedOntologiesScroller.setPreferredSize(new Dimension(200, 255)); selectedOntologiesScroller.setBackground(UIHelper.BG_COLOR); selectedOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR); IAppWidgetFactory.makeIAppScrollPane(selectedOntologiesScroller); selectedOntologiesContainer.setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "selected ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); selectedOntologiesContainer.add(selectedOntologiesScroller, BorderLayout.CENTER); // ADD BUTTONS removeOntologyButton = new JLabel(removeOntologyButtonIcon); removeOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!selectedOntologyList.isSelectionEmpty()) { String ontologyToRemove = selectedOntologyList.getSelectedValue().toString(); System.out.println("Removing " + ontologyToRemove); selectedOntologies.remove(ontologyToRemove); setOntologySelectionPanelPlaceholder(infoImage); updateSelectedOntologies(); } removeOntologyButton.setIcon(removeOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { removeOntologyButton.setIcon(removeOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeOntologyButton.setIcon(removeOntologyButtonIcon); } }); removeOntologyButton.setVisible(false); viewOntologyButton = new JLabel(browseOntologyButtonIcon); viewOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { performTransition(); viewOntologyButton.setIcon(browseOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { viewOntologyButton.setIcon(browseOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { viewOntologyButton.setIcon(browseOntologyButtonIcon); } }); viewOntologyButton.setVisible(false); removeRestrictionButton = new JLabel(removeRestrictionButtonIcon); removeRestrictionButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!selectedOntologyList.isSelectionEmpty()) { ((RecommendedOntology) selectedOntologyList.getSelectedValue()).setBranchToSearchUnder(null); removeRestrictionButton.setVisible(false); selectedOntologyList.repaint(); } removeRestrictionButton.setIcon(removeRestrictionButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { removeRestrictionButton.setIcon(removeRestrictionButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeRestrictionButton.setIcon(removeRestrictionButtonIcon); } }); removeRestrictionButton.setVisible(false); Box selectedOntologiesOptionContainer = Box.createHorizontalBox(); selectedOntologiesOptionContainer.setOpaque(false); selectedOntologiesOptionContainer.add(removeOntologyButton); selectedOntologiesOptionContainer.add(viewOntologyButton); selectedOntologiesOptionContainer.add(removeRestrictionButton); selectedOntologiesContainer.add(selectedOntologiesOptionContainer, BorderLayout.SOUTH); // create panel populated with all available ontologies inside a filterable list! JPanel availableOntologiesListContainer = new JPanel(new BorderLayout()); availableOntologiesListContainer .setBorder(new TitledBorder(new RoundedBorder(UIHelper.LIGHT_GREEN_COLOR, 7), "available ontologies", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); final ExtendedJList availableOntologies = new ExtendedJList(listRenderer); final JLabel addOntologyButton = new JLabel(addOntologyButtonIcon); addOntologyButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (!availableOntologies.isSelectionEmpty()) { Ontology ontology = (Ontology) availableOntologies.getSelectedValue(); selectedOntologies.put(ontology.getOntologyDisplayLabel(), new RecommendedOntology(ontology)); updateSelectedOntologies(); setOntologySelectionPanelPlaceholder(infoImage); } addOntologyButton.setIcon(addOntologyButtonIcon); } @Override public void mouseEntered(MouseEvent mouseEvent) { addOntologyButton.setIcon(addOntologyButtonIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addOntologyButton.setIcon(addOntologyButtonIcon); } }); final JLabel info = UIHelper.createLabel("", UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR); availableOntologies.addPropertyChangeListener("update", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { info.setText("<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>"); } }); Box optionsBox = Box.createVerticalBox(); optionsBox.add(UIHelper.wrapComponentInPanel(info)); Box availableOntologiesOptionBox = Box.createHorizontalBox(); availableOntologiesOptionBox.add(addOntologyButton); availableOntologiesOptionBox.add(Box.createHorizontalGlue()); optionsBox.add(availableOntologiesOptionBox); availableOntologiesListContainer.add(optionsBox, BorderLayout.SOUTH); if (ontologiesToBrowseOn == null) { ontologiesToBrowseOn = new ArrayList<Ontology>(); List<Ontology> bioportalQueryResult = bioportalClient.getAllOntologies(); if (bioportalQueryResult != null) { ontologiesToBrowseOn.addAll(bioportalQueryResult); } ontologiesToBrowseOn.addAll(olsClient.getAllOntologies()); } // precautionary check in case of having no ontologies available to search on. if (ontologiesToBrowseOn != null) { for (Ontology o : ontologiesToBrowseOn) { availableOntologies.addItem(o); } } info.setText( "<html>viewing <b>" + availableOntologies.getFilteredItems().size() + "</b> ontologies</html>"); // need to get ontologies available from bioportal and add them here. JScrollPane availableOntologiesScroller = new JScrollPane(availableOntologies, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); availableOntologiesScroller.getViewport().setBackground(UIHelper.BG_COLOR); availableOntologiesScroller.setPreferredSize(new Dimension(200, 125)); availableOntologiesScroller.setBorder(new EmptyBorder(0, 0, 0, 0)); IAppWidgetFactory.makeIAppScrollPane(availableOntologiesScroller); availableOntologiesListContainer.add(availableOntologiesScroller); availableOntologiesListContainer.add(availableOntologies.getFilterField(), BorderLayout.NORTH); westPanel.add(selectedOntologiesContainer, BorderLayout.CENTER); westPanel.add(availableOntologiesListContainer, BorderLayout.SOUTH); add(westPanel, BorderLayout.WEST); }
From source file:org.javaswift.cloudie.CloudiePanel.java
private void createLists() { containersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); containersList.setCellRenderer(new DefaultListCellRenderer() { @Override//from w ww. j a v a2 s .c o m public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); lbl.setBorder(LR_PADDING); Container c = (Container) value; lbl.setText(c.getName()); lbl.setToolTipText(lbl.getText()); return lbl; } }); containersList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { enableDisableContainerMenu(); updateStatusPanelForContainer(); } }); // storedObjectsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); storedObjectsList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); lbl.setBorder(LR_PADDING); StoredObject so = (StoredObject) value; lbl.setText(so.getName()); lbl.setToolTipText(lbl.getText()); return lbl; } }); storedObjectsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { enableDisableStoredObjectMenu(); updateStatusPanelForStoredObject(); } }); }
From source file:org.jcurl.mr.gui.BroomPanel0.java
public BroomPanel0(final Model m) { model = m == null ? new Model() : m; model.addPropertyChangeListener(this); setVisible(false);/*from www. j a v a 2 s. co m*/ setLayout(new BorderLayout()); final JLabel label; this.add(label = new JLabel(), "North"); label.setText("Broom"); label.setHorizontalAlignment(SwingConstants.CENTER); this.add(slider = new JSlider(), "Center"); slider.setOrientation(SwingConstants.VERTICAL); final int max = (int) (new Measure(IceSize.SIDE_2_CENTER, Unit.METER).to(dim).value * Granularity); slider.setMaximum((int) (Granularity * Math.ceil((double) max / Granularity))); // slider.setMaximum(2500); slider.setMinimum(-slider.getMaximum()); slider.setMajorTickSpacing(Granularity); slider.setMinorTickSpacing(Granularity / 10); slider.setAlignmentX(10); slider.setPaintLabels(true); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.addChangeListener(this); this.add(text = new JTextField(), "South"); text.setHorizontalAlignment(SwingConstants.CENTER); text.setEditable(true); text.addActionListener(this); text.selectAll(); this.setSize(50, 100); model.setBroomX(new Measure(0, dim)); setVisible(true); }
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Initialises the application's GUI elements. */// w ww. j a va 2 s . c o m private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(cockpitLiteProperties.getProperties()); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } // Primary panel that contains all other items. JPanel primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel"); primaryPanel.setLayout(new GridBagLayout()); this.getContentPane().add(primaryPanel); // Setup the stack panel, which contains all other panels as a stack. stackPanel = skinsFactory.createSkinnedJPanel("StackPanel"); stackPanelCardLayout = new CardLayout(); stackPanel.setLayout(stackPanelCardLayout); primaryPanel.add(stackPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Progress notification panel progressNotificationPanel = skinsFactory.createSkinnedJPanel("ProgressNotificationPanel"); progressNotificationPanel.setLayout(new GridBagLayout()); primaryPanel.add(progressNotificationPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 0), 0, 0)); int row = 0; // Login panel. row = 0; loginPanel = skinsFactory.createSkinnedJPanel("LoginPanel"); loginPanel.setLayout(new GridBagLayout()); userInputFields = new UserInputFields(insetsDefault, null, skinsFactory); userInputFields.buildFieldsPanel(loginPanel, cockpitLiteProperties); loginButton = skinsFactory.createSkinnedJButton("LoginButton"); loginButton.setText("Log me in"); loginButton.addActionListener(this); loginPanel.add(loginButton, new GridBagConstraints(0, loginPanel.getComponentCount(), 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Filter panel. filterObjectsPanel = skinsFactory.createSkinnedJPanel("FilterPanel"); filterObjectsPanel.setLayout(new GridBagLayout()); filterObjectsPrefix = skinsFactory.createSkinnedJTextField("FilterPrefix"); filterObjectsPrefix.setToolTipText("Only show files starting with this string"); filterObjectsPrefix.addActionListener(this); filterObjectsPrefix.setActionCommand("RefreshObjects"); JLabel filterPrefixLabel = skinsFactory.createSkinnedJHtmlLabel("FilterPrefixLable", this); filterPrefixLabel.setText("File name starts with: "); filterObjectsPanel.add(filterPrefixLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); filterObjectsPanel.setVisible(false); // Objects panel. row = 0; JPanel objectsPanel = skinsFactory.createSkinnedJPanel("ObjectsPanel"); objectsPanel.setLayout(new GridBagLayout()); filterObjectsCheckBox = skinsFactory.createSkinnedJCheckBox("FilterCheckbox"); filterObjectsCheckBox.setText("Search files"); filterObjectsCheckBox.setEnabled(true); filterObjectsCheckBox.addActionListener(this); filterObjectsCheckBox.setToolTipText("Check this option to search your files"); objectsHeadingLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsHeadingLabel", this); objectsHeadingLabel.setText("Not logged in"); objectsPanel.add(objectsHeadingLabel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); JButton objectActionButton = skinsFactory.createSkinnedJButton("ObjectMenuButton"); objectActionButton.setToolTipText("File actions menu"); guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png"); objectActionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton) e.getSource(); objectActionMenu.show(sourceButton, 0, sourceButton.getHeight()); } }); objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsTable = skinsFactory.createSkinnedJTable("ObjectsTable"); objectTableModel = new CLObjectTableModel(); objectTableModelSorter = new TableSorter(objectTableModel); objectTableModelSorter.setTableHeader(objectsTable.getTableHeader()); objectsTable.setModel(objectTableModelSorter); objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = 7229656175879985698L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue()); return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column); } }); objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = -4983176028291916397L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Date date = (Date) value; return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus, row, column); } }); objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); objectsTable.getSelectionModel().addListSelectionListener(this); objectsTable.setShowHorizontalLines(true); objectsTable.setShowVerticalLines(true); objectsTable.addMouseListener(new ContextMenuListener()); objectsTableSP = skinsFactory.createSkinnedJScrollPane("ObjectsTableSP", objectsTable); objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); objectsSummaryLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsSummary", this); objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER); objectsSummaryLabel.setFocusable(false); objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Object action menu. objectActionMenu = skinsFactory.createSkinnedJPopupMenu("ObjectPopupMenu"); refreshObjectMenuItem = skinsFactory.createSkinnedJMenuItem("RefreshMenuItem"); refreshObjectMenuItem.setText("Refresh file listing"); refreshObjectMenuItem.setActionCommand("RefreshObjects"); refreshObjectMenuItem.addActionListener(this); guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png"); objectActionMenu.add(refreshObjectMenuItem); viewObjectPropertiesMenuItem = skinsFactory.createSkinnedJMenuItem("PropertiesMenuItem"); viewObjectPropertiesMenuItem.setText("View file properties..."); viewObjectPropertiesMenuItem.setActionCommand("ViewObjectProperties"); viewObjectPropertiesMenuItem.addActionListener(this); guiUtils.applyIcon(viewObjectPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); objectActionMenu.add(viewObjectPropertiesMenuItem); downloadObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DownloadMenuItem"); downloadObjectMenuItem.setText("Download file(s)..."); downloadObjectMenuItem.setActionCommand("DownloadObjects"); downloadObjectMenuItem.addActionListener(this); guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png"); objectActionMenu.add(downloadObjectMenuItem); uploadFilesMenuItem = skinsFactory.createSkinnedJMenuItem("UploadMenuItem"); uploadFilesMenuItem.setText("Upload file(s)..."); uploadFilesMenuItem.setActionCommand("UploadFiles"); uploadFilesMenuItem.addActionListener(this); guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png"); objectActionMenu.add(uploadFilesMenuItem); objectActionMenu.add(new JSeparator()); togglePublicMenuItem = skinsFactory.createSkinnedJMenuItem("AclToggleMenuItem"); togglePublicMenuItem.setText("Change privacy setting..."); togglePublicMenuItem.setActionCommand("TogglePublicPrivate"); togglePublicMenuItem.addActionListener(this); guiUtils.applyIcon(togglePublicMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); objectActionMenu.add(togglePublicMenuItem); generatePublicGetUrl = skinsFactory.createSkinnedJMenuItem("PublicUrlMenuItem"); generatePublicGetUrl.setText("Public web link..."); generatePublicGetUrl.setActionCommand("GeneratePublicGetURL"); generatePublicGetUrl.addActionListener(this); guiUtils.applyIcon(generatePublicGetUrl, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generatePublicGetUrl); objectActionMenu.add(new JSeparator()); deleteObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DeleteMenuItem"); deleteObjectMenuItem.setText("Delete file(s)..."); deleteObjectMenuItem.setActionCommand("DeleteObjects"); deleteObjectMenuItem.addActionListener(this); guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png"); objectActionMenu.add(deleteObjectMenuItem); viewObjectPropertiesMenuItem.setEnabled(false); refreshObjectMenuItem.setEnabled(false); togglePublicMenuItem.setEnabled(false); downloadObjectMenuItem.setEnabled(false); generatePublicGetUrl.setEnabled(false); deleteObjectMenuItem.setEnabled(false); // Card layout in stack panel stackPanel.add(loginPanel, "LoginPanel"); stackPanel.add(objectsPanel, "ObjectsPanel"); // Set preferred sizes int preferredWidth = 800; int preferredHeight = 600; this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); // Initialize drop target. initDropTarget(new JComponent[] { objectsPanel }); objectsPanel.getDropTarget().setActive(true); }
From source file:org.jets3t.gui.ItemPropertiesDialog.java
/** * Initialise the GUI elements to display the given item. * * @param s3Item/* ww w . j a v a2 s . c o m*/ * the S3Bucket or an S3Object whose details will be displayed */ private void initGui(boolean isObjectBased) { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(applicationProperties); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } this.setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel commonPropertiesContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesCommonPanel"); commonPropertiesContainer.setLayout(new GridBagLayout()); JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesMetadataPanel"); metadataContainer.setLayout(new GridBagLayout()); JPanel grantsContainer = skinsFactory.createSkinnedJPanel("ItemPropertiesGrantsPanel"); grantsContainer.setLayout(new GridBagLayout()); if (!isObjectBased) { // Display bucket details. JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel"); bucketNameLabel.setText("Bucket name:"); bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField"); bucketNameTextField.setEditable(false); JLabel bucketLocationLabel = skinsFactory.createSkinnedJHtmlLabel("BucketLocationLabel"); bucketLocationLabel.setText("Location:"); bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField"); bucketLocationTextField.setEditable(false); JLabel bucketCreationDateLabel = skinsFactory.createSkinnedJHtmlLabel("BucketCreationDateLabel"); bucketCreationDateLabel.setText("Creation date:"); bucketCreationDateTextField = skinsFactory.createSkinnedJTextField("BucketCreationDateTextField"); bucketCreationDateTextField.setEditable(false); ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel"); ownerNameLabel.setText("Owner name:"); ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField"); ownerNameTextField.setEditable(false); ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel"); ownerIdLabel.setText("Owner ID:"); ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField"); ownerIdTextField.setEditable(false); bucketIsRequesterPaysLabel = skinsFactory.createSkinnedJHtmlLabel("BucketIsRequesterPaysLabel"); bucketIsRequesterPaysLabel.setText("Requester Pays?"); bucketIsRequesterPaysCheckBox = skinsFactory.createSkinnedJCheckBox("BucketIsRequesterPaysCheckBox"); bucketIsRequesterPaysCheckBox.setEnabled(false); int row = 0; commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketLocationLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketLocationTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketCreationDateLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketCreationDateTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketIsRequesterPaysLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketIsRequesterPaysCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, ++row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); } else { // Display object details. JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel"); objectKeyLabel.setText("Object key:"); objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField"); objectKeyTextField.setEditable(false); JLabel objectContentTypeLabel = skinsFactory.createSkinnedJHtmlLabel("ContentTypeLabel"); objectContentTypeLabel.setText("Content type:"); objectContentTypeTextField = skinsFactory.createSkinnedJTextField("ContentTypeTextField"); objectContentTypeTextField.setEditable(false); JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel"); objectContentLengthLabel.setText("Size:"); objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField"); objectContentLengthTextField.setEditable(false); JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel"); objectLastModifiedLabel.setText("Last modified:"); objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField"); objectLastModifiedTextField.setEditable(false); JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel"); objectETagLabel.setText("ETag:"); objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField"); objectETagTextField.setEditable(false); JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel"); bucketNameLabel.setText("Bucket name:"); bucketNameTextField = skinsFactory.createSkinnedJTextField("BucketNameTextField"); bucketNameTextField.setEditable(false); ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel"); ownerNameLabel.setText("Owner name:"); ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField"); ownerNameTextField.setEditable(false); ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel"); ownerIdLabel.setText("Owner ID:"); ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField"); ownerIdTextField.setEditable(false); commonPropertiesContainer.add(objectKeyLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectKeyTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectContentTypeLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectContentTypeTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectContentLengthLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectContentLengthTextField, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectLastModifiedLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectLastModifiedTextField, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectETagLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(objectETagTextField, new GridBagConstraints(1, 4, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketNameLabel, new GridBagConstraints(0, 5, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(bucketNameTextField, new GridBagConstraints(1, 5, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerNameLabel, new GridBagConstraints(0, 7, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerNameTextField, new GridBagConstraints(1, 7, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerIdLabel, new GridBagConstraints(0, 8, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); commonPropertiesContainer.add(ownerIdTextField, new GridBagConstraints(1, 8, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Build metadata table. objectMetadataTableModel = new DefaultTableModel(new Object[] { "Name", "Value" }, 0) { private static final long serialVersionUID = -3762866886166776851L; @Override public boolean isCellEditable(int row, int column) { return false; } }; TableSorter metadataTableSorter = new TableSorter(objectMetadataTableModel); JTable metadataTable = skinsFactory.createSkinnedJTable("MetadataTable"); metadataTable.setModel(metadataTableSorter); metadataTableSorter.setTableHeader(metadataTable.getTableHeader()); metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); } // Build grants table. grantsTableModel = new DefaultTableModel(new Object[] { "Grantee", "Permission" }, 0) { private static final long serialVersionUID = -5882427163845726770L; @Override public boolean isCellEditable(int row, int column) { return false; } }; TableSorter grantsTableSorter = new TableSorter(grantsTableModel); grantsTable = skinsFactory.createSkinnedJTable("GrantsTable"); grantsTable.setModel(grantsTableSorter); grantsTableSorter.setTableHeader(grantsTable.getTableHeader()); grantsContainer.add(new JScrollPane(grantsTable), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // OK Button. JButton okButton = skinsFactory.createSkinnedJButton("ItemPropertiesOKButton"); okButton.setText("Finished"); okButton.setActionCommand("OK"); okButton.addActionListener(this); // Set default ENTER button. this.getRootPane().setDefaultButton(okButton); // Put it all together. int row = 0; JPanel container = skinsFactory.createSkinnedJPanel("ItemPropertiesPanel"); container.setLayout(new GridBagLayout()); container.add(commonPropertiesContainer, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); if (isObjectBased) { if (includeMetadata) { JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel"); metadataLabel.setText("<html><b>Metadata</b></html>"); metadataLabel.setHorizontalAlignment(JLabel.CENTER); container.add(metadataLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0)); container.add(metadataContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); } // Object previous and next buttons, if we have multiple objects. previousObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesPreviousButton"); previousObjectButton.setText("Previous"); previousObjectButton.addActionListener(this); previousObjectButton.setEnabled(false); nextObjectButton = skinsFactory.createSkinnedJButton("ItemPropertiesNextButton"); nextObjectButton.setText("Next"); nextObjectButton.addActionListener(this); nextObjectButton.setEnabled(false); currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ItemPropertiesCurrentObjectLabel"); currentObjectLabel.setHorizontalAlignment(JLabel.CENTER); nextPreviousPanel = skinsFactory.createSkinnedJPanel("ItemPropertiesNextPreviousPanel"); nextPreviousPanel.setLayout(new GridBagLayout()); nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); row++; } else { JHtmlLabel grantsLabel = skinsFactory.createSkinnedJHtmlLabel("GrantsLabel"); grantsLabel.setText("<html><b>Permissions</b></html>"); grantsLabel.setHorizontalAlignment(JLabel.CENTER); container.add(grantsLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0)); container.add(grantsContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); } container.add(okButton, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); this.getContentPane().add(container); this.pack(); if (isObjectBased) { this.setSize(400, (includeMetadata ? 550 : 400)); } this.setLocationRelativeTo(this.getOwner()); }
From source file:org.jets3t.gui.ObjectsAttributesDialog.java
/** * Initialise the GUI elements to display the given item. *//*from w ww . java2 s .c o m*/ private void initGui() { this.setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel unmodifiableAttributesPanel = skinsFactory.createSkinnedJPanel("ObjectStaticAttributesPanel"); unmodifiableAttributesPanel.setLayout(new GridBagLayout()); JPanel metadataContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataPanel"); metadataContainer.setLayout(new GridBagLayout()); metadataButtonsContainer = skinsFactory.createSkinnedJPanel("ObjectPropertiesMetadataButtonsPanel"); metadataButtonsContainer.setLayout(new GridBagLayout()); // Fields to display unmodifiable object details. JLabel objectKeyLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectKeyLabel"); objectKeyLabel.setText("Object key:"); objectKeyTextField = skinsFactory.createSkinnedJTextField("ObjectKeyTextField"); objectKeyTextField.setEditable(false); JLabel objectContentLengthLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectContentLengthLabel"); objectContentLengthLabel.setText("Size:"); objectContentLengthTextField = skinsFactory.createSkinnedJTextField("ObjectContentLengthTextField"); objectContentLengthTextField.setEditable(false); JLabel objectLastModifiedLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectLastModifiedLabel"); objectLastModifiedLabel.setText("Last modified:"); objectLastModifiedTextField = skinsFactory.createSkinnedJTextField("ObjectLastModifiedTextField"); objectLastModifiedTextField.setEditable(false); JLabel objectETagLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectETagLabel"); objectETagLabel.setText("ETag:"); objectETagTextField = skinsFactory.createSkinnedJTextField("ObjectETagTextField"); objectETagTextField.setEditable(false); JLabel bucketNameLabel = skinsFactory.createSkinnedJHtmlLabel("BucketNameLabel"); bucketNameLabel.setText("Bucket:"); bucketLocationTextField = skinsFactory.createSkinnedJTextField("BucketLocationTextField"); bucketLocationTextField.setEditable(false); ownerNameLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerNameLabel"); ownerNameLabel.setText("Owner name:"); ownerNameTextField = skinsFactory.createSkinnedJTextField("OwnerNameTextField"); ownerNameTextField.setEditable(false); ownerIdLabel = skinsFactory.createSkinnedJHtmlLabel("OwnerIdLabel"); ownerIdLabel.setText("Owner ID:"); ownerIdTextField = skinsFactory.createSkinnedJTextField("OwnerIdTextField"); ownerIdTextField.setEditable(false); int row = 0; unmodifiableAttributesPanel.add(objectKeyLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectKeyTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectContentLengthLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectContentLengthTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectLastModifiedLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectLastModifiedTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(objectETagLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(objectETagTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(ownerNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(ownerNameTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(ownerIdLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(ownerIdTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); row++; unmodifiableAttributesPanel.add(bucketNameLabel, new GridBagConstraints(0, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); unmodifiableAttributesPanel.add(bucketLocationTextField, new GridBagConstraints(1, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Build metadata table. objectMetadataTableModel = new DefaultTableModel(new Object[] { "Name", "Value" }, 0) { private static final long serialVersionUID = -3762866886166776851L; public boolean isCellEditable(int row, int column) { return isModifyMode(); } }; metadataTableSorter = new TableSorter(objectMetadataTableModel); metadataTable = skinsFactory.createSkinnedJTable("MetadataTable"); metadataTable.setModel(metadataTableSorter); metadataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && removeMetadataItemButton != null) { int row = metadataTable.getSelectedRow(); removeMetadataItemButton.setEnabled(row >= 0); } } }); metadataTableSorter.setTableHeader(metadataTable.getTableHeader()); metadataTableSorter.setSortingStatus(0, TableSorter.ASCENDING); metadataContainer.add(new JScrollPane(metadataTable), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsHorizontalSpace, 0, 0)); // Add/remove buttons for metadata table. removeMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); removeMetadataItemButton.setEnabled(false); removeMetadataItemButton.setToolTipText("Remove the selected metadata item(s)"); guiUtils.applyIcon(removeMetadataItemButton, "/images/nuvola/16x16/actions/viewmag-.png"); removeMetadataItemButton.addActionListener(this); removeMetadataItemButton.setActionCommand("removeMetadataItem"); addMetadataItemButton = skinsFactory.createSkinnedJButton("ObjectPropertiesAddMetadataButton"); addMetadataItemButton.setToolTipText("Add a new metadata item"); guiUtils.applyIcon(addMetadataItemButton, "/images/nuvola/16x16/actions/viewmag+.png"); addMetadataItemButton.setActionCommand("addMetadataItem"); addMetadataItemButton.addActionListener(this); metadataButtonsContainer.add(removeMetadataItemButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataButtonsContainer.add(addMetadataItemButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsZero, 0, 0)); metadataContainer.add(metadataButtonsContainer, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); metadataButtonsContainer.setVisible(false); // OK Button. okButton = skinsFactory.createSkinnedJButton("ObjectPropertiesOKButton"); okButton.setText("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(this); // Cancel Button. cancelButton = null; cancelButton = skinsFactory.createSkinnedJButton("ObjectPropertiesCancelButton"); cancelButton.setText("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); cancelButton.setVisible(false); // Recognize and handle ENTER, ESCAPE, PAGE_UP, and PAGE_DOWN key presses. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -7768790936535999307L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_UP"), "PAGE_UP"); this.getRootPane().getActionMap().put("PAGE_UP", new AbstractAction() { private static final long serialVersionUID = -6324229423705756219L; public void actionPerformed(ActionEvent actionEvent) { previousObjectButton.doClick(); } }); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("PAGE_DOWN"), "PAGE_DOWN"); this.getRootPane().getActionMap().put("PAGE_DOWN", new AbstractAction() { private static final long serialVersionUID = -5808972377672449421L; public void actionPerformed(ActionEvent actionEvent) { nextObjectButton.doClick(); } }); // Put it all together. row = 0; JPanel container = skinsFactory.createSkinnedJPanel("ObjectPropertiesPanel"); container.setLayout(new GridBagLayout()); container.add(unmodifiableAttributesPanel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); // Object previous and next buttons, if we have multiple objects. previousObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesPreviousButton"); guiUtils.applyIcon(previousObjectButton, "/images/nuvola/16x16/actions/1leftarrow.png"); previousObjectButton.addActionListener(this); previousObjectButton.setEnabled(false); nextObjectButton = skinsFactory.createSkinnedJButton("ObjectPropertiesNextButton"); guiUtils.applyIcon(nextObjectButton, "/images/nuvola/16x16/actions/1rightarrow.png"); nextObjectButton.addActionListener(this); nextObjectButton.setEnabled(false); currentObjectLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectPropertiesCurrentObjectLabel"); currentObjectLabel.setHorizontalAlignment(JLabel.CENTER); nextPreviousPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesNextPreviousPanel"); nextPreviousPanel.setLayout(new GridBagLayout()); nextPreviousPanel.add(previousObjectButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); nextPreviousPanel.add(currentObjectLabel, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsHorizontalSpace, 0, 0)); nextPreviousPanel.add(nextObjectButton, new GridBagConstraints(2, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); container.add(nextPreviousPanel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); nextPreviousPanel.setVisible(false); row++; JHtmlLabel metadataLabel = skinsFactory.createSkinnedJHtmlLabel("MetadataLabel"); metadataLabel.setText("<html><b>Metadata Attributes</b></html>"); metadataLabel.setHorizontalAlignment(JLabel.CENTER); container.add(metadataLabel, new GridBagConstraints(0, row++, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsVerticalSpace, 0, 0)); container.add(metadataContainer, new GridBagConstraints(0, row++, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Destination Access Control List setting. destinationPanel = skinsFactory.createSkinnedJPanel("DestinationPanel"); destinationPanel.setLayout(new GridBagLayout()); JPanel actionButtonsPanel = skinsFactory.createSkinnedJPanel("ObjectPropertiesActionButtonsPanel"); actionButtonsPanel.setLayout(new GridBagLayout()); actionButtonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); actionButtonsPanel.add(okButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); cancelButton.setVisible(false); container.add(actionButtonsPanel, new GridBagConstraints(0, row++, 3, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); this.getContentPane().add(container); this.pack(); this.setSize(new Dimension(450, 500)); this.setLocationRelativeTo(this.getOwner()); }
From source file:org.jtrfp.trcl.gui.ConfigWindow.java
public ConfigWindow() { setTitle("Settings"); setSize(340, 540);// w w w . j av a2 s . c om if (config == null) config = new TRConfiguration(); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel generalTab = new JPanel(); tabbedPane.addTab("General", new ImageIcon(ConfigWindow.class .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")), generalTab, null); GridBagLayout gbl_generalTab = new GridBagLayout(); gbl_generalTab.columnWidths = new int[] { 0, 0 }; gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 }; gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; generalTab.setLayout(gbl_generalTab); JPanel settingsLoadSavePanel = new JPanel(); GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints(); gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0); gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST; gbc_settingsLoadSavePanel.gridx = 0; gbc_settingsLoadSavePanel.gridy = 0; generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel); settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); JButton btnSave = new JButton("Export..."); btnSave.setToolTipText("Export these settings to an external file"); settingsLoadSavePanel.add(btnSave); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { exportSettings(); } }); JButton btnLoad = new JButton("Import..."); btnLoad.setToolTipText("Import an external settings file"); settingsLoadSavePanel.add(btnLoad); btnLoad.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { importSettings(); } }); JButton btnConfigReset = new JButton("Reset"); btnConfigReset.setToolTipText("Reset all settings to defaults"); settingsLoadSavePanel.add(btnConfigReset); btnConfigReset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { defaultSettings(); } }); JPanel registeredPODsPanel = new JPanel(); registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null)); GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints(); gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0); gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH; gbc_registeredPODsPanel.gridx = 0; gbc_registeredPODsPanel.gridy = 1; generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel); GridBagLayout gbl_registeredPODsPanel = new GridBagLayout(); gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 }; gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 }; gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; registeredPODsPanel.setLayout(gbl_registeredPODsPanel); JPanel podListPanel = new JPanel(); GridBagConstraints gbc_podListPanel = new GridBagConstraints(); gbc_podListPanel.insets = new Insets(0, 0, 5, 0); gbc_podListPanel.fill = GridBagConstraints.BOTH; gbc_podListPanel.gridx = 0; gbc_podListPanel.gridy = 0; registeredPODsPanel.add(podListPanel, gbc_podListPanel); podListPanel.setLayout(new BorderLayout(0, 0)); JScrollPane podListScrollPane = new JScrollPane(); podListPanel.add(podListScrollPane, BorderLayout.CENTER); podList = new JList(podLM); podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); podListScrollPane.setViewportView(podList); JPanel podListOpButtonPanel = new JPanel(); podListOpButtonPanel.setBorder(null); GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints(); gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_podListOpButtonPanel.gridx = 0; gbc_podListOpButtonPanel.gridy = 1; registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel); FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); JButton addPodButton = new JButton("Add..."); addPodButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game."); podListOpButtonPanel.add(addPodButton); addPodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addPOD(); } }); JButton removePodButton = new JButton("Remove"); removePodButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removePodButton.setToolTipText("Remove a POD file from being considered when playing a game"); podListOpButtonPanel.add(removePodButton); removePodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { podLM.removeElement(podList.getSelectedValue()); } }); JButton podEditButton = new JButton("Edit..."); podEditButton.setIcon(null); podEditButton.setToolTipText("Edit the selected POD path"); podListOpButtonPanel.add(podEditButton); podEditButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editPODPath(); } }); JPanel missionPanel = new JPanel(); GridBagConstraints gbc_missionPanel = new GridBagConstraints(); gbc_missionPanel.fill = GridBagConstraints.BOTH; gbc_missionPanel.gridx = 0; gbc_missionPanel.gridy = 2; generalTab.add(missionPanel, gbc_missionPanel); missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gbl_missionPanel = new GridBagLayout(); gbl_missionPanel.columnWidths = new int[] { 0, 0 }; gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; missionPanel.setLayout(gbl_missionPanel); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; missionPanel.add(scrollPane, gbc_scrollPane); missionList = new JList(missionLM); missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(missionList); JPanel missionListOpButtonPanel = new JPanel(); GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints(); gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_missionListOpButtonPanel.gridx = 0; gbc_missionListOpButtonPanel.gridy = 1; missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel); JButton addVOXButton = new JButton("Add..."); addVOXButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addVOXButton.setToolTipText("Add an external VOX file as a mission"); missionListOpButtonPanel.add(addVOXButton); addVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addVOX(); } }); final JButton removeVOXButton = new JButton("Remove"); removeVOXButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removeVOXButton.setToolTipText("Remove the selected mission"); missionListOpButtonPanel.add(removeVOXButton); removeVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { missionLM.remove(missionList.getSelectedIndex()); } }); final JButton editVOXButton = new JButton("Edit..."); editVOXButton.setToolTipText("Edit the selected Mission's VOX path"); missionListOpButtonPanel.add(editVOXButton); editVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editVOXPath(); } }); missionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { final String val = (String) missionList.getSelectedValue(); if (val == null) missionList.setSelectedIndex(0); else if (isBuiltinVOX(val)) { removeVOXButton.setEnabled(false); editVOXButton.setEnabled(false); } else { removeVOXButton.setEnabled(true); editVOXButton.setEnabled(true); } } }); JPanel soundTab = new JPanel(); tabbedPane.addTab("Sound", new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")), soundTab, null); GridBagLayout gbl_soundTab = new GridBagLayout(); gbl_soundTab.columnWidths = new int[] { 0, 0 }; gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 }; gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; soundTab.setLayout(gbl_soundTab); JPanel checkboxPanel = new JPanel(); GridBagConstraints gbc_checkboxPanel = new GridBagConstraints(); gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0); gbc_checkboxPanel.fill = GridBagConstraints.BOTH; gbc_checkboxPanel.gridx = 0; gbc_checkboxPanel.gridy = 0; soundTab.add(checkboxPanel, gbc_checkboxPanel); chckbxLinearInterpolation = new JCheckBox("Linear Filtering"); chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples."); chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT); checkboxPanel.add(chckbxLinearInterpolation); chckbxLinearInterpolation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { needRestart = true; } }); chckbxBufferLag = new JCheckBox("Buffer Lag"); chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency."); checkboxPanel.add(chckbxBufferLag); JPanel modStereoWidthPanel = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints(); gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH; gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0); gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_modStereoWidthPanel.gridx = 0; gbc_modStereoWidthPanel.gridy = 1; soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel); modStereoWidthSlider = new JSlider(); modStereoWidthSlider.setPaintTicks(true); modStereoWidthSlider.setMinorTickSpacing(25); modStereoWidthPanel.add(modStereoWidthSlider); final JLabel modStereoWidthLbl = new JLabel("NN%"); modStereoWidthPanel.add(modStereoWidthLbl); JPanel bufferSizePanel = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); bufferSizePanel.setBorder( new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints(); gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH; gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0); gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL; gbc_bufferSizePanel.gridx = 0; gbc_bufferSizePanel.gridy = 2; soundTab.add(bufferSizePanel, gbc_bufferSizePanel); audioBufferSizeCB = new JComboBox(); audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values())); bufferSizePanel.add(audioBufferSizeCB); soundOutputSelectorGUI = new SoundOutputSelectorGUI(); soundOutputSelectorGUI.setBorder( new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints(); gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH; gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0); gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL; gbc_soundOutputSelectorGUI.gridx = 0; gbc_soundOutputSelectorGUI.gridy = 3; soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI); modStereoWidthSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%"); needRestart = true; } }); JPanel okCancelPanel = new JPanel(); getContentPane().add(okCancelPanel, BorderLayout.SOUTH); okCancelPanel.setLayout(new BorderLayout(0, 0)); JButton btnOk = new JButton("OK"); btnOk.setToolTipText("Apply these settings and close the window"); okCancelPanel.add(btnOk, BorderLayout.WEST); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { applySettings(); ConfigWindow.this.setVisible(false); } }); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Close the window without applying settings"); okCancelPanel.add(btnCancel, BorderLayout.EAST); JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath()); lblConfigpath.setIcon(null); lblConfigpath.setToolTipText("Default config file path"); lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER); lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6)); okCancelPanel.add(lblConfigpath, BorderLayout.CENTER); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ConfigWindow.this.setVisible(false); } }); }
From source file:org.kineticsystem.commons.data.view.renderer.BeanComboBoxRenderer.java
/** {@inheritDoc} */ @Override/*from w ww . j a v a2 s .co m*/ public Component getListCellRendererComponent(JList list, Object obj, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, obj, index, isSelected, cellHasFocus); try { String text = BeanRenderUtils.getPropertyValue(obj, propertyName, format); label.setText(text); } catch (Exception ex) { logger.error(ex); } return label; }
From source file:org.kineticsystem.commons.data.view.renderer.BeanTableCellRenderer.java
/** {@inheritDoc} */ @Override//from w w w . ja va 2 s. c o m public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, obj, isSelected, hasFocus, row, column); try { String text = BeanRenderUtils.getPropertyValue(obj, propertyName, format); label.setText(text); } catch (Exception ex) { logger.error(ex); } return label; }