List of usage examples for javax.swing JSplitPane setResizeWeight
@BeanProperty(description = "Specifies how to distribute extra space when the split pane resizes.") public void setResizeWeight(double value)
From source file:org.monkeys.gui.matcher.MatcherPanel.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./* w ww.j ava 2 s .c o m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { javax.swing.JSplitPane splitPane = new javax.swing.JSplitPane(); textPanel = new javax.swing.JPanel(); textHeader = new org.monkeys.gui.HeaderLabel(); javax.swing.JScrollPane textScroll = new javax.swing.JScrollPane(); textArea = new javax.swing.JTextArea(); editPanel = new javax.swing.JPanel(); clearButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator2 = new javax.swing.JSeparator(); editButton = new javax.swing.JToggleButton(); matchingPanel = new javax.swing.JPanel(); org.monkeys.gui.HeaderLabel matchingHeader = new org.monkeys.gui.HeaderLabel(); matchingScroll = new javax.swing.JScrollPane(); matchingList = new org.monkeys.gui.matcher.MatcherTable(); org.monkeys.gui.HeaderLabel categoryLabel = new org.monkeys.gui.HeaderLabel(); categoryDropdown = new org.monkeys.gui.CategoryDropdown(); clipboardButton = new javax.swing.JToggleButton(); selectButton = new javax.swing.JToggleButton(); removeDuplicateButton = new javax.swing.JButton(); removeRowButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator3 = new javax.swing.JSeparator(); javax.swing.JSeparator jSeparator4 = new javax.swing.JSeparator(); javax.swing.JSeparator jSeparator5 = new javax.swing.JSeparator(); modifyButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator6 = new javax.swing.JSeparator(); undoButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator7 = new javax.swing.JSeparator(); clipboardDropdown = new javax.swing.JComboBox(); splitPane.setBorder(null); splitPane.setDividerSize(8); splitPane.setResizeWeight(0.6); textHeader.setText("Text"); textScroll.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray)); textScroll.setMinimumSize(new java.awt.Dimension(200, 50)); textScroll.setPreferredSize(new java.awt.Dimension(300, 150)); textArea.setTabSize(4); textArea.setAutoscrolls(false); textScroll.setViewportView(textArea); clearButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/clear-20.png"))); // NOI18N clearButton.setText("Clear"); clearButton.setToolTipText("Clear All Fields"); clearButton.setBorderPainted(false); clearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearButtonActionPerformed(evt); } }); jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL); editButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/lock-18.png"))); // NOI18N editButton.setSelected(true); editButton.setText("Edit"); editButton.setToolTipText("Edit Text"); editButton.setBorderPainted(false); editButton.setDisabledIcon( new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/lock-18.png"))); // NOI18N editButton.setIconTextGap(3); editButton.setSelectedIcon( new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/unlock-18.png"))); // NOI18N editButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editButtonActionPerformed(evt); } }); javax.swing.GroupLayout editPanelLayout = new javax.swing.GroupLayout(editPanel); editPanel.setLayout(editPanelLayout); editPanelLayout.setHorizontalGroup(editPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(editPanelLayout.createSequentialGroup().addComponent(editButton).addGap(0, 0, 0) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(clearButton).addGap(0, 89, Short.MAX_VALUE))); editPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { clearButton, editButton }); editPanelLayout.setVerticalGroup(editPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(editPanelLayout.createSequentialGroup().addGap(0, 0, 0) .addGroup(editPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSeparator2) .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, 0))); editPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { clearButton, editButton }); javax.swing.GroupLayout textPanelLayout = new javax.swing.GroupLayout(textPanel); textPanel.setLayout(textPanelLayout); textPanelLayout.setHorizontalGroup(textPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(textPanelLayout.createSequentialGroup() .addComponent(editPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(textPanelLayout.createSequentialGroup().addContainerGap() .addGroup(textPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(textScroll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(textHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); textPanelLayout.setVerticalGroup(textPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(textPanelLayout.createSequentialGroup().addContainerGap() .addComponent(textHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(editPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE) .addContainerGap())); splitPane.setLeftComponent(textPanel); matchingHeader.setText("Matches"); matchingScroll.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray)); matchingScroll.setMinimumSize(new java.awt.Dimension(200, 120)); matchingScroll.setPreferredSize(new java.awt.Dimension(480, 300)); matchingScroll.setViewportView(matchingList); categoryLabel.setText("Category"); clipboardButton.setIcon( new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/clipboard-16.png"))); // NOI18N clipboardButton.setToolTipText("Copy Selected To Clipboard"); clipboardButton.setBorderPainted(false); clipboardButton.setEnabled(false); clipboardButton.setIconTextGap(2); clipboardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clipboardButtonActionPerformed(evt); } }); selectButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/list-16.png"))); // NOI18N selectButton.setToolTipText("Select / Unselect All"); selectButton.setBorderPainted(false); selectButton.setEnabled(false); selectButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selectButtonActionPerformed(evt); } }); removeDuplicateButton.setIcon(new javax.swing.ImageIcon( getClass().getResource("/org/monkeys/gui/icons/remove-duplicates-16.png"))); // NOI18N removeDuplicateButton.setToolTipText("Remove Duplicates"); removeDuplicateButton.setBorderPainted(false); removeDuplicateButton.setEnabled(false); removeDuplicateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeDuplicateButtonActionPerformed(evt); } }); removeRowButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/remove-16.png"))); // NOI18N removeRowButton.setToolTipText("Remove Selected"); removeRowButton.setBorderPainted(false); removeRowButton.setEnabled(false); removeRowButton.setIconTextGap(2); removeRowButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeRowButtonActionPerformed(evt); } }); jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL); jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL); jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL); modifyButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/edit-16.png"))); // NOI18N modifyButton.setToolTipText("Edit Selected"); modifyButton.setBorderPainted(false); modifyButton.setEnabled(false); modifyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { modifyButtonActionPerformed(evt); } }); jSeparator6.setOrientation(javax.swing.SwingConstants.VERTICAL); undoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/monkeys/gui/icons/undo-16.png"))); // NOI18N undoButton.setBorderPainted(false); undoButton.setEnabled(false); undoButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { undoButtonActionPerformed(evt); } }); jSeparator7.setOrientation(javax.swing.SwingConstants.VERTICAL); clipboardDropdown.setEditable(true); clipboardDropdown.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); clipboardDropdown.setEnabled(false); javax.swing.GroupLayout matchingPanelLayout = new javax.swing.GroupLayout(matchingPanel); matchingPanel.setLayout(matchingPanelLayout); matchingPanelLayout.setHorizontalGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(matchingPanelLayout.createSequentialGroup().addContainerGap() .addGroup(matchingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(matchingPanelLayout.createSequentialGroup().addComponent(selectButton) .addGap(0, 0, 0) .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(removeDuplicateButton).addGap(0, 0, 0) .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(removeRowButton).addGap(0, 0, 0) .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(modifyButton).addGap(0, 0, 0) .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(undoButton).addGap(0, 0, 0) .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(clipboardDropdown, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(clipboardButton) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(matchingScroll, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(categoryLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(categoryDropdown, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(matchingHeader, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); matchingPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { clipboardButton, modifyButton, removeRowButton }); matchingPanelLayout.setVerticalGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(matchingPanelLayout.createSequentialGroup().addContainerGap() .addComponent(categoryLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0) .addComponent(categoryDropdown, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(matchingHeader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(matchingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(removeDuplicateButton).addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(selectButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(removeRowButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(modifyButton) .addGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(clipboardButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(matchingPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(undoButton).addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(jSeparator7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(clipboardDropdown, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(matchingScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE) .addContainerGap())); matchingPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { clipboardButton, clipboardDropdown }); splitPane.setRightComponent(matchingPanel); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 664, Short.MAX_VALUE) .addGap(0, 0, 0))); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(splitPane)); }
From source file:org.ngrinder.recorder.Recorder.java
/** * Create a split pane with the give left and right components. * //ww w . ja v a 2 s .com * @param left * component located in left * @param right * component located in right * @return JSplitPane instance */ protected JSplitPane createSplitPane(final JComponent left, final JComponent right) { JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); splitPane.setDividerLocation( splitPane.getSize().width - splitPane.getInsets().right - splitPane.getDividerSize() - 200); splitPane.setResizeWeight(1); splitPane.setMinimumSize(new Dimension(600, 600)); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); return splitPane; }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Initializes and returns a split pane, either vertical or horizontal * depending on the passed parameter./* w ww . j a va 2 s.co m*/ * * @param orientation The orientation of the split pane. * @return See above. */ private JSplitPane initSplitPane(int orientation) { int type; switch (orientation) { case JSplitPane.HORIZONTAL_SPLIT: case JSplitPane.VERTICAL_SPLIT: type = orientation; break; default: type = JSplitPane.HORIZONTAL_SPLIT; } JSplitPane pane = new JSplitPane(type); pane.setOneTouchExpandable(true); pane.setContinuousLayout(true); pane.setDividerLocation(-1); pane.setResizeWeight(0.0); return pane; }
From source file:org.optaconf.benchmark.examples.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel() { JPanel quickOpenPanel = new JPanel(new BorderLayout()); JLabel quickOpenLabel = new JLabel("Quick open"); quickOpenLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); quickOpenPanel.add(quickOpenLabel, BorderLayout.NORTH); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenUnsolvedPanel(), createQuickOpenSolvedPanel()); splitPane.setResizeWeight(0.8); splitPane.setBorder(null);/*from w ww . j a va 2 s . c om*/ quickOpenPanel.add(splitPane, BorderLayout.CENTER); return quickOpenPanel; }
From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java
private JComponent createContentPane() { // JComponent quickOpenPanel = createQuickOpenPanel(); JComponent quickOpenPanel = createQuickOpenScorePanel(); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(createToolBar(), BorderLayout.NORTH); mainPanel.add(createMiddlePanel(), BorderLayout.CENTER); mainPanel.add(createScorePanel(), BorderLayout.SOUTH); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, quickOpenPanel, mainPanel); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.2); return splitPane; }
From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java
@SuppressWarnings("unused") private JComponent createQuickOpenPanel() { JPanel quickOpenPanel = new JPanel(new BorderLayout()); quickOpenPanel.add(new JLabel("Quick open"), BorderLayout.NORTH); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenUnsolvedPanel(), createQuickOpenSolvedPanel()); splitPane.setResizeWeight(0.8); splitPane.setBorder(null);/* w w w.jav a2 s . c o m*/ quickOpenPanel.add(splitPane, BorderLayout.CENTER); return quickOpenPanel; }
From source file:org.optaplanner.mes.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenScorePanel() { createQuickOpenUnsolvedPanel();//from w w w . java 2 s. c o m JPanel panel = new JPanel(new BorderLayout()); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createQuickOpenSolvedPanel(), createScoreFieldPanel()); splitPane.setResizeWeight(0.8); splitPane.setBorder(null); panel.add(splitPane, BorderLayout.CENTER); return panel; }
From source file:org.pentaho.ui.xul.swing.SwingElement.java
public void layout() { super.layout(); double totalFlex = 0.0; if (isVisible() == false) { resetContainer();/*from ww w . j a v a 2 s. c o m*/ return; } for (Element comp : getChildNodes()) { // if (comp.getManagedObject() == null) { // continue; // } if (((XulComponent) comp).getFlex() > 0) { flexLayout = true; totalFlex += ((XulComponent) comp).getFlex(); } } double currentFlexTotal = 0.0; Align alignment = (getAlign() != null) ? Align.valueOf(this.getAlign().toUpperCase()) : null; for (int i = 0; i < getChildNodes().size(); i++) { XulComponent comp = (XulComponent) getChildNodes().get(i); gc.fill = GridBagConstraints.BOTH; if (comp instanceof XulSplitter) { JPanel prevContainer = container; container = new ScrollablePanel(new GridBagLayout()); container.setOpaque(false); final JSplitPane splitter = new JSplitPane( (this.getOrientation() == Orient.VERTICAL) ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT, prevContainer, container); splitter.setContinuousLayout(true); final double splitterSize = currentFlexTotal / totalFlex; splitter.setResizeWeight(splitterSize); if (totalFlex > 0) { splitter.addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent arg0) { } public void componentMoved(ComponentEvent arg0) { } public void componentShown(ComponentEvent arg0) { } public void componentResized(ComponentEvent arg0) { splitter.setDividerLocation(splitterSize); splitter.removeComponentListener(this); } }); } if (!flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } prevContainer.add(Box.createGlue(), gc); } setManagedObject(splitter); } Object maybeComponent = comp.getManagedObject(); if (maybeComponent == null || !(maybeComponent instanceof Component)) { continue; } if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.gridheight = comp.getFlex() + 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.weighty = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } else { gc.gridwidth = comp.getFlex() + 1; gc.gridheight = GridBagConstraints.REMAINDER; gc.weightx = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } currentFlexTotal += comp.getFlex(); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.WEST; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.EAST; break; } } } else { if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.NORTH; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.SOUTH; break; } } } Component component = (Component) maybeComponent; if (comp.getWidth() > 0 || comp.getHeight() > 0) { Dimension minSize = component.getMinimumSize(); Dimension prefSize = component.getPreferredSize(); if (comp.getWidth() > 0) { minSize.width = comp.getWidth(); prefSize.width = comp.getWidth(); } if (comp.getHeight() > 0) { minSize.height = comp.getHeight(); prefSize.height = comp.getHeight(); } component.setMinimumSize(minSize); component.setPreferredSize(prefSize); } container.add(component, gc); if (i + 1 == getChildNodes().size() && !flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } container.add(Box.createGlue(), gc); } } }
From source file:org.roche.antibody.ui.components.AntibodyEditorPane.java
/** * initates swing component/*from w w w . j a v a 2 s. com*/ */ private void initComponents() { abstractGraphLayouter = AbstractGraphLayoutService.createLayouter(); this.abstractAntibodyView = new Graph2DView(); this.abstractAntibodyView.setFitContentOnResize(true); editMode = new AntibodyEditMode(this); abstractAntibodyView.addViewMode(editMode); // enable bridges for PolyLineEdgeRealizer BridgeCalculator bridgeCalculator = new BridgeCalculator(); bridgeCalculator.setCrossingMode(BridgeCalculator.CROSSING_MODE_HORIZONTAL_CROSSES_VERTICAL); ((DefaultGraph2DRenderer) abstractAntibodyView.getGraph2DRenderer()).setBridgeCalculator(bridgeCalculator); configureKeyboardActions(); this.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { super.componentShown(e); LOG.debug("Call componentShown of: {}", this.getClass().getName()); updateGraphLayout(); } }); this.setLayout(new BorderLayout()); // --- START Graphical Representation of Antybody (Center Panel) JSplitPane pnlSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); pnlSplit.setOneTouchExpandable(true); this.add(pnlSplit, BorderLayout.CENTER); pnlSplit.setLeftComponent(abstractAntibodyView); pnlSplit.setResizeWeight(1); // --- START Property Table, HELM Notation etc. (Right Panel) pnlEast = new JSplitPane(JSplitPane.VERTICAL_SPLIT); pnlEast.setBorder(DEFAULT_BORDER); pnlEast.setResizeWeight(0.65); antibodyPropertyModel = new DomainTableModel(); antibodyPropertyModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { abstractGraph.updateViews(); } }); propertyTable = new JTable(antibodyPropertyModel); propertyTable.setDefaultRenderer(Object.class, new DomainTableCellRenderer()); JScrollPane spnlPropertyTable = new JScrollPane(propertyTable); pnlEast.setTopComponent(spnlPropertyTable); pnlSplit.setRightComponent(pnlEast); // graphical preview graphicsPane = new JPanel(new BorderLayout()); anotherView = new Graph2DView(); graphicsPane.add(anotherView, BorderLayout.CENTER); // Tabcontainer for graphic and helm notation preview tabbedPane = new JTabbedPane(JTabbedPane.TOP); // --- HELM notation Preview Panel helmPreviewPane = new JPanel(); helmPreviewPane.setLayout(new BorderLayout()); tabbedPane.addTab("HELM Notation Preview", null, helmPreviewPane, null); // --- Button Panel for HELM notation preview JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); cmdSaveAsXml = new JButton("Save Antibody", new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.DISK_IMAGE))); cmdSaveAsXml.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { XmlFileChooser dialog = new XmlFileChooser(); if (dialog.showSaveDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) { File abFile = dialog.getSelectedFile(); String newPath = FilenameUtils.removeExtension(abFile.getAbsolutePath()); abFile = new File(newPath + AntibodyFileChooser.XML_EXTENSION); AntibodyContainer abContainer = new AntibodyContainer(); try { antibody.setDomainLibraryPath(ConfigFileService.getInstance().getDomainLibFilename()); // PreferencesService.getInstance().getDomainLibraryFile().getAbsolutePath()); abContainer.setAntibody(antibody); abContainer.setHelmCode(helmTextArea.getText()); xmlService.marshal(abContainer, abFile); } catch (JAXBException e1) { JOptionPane.showMessageDialog(mainEditor.getFrame(), "Could not save Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE); LOG.error("Could not save Antibody-XML to disk! {}", e1); } } } }); pnlButtons.add(cmdSaveAsXml); cmdLoadFromXml = new JButton("Load Antibody", new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.OPEN_FOLDER))); cmdLoadFromXml.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { XmlFileChooser dialog = new XmlFileChooser(); if (dialog.showOpenDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) { File abFile = dialog.getSelectedFile(); try { AntibodyContainer newAbContainer = xmlService.unmarshal(abFile); setModel(newAbContainer.getAntibody()); } catch (JAXBException e1) { JOptionPane.showMessageDialog(mainEditor.getFrame(), "Could not load Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE); LOG.error("Could not load Antibody-XML to disk! {}", e1); } } } }); pnlButtons.add(cmdLoadFromXml); helmPreviewPane.add(pnlButtons, BorderLayout.SOUTH); pnlEast.setBottomComponent(tabbedPane); // --- HELM Notation Text Area helmTextArea = new JTextArea(); helmTextArea.setLineWrap(true); JScrollPane spnlHELMTextArea = new JScrollPane(helmTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); helmPreviewPane.add(spnlHELMTextArea, BorderLayout.CENTER); }
From source file:org.sintef.thingml.ThingMLFrame.java
public ThingMLFrame(String args[]) { int i = 0;/* w ww. ja va2 s .com*/ for (String s : args) { if (i > 0) { argsFlat += "="; } argsFlat += s; } if (argsFlat.contains("-open=")) { File filePath = new File(argsFlat.substring(argsFlat.indexOf("=") + 1)); filePanel = new FilePanel(editor, this, filePath.getParentFile()); String content = ""; try { final InputStream input = new FileInputStream(filePath); final java.util.List<String> packLines = IOUtils.readLines(input); for (String line : packLines) { content += line + "\n"; } input.close(); } catch (Exception ex) { ex.printStackTrace(); } editor.loadText(content, null); } else { filePanel = new FilePanel(editor, this, null); } setTitle("ThingML Editor"); this.setLayout(new BorderLayout()); filePanel.setPreferredSize(new Dimension(300, 300)); filePanel.setSize(300, 300); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, filePanel, editor); splitPane.setContinuousLayout(true); splitPane.setDividerSize(6); splitPane.setDividerLocation(200); splitPane.setResizeWeight(0.0); splitPane.setBorder(null); add(splitPane, BorderLayout.CENTER); }