List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy
@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED", "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER", "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy") public void setVerticalScrollBarPolicy(int policy)
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewParametersDialog.java
private JScrollPane createParametersPanel() { parametersPanel = new ParameterReportControllerPane(); try {/*from ww w. j a va2 s. c om*/ parametersPanel.setReport(masterReport); } catch (ReportProcessingException e) { parametersPanel.setErrorMessage(e.getMessage()); logger.error("Failed to query parameters", e); // NON-NLS } parametersPanel.hideControls(); final JPanel carrierPanel = new JPanel(new BorderLayout()); carrierPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); carrierPanel.add(parametersPanel, BorderLayout.NORTH); final JScrollPane result = new JScrollPane(carrierPanel); result.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); return result; }
From source file:org.photovault.swingui.PhotoInfoEditor.java
protected void createUI() { setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); tabPane = new JTabbedPane(); add(tabPane, BorderLayout.CENTER); // General pane JPanel generalPane = new JPanel(); tabPane.addTab("General", generalPane); // Create the fields & their labels // Photographer field JLabel photographerLabel = new JLabel("Photographer"); photographerField = createMvTextField("photographer", 30); photographerDoc = photographerField.getDocument(); // "Fuzzy time" field JLabel fuzzyDateLabel = new JLabel("Shooting date"); fuzzyDateField = new JTextField(30); fuzzyDateDoc = fuzzyDateField.getDocument(); fuzzyDateDoc.putProperty(FIELD, PhotoInfoFields.FUZZY_SHOOT_TIME); fuzzyDateDoc.addDocumentListener(this); JLabel qualityLabel = new JLabel("Quality"); qualityField = new JComboBox(qualityStrings); qualityField.addActionListener(this); StarRating qualityStars = new StarRating(5); FieldController<Integer> qfCtrl = ctrl.getFieldController("quality"); ValueModel qualityFieldValue = new PropertyAdapter(qfCtrl, "value", true); ValueModel starCount = new PropertyAdapter(qualityStars, "selection", true); PropertyConnector.connect(qualityFieldValue, "value", starCount, "value"); // Shooting place field JLabel shootingPlaceLabel = new JLabel("Shooting place"); shootingPlaceField = createMvTextField("shotLocation.description", 30); shootingPlaceDoc = shootingPlaceField.getDocument(); JLabel shotLocRoadLabel = new JLabel("Road"); JTextField shotLocRoadField = createMvTextField("shotLocation.road", 30); JLabel shotLocSuburbLabel = new JLabel("Suburb"); JTextField shotLocSuburbField = createMvTextField("shotLocation.suburb", 30); JLabel shotLocCityLabel = new JLabel("City"); JTextField shotLocCityField = createMvTextField("shotLocation.city", 30); JLabel shotLocCountryLabel = new JLabel("Country"); JTextField shotLocCountryField = createMvTextField("shotLocation.country", 30); JLabel shotLocGeohashLabel = new JLabel("Geohash code"); JTextField shotLocGeohashField = createMvTextField("shotLocation.geoHashString", 30); shotLocGeohashField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "fillAddress"); shotLocGeohashField.getActionMap().put("fillAddress", new FindAddressAction(ctrl)); // Tags//from ww w. j ava 2s . c o m JLabel tagLabel = new JLabel("Tags"); tagList = new TagList2(ctrl.getTagController()); tagList.setBackground(generalPane.getBackground()); // Description text JLabel descLabel = new JLabel("Description"); descriptionTextArea = new JTextArea(5, 40); descriptionTextArea.setLineWrap(true); descriptionTextArea.setWrapStyleWord(true); JScrollPane descScrollPane = new JScrollPane(descriptionTextArea); descScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border descBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); descBorder = BorderFactory.createTitledBorder(descBorder, "Description"); descScrollPane.setBorder(descBorder); descriptionDoc = descriptionTextArea.getDocument(); descriptionDoc.putProperty(FIELD, PhotoInfoFields.DESCRIPTION); descriptionDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); generalPane.setLayout(layout); JLabel[] labels = { photographerLabel, fuzzyDateLabel, shootingPlaceLabel, shotLocGeohashLabel, shotLocRoadLabel, shotLocSuburbLabel, shotLocCityLabel, shotLocCountryLabel, qualityLabel, tagLabel }; JComponent[] fields = { photographerField, fuzzyDateField, shootingPlaceField, shotLocGeohashField, shotLocRoadField, shotLocSuburbField, shotLocCityField, shotLocCountryField, qualityStars, tagList }; addLabelTextRows(labels, fields, layout, generalPane); c = layout.getConstraints(tagList); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.0; c.weighty = 1.0; layout.setConstraints(tagList, c); generalPane.add(descScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(descScrollPane, c); c = new GridBagConstraints(); c.gridwidth = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.gridy = GridBagConstraints.RELATIVE; c.gridy = GridBagConstraints.RELATIVE; createTechDataUI(); createFolderPaneUI(); createRightsUI(); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
protected void createTechDataUI() { JPanel pane = new JPanel(); tabPane.addTab("Tech data", pane); JLabel cameraMakerLabel = new JLabel("Camera make"); JTextField cameraMakerField = createMvTextField("cameraMaker", 20); // cameraDoc = cameraField.getDocument(); JLabel cameraLabel = new JLabel("Camera model"); cameraField = createMvTextField("camera", 20); cameraDoc = cameraField.getDocument(); JLabel lensLabel = new JLabel("Lens"); lensField = createMvTextField("lens", 20); lensDoc = lensField.getDocument();// w ww . java 2 s. com JLabel filmLabel = new JLabel("Film"); filmField = createMvTextField("film", 20); filmDoc = filmField.getDocument(); JLabel filmSpeedLabel = new JLabel("Film speed"); NumberFormatter filmSpeedFormatter = new NumberFormatter(new DecimalFormat("#########0")); filmSpeedFormatter.setValueClass(PhotoInfoFields.FILM_SPEED.getType()); filmSpeedField = new JFormattedTextField(filmSpeedFormatter); filmSpeedField.setColumns(5); filmSpeedField.addPropertyChangeListener(this); filmSpeedField.putClientProperty(FIELD, PhotoInfoFields.FILM_SPEED); JLabel shutterSpeedLabel = new JLabel("Shutter speed"); DecimalFormat shutterSpeedFormat = new DecimalFormat("###0.####"); NumberFormatter shutterSpeedFormatter = new NumberFormatter(shutterSpeedFormat); shutterSpeedFormatter.setValueClass(PhotoInfoFields.SHUTTER_SPEED.getType()); shutterSpeedField = new JFormattedTextField(shutterSpeedFormatter); shutterSpeedField.setColumns(5); shutterSpeedField.addPropertyChangeListener(this); shutterSpeedField.putClientProperty(FIELD, PhotoInfoFields.SHUTTER_SPEED); JLabel fStopLabel = new JLabel("F-stop"); DecimalFormat fStopFormat = new DecimalFormat("#0.#"); NumberFormatter fStopFormatter = new NumberFormatter(fStopFormat); fStopFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); fStopField = new JFormattedTextField(fStopFormatter); fStopField.setColumns(5); fStopField.addPropertyChangeListener(this); fStopField.putClientProperty(FIELD, PhotoInfoFields.FSTOP); JLabel focalLengthLabel = new JLabel("Focal length"); NumberFormatter focalLengthFormatter = new NumberFormatter(new DecimalFormat("#######0.#")); focalLengthFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); focalLengthField = new JFormattedTextField(focalLengthFormatter); focalLengthField.setColumns(5); focalLengthField.addPropertyChangeListener(this); focalLengthField.putClientProperty(FIELD, PhotoInfoFields.FOCAL_LENGTH); // Tech note text JLabel notesLabel = new JLabel("Tech. notes"); technoteTextArea = new JTextArea(5, 40); technoteTextArea.setLineWrap(true); technoteTextArea.setWrapStyleWord(true); JScrollPane technoteScrollPane = new JScrollPane(technoteTextArea); technoteScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border technoteBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); technoteBorder = BorderFactory.createTitledBorder(technoteBorder, "Description"); technoteScrollPane.setBorder(technoteBorder); technoteDoc = technoteTextArea.getDocument(); technoteDoc.putProperty(FIELD, PhotoInfoFields.TECH_NOTES); technoteDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout); JLabel[] labels = { cameraMakerLabel, cameraLabel, lensLabel, focalLengthLabel, filmLabel, filmSpeedLabel, shutterSpeedLabel, fStopLabel }; JTextField[] fields = { cameraMakerField, cameraField, lensField, focalLengthField, filmField, filmSpeedField, shutterSpeedField, fStopField }; addLabelTextRows(labels, fields, layout, pane); pane.add(technoteScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(technoteScrollPane, c); }
From source file:org.photovault.swingui.PhotoInfoEditor.java
private void createRightsUI() { JPanel pane = new JPanel(); tabPane.addTab("Rights", pane); JLabel copyrightLabel = new JLabel("Copyright"); JTextField copyrightField = createMvTextField("usageRights.copyright", 30); JLabel attributionLabel = new JLabel("Name for attribution"); JTextField attributionField = createMvTextField("usageRights.attributionName", 30); JLabel attributionUrlLabel = new JLabel("Url for attribution"); JTextField attributionUrlField = createMvTextField("usageRights.attributionUrl", 30); JLabel licenseLabel = new JLabel("License"); List<License> licenses = new ArrayList(); licenses.addAll(EnumSet.allOf(License.class)); JComboBox licenseCombo = createMvComboBox("usageRights.license", licenses); // Tech note text JLabel termsLabel = new JLabel("Usage terms"); JTextArea termsTextArea = createMvTextArea("usageRights.usageTerms", 5, 40); termsTextArea.setLineWrap(true);/*from w w w .j a v a 2 s.com*/ termsTextArea.setWrapStyleWord(true); JScrollPane termsScrollPane = new JScrollPane(termsTextArea); termsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border termsBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); termsBorder = BorderFactory.createTitledBorder(termsBorder, "Usage terms"); termsScrollPane.setBorder(termsBorder); GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout); JLabel[] labels = { copyrightLabel, licenseLabel, attributionLabel, attributionUrlLabel }; JComponent[] fields = { copyrightField, licenseCombo, attributionField, attributionUrlField }; addLabelTextRows(labels, fields, layout, pane); pane.add(termsScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(termsScrollPane, c); }
From source file:org.pmedv.blackboard.commands.CreateBoardCommand.java
@Override public void execute(ActionEvent e) { final ApplicationContext ctx = AppContext.getContext(); final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class); final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); /*/*from ww w.j av a2s . c om*/ * Get the resource service */ final ResourceService resources = ctx.getBean(ResourceService.class); /* * The infonode docking framework must be invoked later since swing is * not thread safe. */ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { BoardEditorModel model = new BoardEditorModel(); model.addDefaultLayers(); model.setWidth(IOUtils.BOARD_DEFAULT_WIDTH); model.setHeight(IOUtils.BOARD_DEFAULT_HEIGHT); String title = resources.getResourceByKey("CreateBoardCommand.name"); String subTitle = resources.getResourceByKey("CreateBoardCommand.dialog.subtitle"); BoardPropertiesDialog bpd = new BoardPropertiesDialog(title, subTitle, resources.getIcon("icon.dialog.board"), model); bpd.setVisible(true); if (bpd.getResult() == AbstractNiceDialog.OPTION_CANCEL) return; final BoardEditor editor = new BoardEditor(model); // the center panel centers the editor inside the view no matter which dimensions it has CenterPanel panel = new CenterPanel(); // go for the zoom JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints()); panel.getCenterPanel().add(zoomLayer); editor.setZoomLayer(zoomLayer); panel.setBoardEditor(editor); // put the panel into a scroll pane JScrollPane s = new JScrollPane(panel); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); s.getVerticalScrollBar().setUnitIncrement(512); // create new view and connect the view with the editor editorView = new View(title, resources.getIcon("icon.editor"), s); editor.setView(editorView); editor.setFileState(FileState.NEW_AND_UNSAVED); editor.setCurrentFile(null); // check all available open views ArrayList<View> views = EditorUtils.getCurrentPerspectiveViews(advisor.getCurrentPerspective()); // we need this index for a new untitled view int lastUntitledIndex = 0; for (View v : views) { // found a view with an untitled editor if (v.getViewProperties().getTitle().startsWith("untitled")) { // select index if it's greater than the last int index = 0; if (v.getViewProperties().getTitle().contains("*")) { int end = v.getViewProperties().getTitle().lastIndexOf("*"); index = Integer.valueOf(v.getViewProperties().getTitle().substring(8, end)); } else { index = Integer.valueOf(v.getViewProperties().getTitle().substring(8)); } if (index > lastUntitledIndex) lastUntitledIndex = index; } } // and finally add one in order to get the right name lastUntitledIndex++; editor.getView().getViewProperties().setTitle("untitled" + lastUntitledIndex); final int index = editor.getView().hashCode(); EditorUtils.registerEditorListeners(editor); openEditor(editorView, index); log.info("Opening editor : " + title); // notifies the GUI about the editor change if a tab is switched by the mouse editorView.addTabMouseButtonListener(new MouseButtonListener() { @Override public void mouseButtonEvent(MouseEvent e) { handleMouseEvent(e, editor); } }); // wee need to know if a mouse click inside an editor occurs editor.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMouseEvent(e, editor); } }); // This listener handles the close of an editor tab editorView.addListener(new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow arg0) throws OperationAbortedException { if (editor != null) if (editor.getFileState().equals(FileState.DIRTY)) { int result = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.warning.notsaved"), resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.NO_OPTION) { throw new OperationAbortedException("Aborted."); } } advisor.getCurrentPerspective().getViewMap().removeView(index); editor.notifyListeners(EventType.EDITOR_CLOSED); } @Override public void windowClosed(DockingWindow window) { editor.notifyListeners(EventType.EDITOR_CLOSED); } }); editor.updateStatusBar(); editor.notifyListeners(EventType.EDITOR_CHANGED); ctx.getBean(SetSelectModeCommand.class).execute(null); } }); }
From source file:org.pmedv.blackboard.commands.CreatePartListCommand.java
@Override public void execute(ActionEvent e) { ApplicationContext ctx = AppContext.getContext(); final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); final BoardEditor editor = EditorUtils.getCurrentActiveEditor(); StringBuffer partList = new StringBuffer(); partList.append("Name,Value,Package\n"); for (Layer layer : editor.getModel().getLayers()) { for (Item i : layer.getItems()) { if (i instanceof Part && !(i instanceof TextPart)) { Part p = (Part) i;/*from ww w . j a v a 2s . c o m*/ partList.append(p.getName() + "," + p.getValue() + "," + p.getPackageType() + "\n"); } if (i instanceof Resistor) { Resistor r = (Resistor) i; partList.append(r.getName() + "," + r.getValue() + " Ohm,RESISTOR\n"); } } } final JFileChooser fc = new JFileChooser("."); fc.setFileFilter(new CSVFilter()); fc.setDialogTitle(resources.getResourceByKey("CreatePartListCommand.dialog.subtitle")); fc.setApproveButtonText(resources.getResourceByKey("msg.save")); int result = fc.showOpenDialog(win); if (result == JFileChooser.APPROVE_OPTION) { if (fc.getSelectedFile() == null) return; File selectedFile = fc.getSelectedFile(); if (selectedFile != null) { // if csv extension is missing... if (!selectedFile.getName().endsWith(".csv")) { selectedFile = new File(selectedFile.getAbsolutePath() + ".csv"); } try { FileUtils.writeStringToFile(selectedFile, partList.toString(), "UTF-8"); int res = JOptionPane.showConfirmDialog(win, resources.getResourceByKey("msg.viewpartlist"), resources.getResourceByKey("msg.question"), JOptionPane.YES_NO_OPTION); if (res == JOptionPane.YES_OPTION) { JTextArea textPane = new JTextArea(); textPane.setText(partList.toString()); JScrollPane s = new JScrollPane(textPane); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); View v = new View("Partlist for " + editor.getCurrentFile().getName(), null, s); editor.setView(v); final ImageIcon icon = resources.getIcon("icon.document.html"); v.getViewProperties().setIcon(icon); v.getViewProperties().setTitle("Partlist for " + editor.getCurrentFile().getName()); openEditor(v, editor.getCurrentFile().hashCode()); v.undock(new Point(20, 10)); } } catch (IOException e1) { ErrorUtils.showErrorDialog(e1); } } } }
From source file:org.pmedv.blackboard.commands.OpenBoardCommand.java
public void doOpen() { final ApplicationContext ctx = AppContext.getContext(); final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class); BoardEditorModel model = null;/* w w w . jav a2 s .c o m*/ String filename = file.getName().toLowerCase(); try { if (filename.endsWith(".bb") || filename.endsWith(".bbs")) { File input; try { input = IOUtils.unpackBoard(file); } catch (Exception e1) { ErrorUtils.showErrorDialog(e1); return; } model = IOUtils.openBoard(input); } else // legacy xml support model = IOUtils.openBoard(file); } catch (Exception e1) { ErrorUtils.showErrorDialog(e1); file = null; return; } if (model == null) { ErrorUtils.showErrorDialog( new Exception(resources.getResourceByKey("OpenBoardCommand.error") + " : " + file.getName())); file = null; return; } final BoardEditor editor = new BoardEditor(model); CenterPanel panel = new CenterPanel(); JXLayer<?> zoomLayer = TransformUtils.createTransformJXLayer(editor, 1, new QualityHints()); panel.getCenterPanel().add(zoomLayer); editor.setZoomLayer(zoomLayer); panel.setBoardEditor(editor); JScrollPane s = new JScrollPane(panel); s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); editorView = new View(title, resources.getIcon("icon.editor"), s); editor.setView(editorView); editor.setCurrentFile(file); editor.setFileState(FileState.OPENED); EditorUtils.registerEditorListeners(editor); editorView.getViewProperties().setTitle(file.getName()); try { IOUtils.updateRecentFiles(file.getAbsolutePath()); } catch (Exception e1) { ErrorUtils.showErrorDialog(e1); } openEditor(editorView, editor.getCurrentFile().hashCode()); if (!fromRecentFileList) file = null; editorView.addTabMouseButtonListener(new MouseButtonListener() { @Override public void mouseButtonEvent(MouseEvent e) { handleMouseEvent(e, editor); } }); editor.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handleMouseEvent(e, editor); } }); editorView.addListener(new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow arg0) throws OperationAbortedException { if (editor.getFileState().equals(FileState.DIRTY)) { int result = JOptionPane.showConfirmDialog(ctx.getBean(ApplicationWindow.class), resources.getResourceByKey("msg.warning.notsaved"), resources.getResourceByKey("msg.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.NO_OPTION) { throw new OperationAbortedException("Aborted."); } } log.info("Removing view with index " + editor.getCurrentFile().hashCode() + " from perspective " + advisor.getCurrentPerspective().ID); advisor.getCurrentPerspective().getViewMap().removeView(editor.getCurrentFile().hashCode()); editor.notifyListeners(EventType.EDITOR_CLOSED); } @Override public void windowClosed(DockingWindow window) { editor.notifyListeners(EventType.EDITOR_CLOSED); } }); editor.updateStatusBar(); editor.notifyListeners(EventType.EDITOR_CHANGED); ctx.getBean(SetSelectModeCommand.class).execute(null); }
From source file:org.p_vcd.ui.LicenseDialog.java
public LicenseDialog(String libName, String libHomepage, String licenseName, String licenseFilename) { setSize(680, 480);/*from w w w.j a v a2 s . c om*/ setTitle(libName); getContentPane().setLayout(new BorderLayout()); { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.NORTH); panel.setLayout(new MigLayout("", "[grow,trailing][grow]", "[20px][][]")); { JLabel lblSoft = new JLabel(libName); lblSoft.setFont(new Font("Tahoma", Font.BOLD, 16)); panel.add(lblSoft, "center,cell 0 0 2 1"); } { JLabel lblHomePage = new JLabel("Home page:"); lblHomePage.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblHomePage, "cell 0 1"); } { JLabel lblHome = SwingUtil.createLink(libHomepage, libHomepage); lblHome.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblHome, "cell 1 1"); } { JLabel lblNewLabel = new JLabel("License:"); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblNewLabel, "cell 0 2"); } { JLabel lblLicense = new JLabel(licenseName); lblLicense.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblLicense, "cell 1 2"); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(new FlowLayout()); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(600, 300)); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scrollPane); { JTextArea txtLicense = new JTextArea(); txtLicense.setEditable(false); txtLicense.setFont(new Font("Monospaced", Font.PLAIN, 11)); txtLicense.setWrapStyleWord(true); txtLicense.setLineWrap(true); try { InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/p_vcd/licenses/" + licenseFilename); String text = IOUtils.toString(is, "UTF-8"); IOUtils.closeQuietly(is); txtLicense.setText(text); txtLicense.setCaretPosition(0); } catch (Exception e) { e.printStackTrace(); } scrollPane.setViewportView(txtLicense); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LicenseDialog.this.dispose(); } }); okButton.setActionCommand("OK"); panel.add(okButton); getRootPane().setDefaultButton(okButton); } }
From source file:org.spoutcraft.launcher.skin.ConsoleFrame.java
/** * Build the interface./* w ww . jav a 2 s .c o m*/ */ private void buildUI() { if (colorEnabled) { JTextPane text = new JTextPane(); this.textComponent = text; } else { JTextArea text = new JTextArea(); this.textComponent = text; text.setLineWrap(true); } textComponent.addMouseListener(this); textComponent.setFont(getMonospaceFont()); textComponent.setEditable(false); DefaultCaret caret = (DefaultCaret) textComponent.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); document = textComponent.getDocument(); document.addDocumentListener(new LimitLinesDocumentListener(numLines, true)); JScrollPane scrollText = new JScrollPane(textComponent); scrollText.setBorder(null); scrollText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); add(scrollText, BorderLayout.CENTER); }
From source file:org.stanwood.swing.AboutDialog.java
private JComponent createAuthorsTab() { JScrollPane scroll = new JScrollPane(); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); for (Author author : authors) { box.add(new JLabel(author.getName())); JXHyperlink link = new JXHyperlink( new LinkAction(this, author.getEmail(), "mailto:" + author.getEmail())); box.add(link);// w w w . j av a 2 s . c o m link.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); JLabel lblDescription = new JLabel(author.getDescription()); lblDescription.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); box.add(lblDescription); } scroll.getViewport().add(box); return scroll; }