List of usage examples for javax.swing JScrollPane setBounds
public void setBounds(Rectangle r)
From source file:Main.java
/** * Creates a new <code>JScrollPane</code> object with the given properties. * * @param component The component of the scroll pane * @param bounds The dimension of the component * @param backgroundColor The color of the background * @param noBorder if true then the scroll pane is without border otherwise * the scroll pane will have also a border * @param visible if true then the scroll pane will be visible otherwise the * scroll pane will be invisible//from w ww. j av a2 s . co m * @return A <code>JScrollPane</code> object */ public static JScrollPane createJScrollPane(Component component, Rectangle bounds, Color backgroundColor, boolean noBorder, boolean visible) { JScrollPane pane = new JScrollPane(); if (bounds != null) { pane.setBounds(bounds); } pane.setBackground(backgroundColor); pane.setViewportView(component); if (noBorder) { pane.setBorder(null); } if (!visible) { pane.setVisible(false); } return pane; }
From source file:com.funambol.foundation.admin.FileDataObjectSyncSourceConfigPanel.java
/** * Create the panel// ww w . j a va 2 s . c om */ private void init() { // set layout this.setLayout(null); // set properties of label, position and border // referred to the title of the panel titledBorder1 = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText("Edit File Data Object SyncSource"); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder1); int y = 60; int dy = 30; sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(new Rectangle(14, y, 150, 18)); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(new Rectangle(14, y, 150, 18)); nameValue.setFont(defaultFont); nameValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; storageProviderLabel.setText("Storage type:"); storageProviderLabel.setFont(defaultFont); storageProviderLabel.setBounds(new Rectangle(14, y, 150, 18)); //list of supported storage providers String[] providers = new String[] { PROVIDER_FILESYSTEM, PROVIDER_S3 }; storageProviderValue = new JComboBox(providers); storageProviderValue.addActionListener(jcloudsProviderValueActionListener); storageProviderValue.setFont(defaultFont); storageProviderValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; // storageContainerNameLabel.setText("Provider container name:"); storageContainerNameLabel.setFont(defaultFont); storageContainerNameLabel.setBounds(new Rectangle(14, y, 150, 18)); storageContainerNameValue.setFont(defaultFont); storageContainerNameValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; // storageIdentityLabel.setText("Provider identity:"); storageIdentityLabel.setFont(defaultFont); storageIdentityLabel.setBounds(new Rectangle(14, y, 150, 18)); storageIdentityValue.setFont(defaultFont); storageIdentityValue.setBounds(new Rectangle(170, y, 350, 18)); //storage provider identity and storageFilesystemRootPathLabel aren't //showed together, so leaving the y coordinate equals the panel has a better //aspect for different storage types //y += dy; // storageFilesystemRootPathLabel.setText("Local path for filesystem provider:"); storageFilesystemRootPathLabel.setFont(defaultFont); storageFilesystemRootPathLabel.setBounds(new Rectangle(14, y, 150, 18)); storageFilesystemRootPathValue.setFont(defaultFont); storageFilesystemRootPathValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; // storageCredentialLabel.setText("Provider credential:"); storageCredentialLabel.setFont(defaultFont); storageCredentialLabel.setBounds(new Rectangle(14, y, 150, 18)); storageCredentialValue.setFont(defaultFont); storageCredentialValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; localRootPathLabel.setText("Root local path for temp files: "); localRootPathLabel.setFont(defaultFont); localRootPathLabel.setBounds(new Rectangle(14, y, 150, 18)); localRootPathValue.setFont(defaultFont); localRootPathValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; quotaLabel.setText("Quota: "); quotaLabel.setFont(defaultFont); quotaLabel.setBounds(new Rectangle(14, y, 150, 18)); model = new RolesTableModel(); quotaTable = new JTable(model); quotaTable.setFont(defaultFont); quotaTable.setShowGrid(true); quotaTable.setAutoscrolls(true); quotaTable.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); //add the table into a JScrollPanel, otherwise no columns headers and border //will be show JScrollPane scrollpane = new JScrollPane(quotaTable); scrollpane.setBounds(new Rectangle(170, y, 350, 110)); quotaTable.setPreferredScrollableViewportSize(new Dimension(350, 110)); y += dy + 75; notaLabel.setText( "<html>Please enter the number followed by 'M' if it is 'MegaBytes', or 'G' if it is 'GigaBytes'<BR>Example: '100 M' stands for 100 MegaBytes, '2 G' stands for 2 GigaBytes</html>"); notaLabel.setFont(defaultFont); notaLabel.setBounds(new Rectangle(170, y, 350, 54)); //button separed from other controls, and the height of the table y += dy + 36; confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(170, y, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { FileDataObjectSyncSourceConfigPanel.this .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { FileDataObjectSyncSourceConfigPanel.this .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // add all components to the panel this.add(panelName, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameLabel, null); this.add(nameValue, null); this.add(storageProviderLabel, null); this.add(storageProviderValue, null); this.add(storageContainerNameLabel, null); this.add(storageContainerNameValue, null); this.add(storageIdentityLabel, null); this.add(storageIdentityValue, null); this.add(storageCredentialLabel, null); this.add(storageCredentialValue, null); this.add(storageFilesystemRootPathLabel, null); this.add(storageFilesystemRootPathValue, null); this.add(localRootPathLabel, null); this.add(localRootPathValue, null); this.add(quotaLabel, null); this.add(scrollpane, null); this.add(notaLabel, null); this.add(confirmButton, null); }