List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:display.containers.FileManager.java
public Container getPane() { //if (gui==null) { fileSystemView = FileSystemView.getFileSystemView(); desktop = Desktop.getDesktop(); JPanel detailView = new JPanel(new BorderLayout(3, 3)); //fileTableModel = new FileTableModel(); table = new JTable(); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setAutoCreateRowSorter(true);//w w w .j a v a 2 s . c o m table.setShowVerticalLines(false); table.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getClickCount() >= 2) { Point p = e.getPoint(); int row = table.convertRowIndexToModel(table.rowAtPoint(p)); int column = table.convertColumnIndexToModel(table.columnAtPoint(p)); if (row >= 0 && column >= 0) { mouseDblClicked(row, column); } } } }); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { if (KeyEvent.VK_DELETE == arg0.getKeyCode()) { if (mode != 2) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread t = new Thread(new Runnable() { @Override public void run() { try { deleteSelectedFiles(); } catch (IOException e) { JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.", "Deletion error", JOptionPane.ERROR_MESSAGE); WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } finally { parentFrame.setLock(false); refresh(); parentFrame.getProgressBarPanel().setVisible(false); } } }); t.start(); } else { if (UserProfile.CURRENT_USER.getLevel() == 3) { parentFrame.setLock(true); parentFrame.getProgressBarPanel().setVisible(true); Thread delThread = new Thread(new Runnable() { @Override public void run() { int[] rows = table.getSelectedRows(); int[] columns = table.getSelectedColumns(); for (int i = 0; i < rows.length; i++) { if (!continueAction) { continueAction = true; return; } int row = table.convertRowIndexToModel(rows[i]); try { deleteServerFile(row); } catch (Exception e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e); } } refresh(); parentFrame.setLock(false); parentFrame.getProgressBarPanel().setVisible(false); } }); delThread.start(); } } } } @Override public void keyPressed(KeyEvent arg0) { // TODO Auto-generated method stub } }); table.getSelectionModel().addListSelectionListener(listSelectionListener); JScrollPane tableScroll = new JScrollPane(table); Dimension d = tableScroll.getPreferredSize(); tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2)); detailView.add(tableScroll, BorderLayout.CENTER); // the File tree DefaultMutableTreeNode root = new DefaultMutableTreeNode(); treeModel = new DefaultTreeModel(root); table.getRowSorter().addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { ((FileTableModel) table.getModel()).fireTableDataChanged(); } }); // show the file system roots. File[] roots = fileSystemView.getRoots(); for (File fileSystemRoot : roots) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot); root.add(node); //showChildren(node); // File[] files = fileSystemView.getFiles(fileSystemRoot, true); for (File file : files) { if (file.isDirectory()) { node.add(new DefaultMutableTreeNode(file)); } } // } JScrollPane treeScroll = new JScrollPane(); Dimension preferredSize = treeScroll.getPreferredSize(); Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight()); treeScroll.setPreferredSize(widePreferred); JPanel fileView = new JPanel(new BorderLayout(3, 3)); detailView.add(fileView, BorderLayout.SOUTH); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView); JPanel simpleOutput = new JPanel(new BorderLayout(3, 3)); progressBar = new JProgressBar(); simpleOutput.add(progressBar, BorderLayout.EAST); progressBar.setVisible(false); showChildren(getCurrentDir().toPath()); //table.setDragEnabled(true); table.setColumnSelectionAllowed(false); // Menu popup Pmenu = new JPopupMenu(); changeProjectitem = new JMenuItem("Reassign"); renameProjectitem = new JMenuItem("Rename"); twitem = new JMenuItem("To workspace"); tlitem = new JMenuItem("To local"); processitem = new JMenuItem("Select for process"); switch (mode) { case 0: Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnlocalTowork().doClick(); } }); break; case 1: Pmenu.add(tlitem); Pmenu.add(processitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtnWorkTolocal().doClick(); } }); processitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { SwingUtilities.invokeLater(new Runnable() { public void run() { // Recupere les lignes selectionnees int[] indices = table.getSelectedRows(); // On recupere les fichiers correspondants ArrayList<File> files = new ArrayList<File>(); for (int i = 0; i < indices.length; i++) { int row = table.convertRowIndexToModel(indices[i]); File fi = ((FileTableModel) table.getModel()).getFile(row); if (fi.isDirectory()) files.add(fi); } ImageProcessingFrame imf = new ImageProcessingFrame(files); } }); } }); break; case 2: if (UserProfile.CURRENT_USER.getLevel() == 3) { Pmenu.add(changeProjectitem); Pmenu.add(renameProjectitem); } Pmenu.add(twitem); twitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToWorkspace().doClick(); } }); Pmenu.add(tlitem); tlitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { parentFrame.getBtndistToLocal().doClick(); } }); break; } changeProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas, (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150); reas.setPopupWindow(popup); popup.show(); table.setEnabled(true); } }); renameProjectitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { table.setEnabled(false); final File from = ((FileTableModel) table.getModel()) .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0])); JDialog.setDefaultLookAndFeelDecorated(true); String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?", "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName()); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { ProjectDAO pdao = new MySQLProjectDAO(); if (new File(from.getParent() + File.separator + s).exists()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (A file with this filename already exists)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + "). [Duplication error]"); } else { try { boolean succeed = pdao.renameProject(from.getName(), s); if (!succeed) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (no project with this name)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); } else { from.renameTo(new File(from.getParent() + File.separator + s)); // on renomme le repertoire nifti ou dicom correspondant si il existe switch (from.getParentFile().getName()) { case ServerInfo.NRI_ANALYSE_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)), Paths.get(from.getParent().replaceAll( ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME) + File.separator + s)); } catch (IOException e) { e.printStackTrace(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s)); break; case ServerInfo.NRI_DICOM_NAME: if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)).exists()) try { Files.move(Paths.get(from.getAbsolutePath().replaceAll( ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)), Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME) + File.separator + s)); } catch (IOException e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Couldn't rename " + from.getName() + " (error with file system)", "Renaming error", JOptionPane.ERROR_MESSAGE); } }); e.printStackTrace(); WindowManager.mwLogger.log(Level.SEVERE, "Error during file project renaming (" + from.getName() + ")", e); } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s)); break; } refresh(); } } catch (final SQLException e) { WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog.setDefaultLookAndFeelDecorated(true); JOptionPane.showMessageDialog(WindowManager.MAINWINDOW, "Exception : " + e.toString(), "Openning error", JOptionPane.ERROR_MESSAGE); } }); } } } table.setEnabled(true); } }); table.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent me) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent me) { if (me.getButton() == 3 && table.getSelectedRowCount() > 0) { int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint())); changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row))); renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row))); Pmenu.show(me.getComponent(), me.getX(), me.getY()); } } }); // //} return tableScroll; }
From source file:uk.nhs.cfh.dsp.yasb.expression.builder.RefinedExpressionBuilderPanel.java
/** * Inits the components.// ww w. j a va2 s . c om */ public synchronized void initComponents() { // generate and store concept corresponding to Side |182353008| if (terminologyConceptDAO != null) { lateralityParentConcept = TerminologyConceptUtils.getConceptForID(terminologyConceptDAO, "182353008"); } // add a collapsible panel in NORTH position with a concept search panel searchPanel = new SearchPanel(terminologySearchService, selectionService, applicationService, terminologyConceptDAO); searchPanel.initComponents(); searchPanel.setPreferredSize(new Dimension(350, 450)); collapsiblePane = new JXCollapsiblePane(new BorderLayout()); collapsiblePane.add(searchPanel, BorderLayout.CENTER); collapsiblePane.setCollapsed(true); // create panel for rendering label renderingLabel = new ExpressionRenderingLabel(humanReadableRender); renderingLabel.initComponents(); focusConceptPanel = new ConceptPanel(humanReadableRender); focusConceptPanel.initComponents(); // create top panel with some instructions JPanel p1 = new JPanel(); p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS)); p1.add(focusConceptPanel); // add button for editing focus concept JideButton editFocusConceptButton = new JideButton(new AbstractAction("Edit") { public void actionPerformed(ActionEvent e) { if (collapsiblePane.isCollapsed()) { collapsiblePane.setCollapsed(false); } else { collapsiblePane.setCollapsed(true); } } }); p1.add(Box.createHorizontalGlue()); p1.add(editFocusConceptButton); JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.PAGE_AXIS)); topPanel.add(renderingLabel); topPanel.add(p1); // create scrollPane that contains the properties propertyExpressionListModel = new PropertyExpressionListModel(normalFormGenerator); propertiesList = new JXList(propertyExpressionListModel); // propertiesList.setCellRenderer(new PropertyExpressionListCellRenderer(selectionService, // terminologyConceptDAO, applicationService, humanReadableRender)); propertiesList.setCellRenderer(new ExpressionListCellRenderer(selectionService, terminologyConceptDAO, applicationService, humanReadableRender)); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesList); // // add mouse listeners to tree // propertiesList.addMouseListener(new MouseAdapter() { // // @Override // public void mouseClicked(MouseEvent e) { // int row = propertiesList.getSelectedIndex(); // if(row > -1 && e.getClickCount() == 2) // { // // get selection // Object selection = propertiesList.getSelectedValue(); // // // evaluate selection and set behaviour // if(selection instanceof SnomedRelationshipPropertyExpression) // { // SnomedRelationshipPropertyExpression propertyExpression = // (SnomedRelationshipPropertyExpression) selection; // // get contained relationship // SnomedRelationship relationship = propertyExpression.getRelationship(); // if(relationship != null) // { // // set as selected propertyExpression // selectedPropertyExpression = propertyExpression; // // set as active relationship // activeRelationship = relationship; // } // } // } // } // }); // create laterality hierarchy panel createLateralityConceptHierarchyDialog(); // add panel for adding laterality directly JPanel bottomPanel = new JPanel(new BorderLayout()); // add label and button for laterilty value lateralityLabel = new JLabel(); JButton editLateralityButton = new JButton(new AbstractAction("Edit") { public void actionPerformed(ActionEvent e) { /* get lateralityHierarchyPanel and set parent to Side |182353008| */ lateralityHierarchyPanel.setConcept(lateralityParentConcept); // show conceptHierarchyDialog conceptHierarchyDialog.setLocationRelativeTo(activeFrame); conceptHierarchyDialog.setVisible(true); } }); bottomPanel.add(new JLabel("<html><b>Laterality of concept </b></html>"), BorderLayout.WEST); bottomPanel.add(lateralityLabel, BorderLayout.CENTER); bottomPanel.add(editLateralityButton, BorderLayout.EAST); // add panels to this panel and main panel JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(topPanel, BorderLayout.NORTH); mainPanel.add(propertiesScrollPane, BorderLayout.CENTER); // add to this panel setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(borderOffset, borderOffset, borderOffset, borderOffset)); add(collapsiblePane, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); add(bottomPanel, BorderLayout.SOUTH); }
From source file:de.juwimm.cms.content.panel.PanDocuments.java
private void jbInit() throws Exception { mimeType = ""; btnDelete.setText("Datei lschen"); panBottom.setLayout(new BorderLayout()); panDocumentButtons.setLayout(panDocumentsLayout); btnAdd.setText("Datei hinzufgen"); lbLinkDescription.setText(" Linkbeschreibung "); this.setLayout(new BorderLayout()); panLinkName.setLayout(panLinkNameLayout); panDocumentsLayout.setAlignment(FlowLayout.LEFT); panDocumentButtons.setBackground(SystemColor.text); this.add(panBottom, BorderLayout.SOUTH); panBottom.add(panFileAction, BorderLayout.EAST); panFileAction.add(btnUpdate, null);// w ww . j a v a 2 s . co m panFileAction.add(btnAdd, null); panFileAction.add(btnDelete, null); panFileAction.add(btnPreview, null); panBottom.add(panLinkName, BorderLayout.NORTH); panLinkName.add(lbLinkDescription, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(txtLinkDesc, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); if (showDocumentProperties) { panLinkName.add(lbDocumentLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(txtDocumentLabel, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(lbDocumentDescription, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(txtDocumentDescription, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(lbAuthor, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(txtAuthor, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(lbCategory, new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(txtCategory, new GridBagConstraints(1, 4, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); panLinkName.add(ckbDocumentSearchable, new GridBagConstraints(0, 5, 2, 1, 1, 1, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2)); } panBottom.add(cbxDisplayTypeInline, BorderLayout.WEST); this.add(scrollPane, BorderLayout.CENTER); if (showRegionCombo) { this.add(cboRegion, BorderLayout.NORTH); } this.add(getViewSelectPan(), BorderLayout.WEST); scrollPane.getViewport().add(tblDocuments, null); scrollPane.setTransferHandler(new FileTransferHandler(this)); }
From source file:au.org.ala.delta.editor.ui.ActionSetsDialog.java
private void createUI() { setName("actionSetsDialog"); tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); conforTable = new JTable(); tabbedPane.addTab(_resources.getString("directiveTypeConfor.text"), new JScrollPane(conforTable)); intkeyTable = new JTable(); tabbedPane.addTab(_resources.getString("directiveTypeIntkey.text"), new JScrollPane(intkeyTable)); distTable = new JTable(); tabbedPane.addTab(_resources.getString("directiveTypeDist.text"), new JScrollPane(distTable)); keyTable = new JTable(); tabbedPane.addTab(_resources.getString("directiveTypeKey.text"), new JScrollPane(keyTable)); JPanel buttonPanel = new JPanel(); getContentPane().add(buttonPanel, BorderLayout.EAST); runButton = new JButton(); addButton = new JButton(); editButton = new JButton(); deleteButton = new JButton(); doneButton = new JButton(); GroupLayout gl_buttonPanel = new GroupLayout(buttonPanel); gl_buttonPanel.setHorizontalGroup(gl_buttonPanel.createParallelGroup(Alignment.LEADING) .addComponent(runButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(addButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(editButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(deleteButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(doneButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); gl_buttonPanel.setVerticalGroup(gl_buttonPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_buttonPanel.createSequentialGroup().addComponent(runButton).addComponent(addButton) .addComponent(editButton).addComponent(deleteButton).addComponent(doneButton))); buttonPanel.setLayout(gl_buttonPanel); JPanel labelPanel = new JPanel(); FlowLayout flowLayout = (FlowLayout) labelPanel.getLayout(); flowLayout.setHgap(20);/* ww w . jav a2s .c o m*/ flowLayout.setAlignment(FlowLayout.LEFT); getContentPane().add(labelPanel, BorderLayout.NORTH); JLabel actionSetLabel = new JLabel(); actionSetLabel.setName("actionSetsActionSetsLabel"); labelPanel.add(actionSetLabel); actionSetDetailsLabel = new JLabel(""); labelPanel.add(actionSetDetailsLabel); }
From source file:org.rdv.ui.ControlPanel.java
/** * Setup the UI./*from w w w .j a v a2 s. c o m*/ */ private void initPanel() { setLayout(new BorderLayout()); GridBagConstraints c = new GridBagConstraints(); JPanel container = new JPanel(); container.setLayout(new GridBagLayout()); Box firstRowPanel = new Box(BoxLayout.LINE_AXIS); beginButton = new JButton(); beginButton.setName("beginButton"); beginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLocationBegin(); } }); firstRowPanel.add(beginButton); rtButton = new JButton(); rtButton.setName("rtButton"); rtButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (rtButton.isSelected()) { rbnbController.pause(); } else { rbnbController.monitor(); } } }); firstRowPanel.add(rtButton); playButton = new JButton(); playButton.setName("playButton"); playButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (playButton.isSelected()) { rbnbController.pause(); } else { rbnbController.play(); } } }); firstRowPanel.add(playButton); endButton = new JButton(); endButton.setName("endButton"); endButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLocationEnd(); } }); firstRowPanel.add(endButton); firstRowPanel.add(Box.createHorizontalStrut(8)); SpinnerListModel playbackRateModel = new SpinnerListModel(playbackRates); playbackRateSpinner = new JSpinner(playbackRateModel); playbackRateSpinner.setName("playbackRateSpinner"); JSpinner.ListEditor playbackRateEditor = new JSpinner.ListEditor(playbackRateSpinner); playbackRateEditor.getTextField().setEditable(false); playbackRateSpinner.setEditor(playbackRateEditor); playbackRateSpinner.setPreferredSize(new Dimension(80, playbackRateSpinner.getPreferredSize().height)); playbackRateSpinner.setMinimumSize(playbackRateSpinner.getPreferredSize()); playbackRateSpinner.setMaximumSize(playbackRateSpinner.getPreferredSize()); playbackRateSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { playbackRateChanged(); } }); firstRowPanel.add(playbackRateSpinner); firstRowPanel.add(Box.createHorizontalStrut(8)); timeScaleComboBox = new JComboBox(); timeScaleComboBox.setName("timeScaleComboBox"); timeScaleComboBox.setEditable(true); timeScaleComboBox.setPreferredSize(new Dimension(96, timeScaleComboBox.getPreferredSize().height)); timeScaleComboBox.setMinimumSize(timeScaleComboBox.getPreferredSize()); timeScaleComboBox.setMaximumSize(timeScaleComboBox.getPreferredSize()); for (int i = 0; i < timeScales.length; i++) { timeScaleComboBox.addItem(DataViewer.formatSeconds(timeScales[i])); } timeScaleComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { timeScaleChange(); } }); firstRowPanel.add(timeScaleComboBox); firstRowPanel.add(Box.createHorizontalGlue()); locationButton = new JButton(); locationButton.setName("locationButton"); locationButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { TimeRange timeRange = RBNBHelper.getChannelsTimeRange(); double time = DateTimeDialog.showDialog(ControlPanel.this, rbnbController.getLocation(), timeRange.start, timeRange.end); if (time >= 0) { rbnbController.setLocation(time); } } }); firstRowPanel.add(locationButton); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 8, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(firstRowPanel, c); zoomTimeSlider = new TimeSlider(); zoomTimeSlider.setRangeChangeable(false); zoomTimeSlider.addTimeAdjustmentListener(this); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(0, 8, 0, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(zoomTimeSlider, c); JPanel zoomTimePanel = new JPanel(); zoomTimePanel.setLayout(new BorderLayout()); zoomMinimumLabel = new JLabel(); zoomMinimumLabel.setName("zoomMinimumLabel"); zoomTimePanel.add(zoomMinimumLabel, BorderLayout.WEST); zoomRangeLabel = new JLabel(); zoomRangeLabel.setName("zoomRangeLabel"); zoomRangeLabel.setHorizontalAlignment(JLabel.CENTER); zoomTimePanel.add(zoomRangeLabel, BorderLayout.CENTER); zoomMaximumLabel = new JLabel(); zoomMaximumLabel.setName("zoomMaximumLabel"); zoomTimePanel.add(zoomMaximumLabel, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 0, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(zoomTimePanel, c); globalTimeSlider = new TimeSlider(); globalTimeSlider.setValueChangeable(false); globalTimeSlider.addTimeAdjustmentListener(this); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 1; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 8, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(globalTimeSlider, c); add(container, BorderLayout.CENTER); log.info("Initialized control panel."); }
From source file:PolygonOffset.java
public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); JPanel canvasPanel = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); canvasPanel.setLayout(gridbag);//from ww w . jav a2 s.c o m canvas = new Canvas3D(config); canvas.setSize(600, 600); add(canvas, BorderLayout.CENTER); u = new SimpleUniverse(canvas); if (isApplication) { offScreenCanvas = new OffScreenCanvas3D(config, true); // set the size of the off-screen canvas based on a scale // of the on-screen size Screen3D sOn = canvas.getScreen3D(); Screen3D sOff = offScreenCanvas.getScreen3D(); Dimension dim = sOn.getSize(); dim.width *= offScreenScale; dim.height *= offScreenScale; sOff.setSize(dim); sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() * offScreenScale); sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() * offScreenScale); // attach the offscreen canvas to the view u.getViewer().getView().addCanvas3D(offScreenCanvas); } // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); // set the eye at z = 2.0 viewingPlatform = u.getViewingPlatform(); Transform3D vpTrans = new Transform3D(); vpTrans.set(new Vector3f(0.0f, 0.0f, 2.0f)); viewingPlatform.getViewPlatformTransform().setTransform(vpTrans); // set up a parallel projection with clip limits at 1 and -1 view = u.getViewer().getView(); view.setProjectionPolicy(View.PARALLEL_PROJECTION); view.setFrontClipPolicy(View.VIRTUAL_EYE); view.setBackClipPolicy(View.VIRTUAL_EYE); view.setFrontClipDistance(1.0f); view.setBackClipDistance(3.0f); u.addBranchGraph(scene); // set up the sliders JPanel guiPanel = new JPanel(); guiPanel.setLayout(new GridLayout(0, 1)); FloatLabelJSlider dynamicSlider = new FloatLabelJSlider("Dynamic Offset", 0.1f, 0.0f, 2.0f, dynamicOffset); dynamicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { dynamicOffset = e.getValue(); solidPa.setPolygonOffsetFactor(dynamicOffset); } }); guiPanel.add(dynamicSlider); LogFloatLabelJSlider staticSlider = new LogFloatLabelJSlider("Static Offset", 0.1f, 10000.0f, staticOffset); staticSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { staticOffset = e.getValue(); solidPa.setPolygonOffset(staticOffset); } }); guiPanel.add(staticSlider); FloatLabelJSlider innerSphereSlider = new FloatLabelJSlider("Inner Sphere Scale", 0.001f, 0.90f, 1.0f, innerScale); innerSphereSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { innerScale = e.getValue(); updateInnerScale(); } }); guiPanel.add(innerSphereSlider); if (isApplication) { JButton snapButton = new JButton("Snap Image"); snapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Point loc = canvas.getLocationOnScreen(); offScreenCanvas.setOffScreenLocation(loc); Dimension dim = canvas.getSize(); dim.width *= offScreenScale; dim.height *= offScreenScale; nf.setMinimumIntegerDigits(3); offScreenCanvas.snapImageFile(outFileBase + nf.format(outFileSeq++), dim.width, dim.height); nf.setMinimumIntegerDigits(0); } }); guiPanel.add(snapButton); } add(guiPanel, BorderLayout.EAST); }
From source file:LayeredPaneDemo.java
protected void attachEastResizeEdge() { m_eastResizer = new EastResizeEdge(this); super.add(m_eastResizer, BorderLayout.EAST); }
From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private final JPanel buildProjectPanel() { JPanel projectPanel = new JPanel(new BorderLayout()); projectPanel.setBorder(new TitledBorder("Projects")); // --- left-side ------------------------------------------------- JPanel sidePanel = new JPanel(new BorderLayout()); sidePanel.setPreferredSize(new Dimension(WINDOW_WIDTH / 3, SIZE_IGNORED)); projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); projectList.addListSelectionListener(new ProjectListSelectionListener()); sidePanel.add(new JScrollPane(projectList), BorderLayout.CENTER); projectPanel.add(sidePanel, BorderLayout.WEST); // --- right-side ------------------------------------------------ sidePanel = new JPanel(new BorderLayout()); sidePanel.setPreferredSize(new Dimension(310, SIZE_IGNORED)); JPanel rsTopPanel = new JPanel(new BorderLayout()); rsTopPanel.setPreferredSize(new Dimension(SIZE_IGNORED, 50)); JPanel labelPanel = new JPanel(new GridLayout(2, 1, 0, 5)); labelPanel.add(new JLabel("Name: ")); labelPanel.add(new JLabel("Description: ")); JPanel infoPanel = new JPanel(new GridLayout(2, 1, 0, 5)); infoPanel.add(projectName);/*from www .j a v a 2 s . c om*/ projectName.setEditable(false); infoPanel.add(projectDescription); projectDescription.setEditable(false); rsTopPanel.add(labelPanel, BorderLayout.WEST); rsTopPanel.add(infoPanel, BorderLayout.CENTER); sidePanel.add(rsTopPanel, BorderLayout.NORTH); projectPanel.add(sidePanel, BorderLayout.EAST); return projectPanel; }
From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttributeDialog.java
private void init() { thisDialog = this; setBounds(100, 100, 820, 335);/*from w w w .j a v a 2s . co m*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { JLabel lblAttributeType = new JLabel("Attribute Type"); panel.add(lblAttributeType, "2, 2, right, default"); } { comboBoxType = new JComboBox(); comboBoxType.setModel(new DefaultComboBoxModel( new String[] { "caste", "scientific name", "sex", "life stage", "part association" })); comboBoxType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String item = comboBoxType.getSelectedItem().toString(); if (item != null) { comboBoxValue.setEditable(false); if (item.equals("scientific name")) { comboBoxValue.setEditable(true); } if (item.equals("sex")) { comboBoxValue.setModel(new DefaultComboBoxModel(Sex.getSexValues())); } if (item.equals("life stage")) { comboBoxValue.setModel(new DefaultComboBoxModel(LifeStage.getLifeStageValues())); } if (item.equals("caste")) { comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); } if (item.equals("part association")) { comboBoxValue .setModel(new DefaultComboBoxModel(PartAssociation.getPartAssociationValues())); } } } }); panel.add(comboBoxType, "4, 2, fill, default"); } { JLabel lblValue = new JLabel("Value"); panel.add(lblValue, "2, 4, right, default"); } { comboBoxValue = new JComboBox(); comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); panel.add(comboBoxValue, "4, 4, fill, default"); } { JLabel lblUnits = new JLabel("Units"); panel.add(lblUnits, "2, 6, right, default"); } { textFieldUnits = new JTextField(); panel.add(textFieldUnits, "4, 6, fill, default"); textFieldUnits.setColumns(10); } { JLabel lblRemarks = new JLabel("Remarks"); panel.add(lblRemarks, "2, 8, right, default"); } contentPanel.setLayout(new BorderLayout(0, 0)); contentPanel.add(panel, BorderLayout.WEST); { textFieldRemarks = new JTextField(); panel.add(textFieldRemarks, "4, 8, fill, default"); textFieldRemarks.setColumns(10); } { JButton btnAdd = new JButton("Add"); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); newAttribs.setAttributeType(comboBoxType.getSelectedItem().toString()); newAttribs.setAttributeValue(comboBoxValue.getSelectedItem().toString()); newAttribs.setAttributeUnits(textFieldUnits.getText()); newAttribs.setAttributeRemark(textFieldRemarks.getText()); newAttribs.setSpecimenPartId(parentPart); newAttribs.setAttributeDeterminer(Singleton.getSingletonInstance().getUserFullName()); parentPart.getAttributeCollection().add(newAttribs); SpecimenPartAttributeLifeCycle sls = new SpecimenPartAttributeLifeCycle(); try { sls.attachDirty(newAttribs); } catch (SaveFailedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ((AbstractTableModel) table.getModel()).fireTableDataChanged(); } }); panel.add(btnAdd, "4, 10"); } try { JLabel lblNewLabel = new JLabel(parentPart.getSpecimenId().getBarcode() + ":" + parentPart.getPartName() + " " + parentPart.getPreserveMethod() + " (" + parentPart.getLotCount() + ") Right click on table to edit attributes."); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } catch (Exception e) { JLabel lblNewLabel = new JLabel("No Specimen"); contentPanel.add(lblNewLabel, BorderLayout.NORTH); } JComboBox comboBox = new JComboBox(); comboBox.addItem("caste"); JComboBox comboBox1 = new JComboBox(); for (int i = 0; i < Caste.getCasteValues().length; i++) { comboBox1.addItem(Caste.getCasteValues()[i]); } JScrollPane scrollPane = new JScrollPane(); table = new JTable(new SpecimenPartsAttrTableModel( (Collection<SpecimenPartAttribute>) parentPart.getAttributeCollection())); //table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(comboBox)); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); popupMenu = new JPopupMenu(); JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); mntmCloneRow.setMnemonic(KeyEvent.VK_E); mntmCloneRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // Launch a dialog to edit the selected row. SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( ((SpecimenPartsAttrTableModel) table.getModel()).getRowObject(clickedOnRow)); popup.setVisible(true); } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to edit a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmCloneRow); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.setMnemonic(KeyEvent.VK_D); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnRow >= 0) { ((SpecimenPartsAttrTableModel) table.getModel()).deleteRow(clickedOnRow); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisDialog, "Failed to delete a part attribute row. " + ex.getMessage()); } } }); popupMenu.add(mntmDeleteRow); // TODO: Enable controlled value editing of selected row. // table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(comboBox1)); scrollPane.setViewportView(table); contentPanel.add(scrollPane, BorderLayout.EAST); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButton.grabFocus(); thisDialog.setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { thisDialog.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:org.apache.cayenne.modeler.editor.AbstractCallbackMethodsTab.java
private void addButtonAtHeader(JTable table, JButton button, ActionListener buttonListener, ImageIcon buttonIcon) {//from ww w . j av a 2 s .c o m PanelBuilder builder = new PanelBuilder(new FormLayout("left:10dlu, 2dlu", "center:10dlu")); CellConstraints cc = new CellConstraints(); button.setIcon(buttonIcon); button.setOpaque(false); button.setBorderPainted(false); button.setContentAreaFilled(false); button.addActionListener(buttonListener); builder.add(button, cc.xy(1, 1)); JPanel buttonPanel = builder.getPanel(); buttonPanel.setOpaque(false); JTableHeader header = table.getTableHeader(); header.setLayout(new BorderLayout()); header.setReorderingAllowed(false); header.setPreferredSize(new Dimension(150, 20)); header.add(buttonPanel, BorderLayout.EAST); }