List of usage examples for javax.swing JScrollPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.kepler.gui.ResultTreeRebuilder.java
/** * this method allows the search results to be updated in the panel * //from ww w . j av a2 s.c o m *@param results * the results to update to *@exception IllegalActionException * Description of the Exception */ public void update(LibrarySearchResults results) throws IllegalActionException { if (isDebugging) { log.debug("update(" + results + ")"); } this.results = results; int resultcount; if (results == null || results.size() == 0) { resultcount = 0; } else { resultcount = results.size(); } this.removeAll(); // add the results if there are any if (resultcount > 0) { // add the results tree. EntityLibrary newRoot = new SearchEntityLibrary(workspace); try { newRoot.setName(StaticResources.getDisplayString("components.searchResults", "Search Results")); } catch (IllegalActionException iae) { throw iae; } catch (NameDuplicationException nde) { throw new IllegalActionException("name duplication exception: " + nde); } buildResultTree(newRoot); trimmedLibrary = new VisibleTreeModel(newRoot); AnnotatedPTree rTree = new AnnotatedPTree(trimmedLibrary, this); MouseListener mListener = new LibraryPopupListener(rTree); rTree.setMouseListener(mListener); if (treeSingleSelectionlistener != null) { rTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); rTree.addTreeSelectionListener(treeSingleSelectionlistener); } rTree.initAnotatedPTree(); resultsTree = rTree; rTree.setShowsRootHandles(false); JScrollPane newpane = new JScrollPane(resultsTree); newpane.setPreferredSize(new Dimension(200, 200)); this.add(newpane, BorderLayout.CENTER); expandAll(resultsTree); } else { // if there are no results, just add the library back if (library.getModel() != null) { library.setModel(new NoRemoteComponentsTreeModel(library.getModel())); } this.add(new JScrollPane(library), BorderLayout.CENTER); } // add the search results counter stuff resultCounterPane = new JPanel(); resultCounterPane.setBackground(TabManager.BGCOLOR); resultCounterPane.setLayout(new BorderLayout()); resultCounterLabel = new JLabel( resultcount + " " + StaticResources.getDisplayString("components.resultsFound", "results found.")); resultCounterPane.removeAll(); resultCounterPane.add(resultCounterLabel, BorderLayout.CENTER); this.add(resultCounterPane, BorderLayout.SOUTH); this.repaint(); this.validate(); }
From source file:org.kepler.gui.WorkflowOutlinePanel.java
public void refreshOutlineTree() { if (isDebugging) { log.debug("refreshOutlineTree()"); }/*from ww w. j ava2 s . c o m*/ this.removeAll(); _ptree = new AnnotatedPTree(wotm, this); _mouseListener = new OutlinePopupListener(_ptree); _ptree.setMouseListener(_mouseListener); _ptree.setRootVisible(false); _ptree.initAnotatedPTree(); JScrollPane jSP = new JScrollPane(_ptree, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jSP.setPreferredSize(new Dimension(200, 200)); this.add(jSP, BorderLayout.CENTER); setControls(); this.repaint(); this.validate(); // if panel was showing the results of a search, redo the search if (_searchTerm != null && !_searchTerm.isEmpty()) { search(_searchTerm); } }
From source file:org.knime.ext.textprocessing.nodes.view.documentviewer2.DocumentPanel2.java
/** * Creates new instance of {@code DocumentPanel} with given document view model to show, and the preferred width and * height to set./*from ww w . j a v a 2s . c om*/ * * @param docViewModel The document view model. * @param preferredWidth The preferred width to set. * @param preferredHeight The preferred height to set. */ public DocumentPanel2(final DocumentViewModel docViewModel, final int preferredWidth, final int preferredHeight) { super(new BorderLayout()); if (docViewModel == null) { throw new IllegalArgumentException("Document view model may not be null!"); } m_docViewModel = docViewModel; m_fulltextPane = new JEditorPane(); m_fulltextPane.setContentType("text/html"); m_fulltextPane.setEditable(false); m_fulltextPane.setCaretPosition(0); m_fulltextPane.addHyperlinkListener(new LinkListener()); m_fulltextPane.setToolTipText("Select text and right click."); HTMLEditorKit editorKit = new HTMLEditorKit(); // Adding stylesheet to the document StyleSheet sheet = editorKit.getStyleSheet(); sheet.addRule( "html, body {margin: 0; padding: 4px; color: #000000; font-family: 'Roboto', sans-serif; background: #ffffff; font-size: 12px;}"); sheet.addRule("table { border-collapse: collapse; }"); sheet.addRule("th, td { border: 1px solid #000000; padding: 10px 15px; }"); sheet.addRule( ".docHeading {display: block; font-size: 15px; font-weight: bold; margin: 5px 0 30px 0; width: 100%;}"); sheet.addRule( ".sep { width:100%; border-bottom: 1px dashed #8c8b8b ; top: 10%; bottom: 20%; position: absolute; margin: 10px 0 10px 0;}"); sheet.addRule(".subHeading { font-weight: 500; font-style: italic; text-transform: lowercase; }"); editorKit.setStyleSheet(sheet); m_fulltextPane.setEditorKit(editorKit); Document doc = editorKit.createDefaultDocument(); m_fulltextPane.setDocument(doc); m_fulltextPane.setText(getPreparedText()); m_rightClickMenue = new JPopupMenu(); JMenuItem item; for (String source : SearchEngines.getInstance().getSearchEngineNames()) { item = new JMenuItem(source); item.addActionListener(new RightClickMenueListener()); m_rightClickMenue.add(item); } m_fulltextPane.setComponentPopupMenu(m_rightClickMenue); JScrollPane jsp = new JScrollPane(m_fulltextPane); jsp.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); add(jsp, BorderLayout.CENTER); }
From source file:org.languagetool.gui.Tools.java
static void showRuleInfoDialog(Component parent, String title, String message, Rule rule, URL matchUrl, ResourceBundle messages, String lang) { int dialogWidth = 320; JTextPane textPane = new JTextPane(); textPane.setEditable(false);// ww w .j av a 2s .c o m textPane.setContentType("text/html"); textPane.setBorder(BorderFactory.createEmptyBorder()); textPane.setOpaque(false); textPane.setBackground(new Color(0, 0, 0, 0)); Tools.addHyperlinkListener(textPane); textPane.setSize(dialogWidth, Short.MAX_VALUE); String messageWithBold = message.replaceAll("<suggestion>", "<b>").replaceAll("</suggestion>", "</b>"); String exampleSentences = getExampleSentences(rule, messages); String url = "http://community.languagetool.org/rule/show/" + encodeUrl(rule) + "?lang=" + lang + "&ref=standalone-gui"; boolean isExternal = rule.getCategory().getLocation() == Category.Location.EXTERNAL; String ruleDetailLink = rule instanceof FalseFriendPatternRule || isExternal ? "" : "<a href='" + url + "'>" + messages.getString("ruleDetailsLink") + "</a>"; textPane.setText("<html>" + messageWithBold + exampleSentences + formatURL(matchUrl) + "<br><br>" + ruleDetailLink + "</html>"); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(dialogWidth, textPane.getPreferredSize().height)); scrollPane.setBorder(BorderFactory.createEmptyBorder()); String cleanTitle = title.replace("<suggestion>", "'").replace("</suggestion>", "'"); JOptionPane.showMessageDialog(parent, scrollPane, cleanTitle, JOptionPane.INFORMATION_MESSAGE); }
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./*from w w w.ja va2 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.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep1(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"), localeDelegate.getMessage("dbtransfer.import.step1.2", "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus.")); final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei")); utils.initJPanel(step,//from w w w . j av a 2 s. c o m new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL }); final JButton btnBrowse = new JButton("..."); //final JProgressBar progressBar = new JProgressBar(0, 230); final JCheckBox chbxImportAsNuclon = new JCheckBox( localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon")); chbxImportAsNuclon.setEnabled(false); final JEditorPane editWarnings = new JEditorPane(); editWarnings.setContentType("text/html"); editWarnings.setEditable(false); editWarnings.setBackground(Color.WHITE); final JScrollPane scrollWarn = new JScrollPane(editWarnings); scrollWarn.setPreferredSize(new Dimension(680, 250)); scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); scrollWarn.getVerticalScrollBar().setUnitIncrement(20); scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent); scrollPrev.setPreferredSize(new Dimension(680, 250)); scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1)); scrollPrev.getVerticalScrollBar().setUnitIncrement(20); scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); final JPanel jpnPreview = new JPanel(new BorderLayout()); jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH); jpnPreview.add(scrollPrev, BorderLayout.CENTER); jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH); jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); jpnPreview.setBackground(Color.WHITE); jpnPreviewHeader.setBackground(Color.WHITE); jpnPreviewContent.setBackground(Color.WHITE); jpnPreviewFooter.setBackground(Color.WHITE); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"), scrollWarn); final String sDefaultPreparePreviewTabText = localeDelegate .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen"); tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview); final JLabel lbNewUser = new JLabel(); step.add(lbFile, "0,0"); step.add(tfTransferFile, "1,0"); step.add(btnBrowse, "2,0"); step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1"); step.add(lbNewUser, "0,2,3,2"); step.add(tabbedPane, "0,3,3,3"); tfTransferFile.setEditable(false); final ActionListener prepareImportAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE); Thread t = new Thread() { @Override public void run() { step.setComplete(false); boolean blnTransferWithWarnings = false; //progressBar.setValue(0); //progressBar.setVisible(true); try { String fileName = tfTransferFile.getText(); if (StringUtils.isNullOrEmpty(fileName)) { return; } File f = new File(fileName); long size = f.length(); final InputStream fin = new BufferedInputStream(new FileInputStream(f)); final byte[] transferFile; try { transferFile = utils.getBytes(fin, (int) size); } finally { fin.close(); } resetStep2(); importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon, transferFile); chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions() .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED)); step.setComplete(!importTransferObject.result.hasCriticals()); if (!importTransferObject.result.hasCriticals() && !importTransferObject.result.hasWarnings()) { editWarnings.setText(localeDelegate.getMessage( "configuration.transfer.prepare.no.warnings", "Keine Warnungen")); } else { editWarnings.setText("<html><body><font color=\"#800000\">" + importTransferObject.result.getCriticals() + "</font>" + (importTransferObject.result.hasCriticals() ? "<br />" : "") + importTransferObject.result.getWarnings() + "</body></html>"); } int iPreviewSize = importTransferObject.getPreviewParts().size(); blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts()); tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")")); lbNewUser.setText( "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine" : importTransferObject.getNewUserCount())); } catch (Exception e) { // progressBar.setVisible(false); Errors.getInstance().showExceptionDialog(ifrm, e); } finally { btnBrowse.setEnabled(true); // progressBar.setVisible(false); ifrm.unlockLayer(); } if (blnTransferWithWarnings) { JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage( "dbtransfer.import.step1.19", "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!", "Warning", JOptionPane.WARNING_MESSAGE)); } } }; t.start(); } }; final ActionListener browseAction = new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"), ".nuclet"); final int iBtn = filechooser.showOpenDialog(ifrm); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { tfTransferFile.setText(""); btnBrowse.setEnabled(false); //progressBar.setVisible(true); String fileName = file.getPath(); if (StringUtils.isNullOrEmpty(fileName)) { return; } tfTransferFile.setText(fileName); prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare")); } } } }; final ActionListener importAsNuclonAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { isNuclon = chbxImportAsNuclon.isSelected(); prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare")); } }; btnBrowse.addActionListener(browseAction); chbxImportAsNuclon.addActionListener(importAsNuclonAction); // progressBar.setVisible(false); return step; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private boolean setupPreviewPanel(List<PreviewPart> previewParts) { boolean blnTransferWithWarnings = false; jpnPreviewHeader.removeAll();//from w w w. j a v a 2 s .c om jpnPreviewFooter.removeAll(); // setup parameter scroll pane jpnPreviewContent.removeAll(); double[] rowContraints = new double[previewParts.size()]; for (int i = 0; i < previewParts.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JLabel lbPreviewHeaderEntity = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t")); JLabel lbPreviewHeaderTable = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname")); JLabel lbPreviewHeaderRecords = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze")); lbPreviewHeaderRecords.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze")); utils.initJPanel(jpnPreviewContent, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED }, rowContraints); int iWidthEntityLabelSize = 0; int iWidthTableLabelSize = 0; int iWidthRecordsLabelSize = 0; int iCountNew = 0; int iCountDeleted = 0; int iCountChanged = 0; int iRow = 0; for (final PreviewPart pp : previewParts) { String tooltip = ""; JLabel lbEntity = new JLabel(pp.getEntity()); JLabel lbTable = new JLabel(pp.getTable()); JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords())); lbRecords.setHorizontalAlignment(SwingConstants.RIGHT); if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width) lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize()); if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width) lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize()); if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width) lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize()); iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width ? lbEntity.getPreferredSize().width : iWidthEntityLabelSize; iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width ? lbTable.getPreferredSize().width : iWidthTableLabelSize; iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width ? lbRecords.getPreferredSize().width : iWidthRecordsLabelSize; Icon icoStatement = null; switch (pp.getType()) { case PreviewPart.NEW: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6", "Entit\u00e4t wird hinzugef\u00fcgt"); icoStatement = ParameterEditor.COMPARE_ICON_NEW; iCountNew++; break; case PreviewPart.CHANGE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert"); icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED; iCountChanged++; break; case PreviewPart.DELETE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht"); icoStatement = ParameterEditor.COMPARE_ICON_DELETED; iCountDeleted++; break; } JLabel lbIcon = new JLabel(icoStatement); JLabel lbStatemnts = new JLabel("<html><u>" + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>"); lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbStatemnts.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { String statements = ""; for (String statement : pp.getStatements()) { statements = statements + statement + ";\n\n"; } JTextArea txtArea = new JTextArea(statements); txtArea.setEditable(false); txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JScrollPane scroll = new JScrollPane(txtArea); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setPreferredSize(new Dimension(600, 300)); scroll.setBorder(BorderFactory.createEmptyBorder()); MainFrameTab overlayFrame = new MainFrameTab( localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " " + pp.getEntity() + " (" + pp.getTable() + ")"); overlayFrame.setLayeredComponent(scroll); ifrm.add(overlayFrame); } }); lbIcon.setToolTipText(tooltip); lbStatemnts.setToolTipText(tooltip); lbEntity.setToolTipText(tooltip); lbTable.setToolTipText(tooltip); jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c"); jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c"); jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c"); jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c"); jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c"); if (pp.getWarning() > 0) { lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16()); blnTransferWithWarnings = true; } iRow++; } jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1)); // setup preview header utils.initJPanel(jpnPreviewHeader, new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize, iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); if (previewParts.isEmpty()) { jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18", "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0"); return blnTransferWithWarnings; } jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0"); jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0"); jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0"); jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")), "7,0"); // setup preview footer utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten")); lbCompareDeleted.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten")); lbCompareValueChanged.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten")); jpnPreviewFooter.add(lbCompare, "1,0,r,c"); jpnPreviewFooter.add(lbCompareNew, "2,0,r,c"); jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c"); jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c"); return blnTransferWithWarnings; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep3(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step3.1", "System Parameter"), localeDelegate.getMessage("dbtransfer.import.step3.2", "Bestimmen Sie die Parameter dieses Systems. Sie k\u00f6nnen w\u00e4hlen zwischen dem aktuellen Zustand und dem aus der Konfigurationsdatei importierten Zustand (default). Sollte keine der beiden Vorgaben stimmen, so k\u00f6nnen Sie auch einen anderen Wert setzen.")) { @Override/*from w w w. ja va2s . c o m*/ public void prepare() { setupParameterPanel(importTransferObject.getParameter()); } @Override public void applyState() throws InvalidStateException { setSelectedIncomingParameter.clear(); setSelectedCurrentParameter.clear(); mapSelectedOtherParameter.clear(); for (ParameterEditor pe : lstParameterEditors) { if (pe.isCurrentValue()) setSelectedCurrentParameter.add(pe.getName()); if (pe.isIncomingValue()) setSelectedIncomingParameter.add(pe.getName()); if (pe.isOtherValue()) mapSelectedOtherParameter.put(pe.getName(), pe.getValue()); } } }; step.setComplete(true); utils.initJPanel(step, new double[] { TableLayout.FILL }, new double[] { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED }); rbCurrentAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetParameterEditors(true); } }); rbIncomingAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetParameterEditors(false); } }); final JScrollPane scroll = new JScrollPane(jpnParameter); scroll.setPreferredSize(new Dimension(680, 250)); scroll.setBorder(new LineBorder(Color.LIGHT_GRAY, 1)); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Dimension parameterPanelSize = new Dimension(scroll.getViewport().getWidth(), jpnParameter.getPreferredSize().height); jpnParameter.setPreferredSize(parameterPanelSize); } }); step.add(jpnParameterHeader, "0,0"); step.add(scroll, "0,1"); step.add(jpnParameterFooter, "0,2"); return step; }
From source file:org.nuxeo.launcher.gui.NuxeoFrame.java
/** * @param logFile//from ww w . j a v a 2 s .com */ protected JComponent buildLogPanel(String logFile) { ColoredTextPane textArea = new ColoredTextPane(); textArea.setEditable(false); textArea.setAutoscrolls(true); textArea.setBackground(new Color(54, 55, 67)); textArea.setMaxSize(LOG_MAX_SIZE); JScrollPane logsScroller = new JScrollPane(textArea); logsScroller.setVisible(true); logsScroller.setBorder(BorderFactory.createLineBorder(Color.BLACK)); logsScroller.setAutoscrolls(true); logsScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); logsScroller.setWheelScrollingEnabled(true); logsScroller.setPreferredSize(new Dimension(450, 160)); controller.initLogsManagement(logFile, textArea); logsScroller.addComponentListener(new LogsPanelListener(logFile)); return logsScroller; }
From source file:org.o3project.optsdn.don.frame.NeFrame.java
/** * Create a pane that displays OMS connection information. * // w w w . j ava 2 s . c o m * @return The pane that displays OMS connection information */ private JScrollPane createOmsConnectionInfoPane() { Object[] header = OMS_CONNECTION_INFO_COLNAME_LIST.toArray(); String[][] rowDataList = new String[omsConnectionInfoList.size()][header.length]; for (int i = 0; i < rowDataList.length; i++) { List<Port> omsConnectionInfo = omsConnectionInfoList.get(i); Port port = omsConnectionInfo.get(0); int ofPortIndex = OMS_CONNECTION_INFO_COLNAME_LIST.indexOf(OmsConnectionInfoCols.OF_PORT.getName()); Integer openFlowPortId1 = port.getOpenFlowPortId(); String ofPortValue1; if (openFlowPortId1 == null) { ofPortValue1 = OFPORT_NOTFOUND; } else { ofPortValue1 = String.valueOf(openFlowPortId1); } rowDataList[i][ofPortIndex] = ofPortValue1; Port port2 = omsConnectionInfo.get(1); int connectedToIndex = OMS_CONNECTION_INFO_COLNAME_LIST .indexOf(OmsConnectionInfoCols.CONNECTED_TO.getName()); Integer openFlowPortId2 = port2.getOpenFlowPortId(); String ofPortValue2; if (openFlowPortId2 == null) { ofPortValue2 = OFPORT_NOTFOUND; } else { ofPortValue2 = String.valueOf(openFlowPortId2); } rowDataList[i][connectedToIndex] = port2.getNeId() + ", " + ofPortValue2; } JTable connectedTable = new JTable(rowDataList, header); connectedTable.getTableHeader().setBackground(Color.WHITE); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(SwingConstants.CENTER); for (int i = 0; i < header.length; i++) { TableColumn column = connectedTable.getColumnModel().getColumn(i); column.setCellRenderer(renderer); } JScrollPane connectedPane = new JScrollPane(); connectedPane.getViewport().setView(connectedTable); connectedPane.setPreferredSize(new Dimension(connectedPane.getPreferredSize().width, TABLE_HEIGHT)); return connectedPane; }