List of usage examples for javax.swing JLabel setIconTextGap
@BeanProperty(visualUpdate = true, description = "If both the icon and text properties are set, this property defines the space between them.") public void setIconTextGap(int iconTextGap)
From source file:io.github.tavernaextras.biocatalogue.integration.Integration.java
/** * /*from www . j ava 2 s .com*/ * @param processorResource * @return Outcome of inserting the processor into the current workflow as a * HTML-formatted string (with no opening and closing HTML tags). */ public static JComponent insertProcesorIntoServicePanel(ResourceLink processorResource) { // check if this type of resource can be added to Service Panel TYPE resourceType = Resource.getResourceTypeFromResourceURL(processorResource.getHref()); if (resourceType.isSuitableForAddingToServicePanel()) { switch (resourceType) { case SOAPOperation: SoapOperation soapOp = (SoapOperation) processorResource; try { SoapService soapService = BioCatalogueClient.getInstance() .getBioCatalogueSoapService(soapOp.getAncestors().getSoapService().getHref()); SoapOperationIdentity soapOpId = new SoapOperationIdentity(soapService.getWsdlLocation(), soapOp.getName(), StringEscapeUtils.escapeHtml(soapOp.getDescription())); WSDLOperationFromBioCatalogueServiceDescription wsdlOperationDescription = new WSDLOperationFromBioCatalogueServiceDescription( soapOpId); BioCatalogueWSDLOperationServiceProvider.registerWSDLOperation(wsdlOperationDescription, null); return (new JLabel("Selected SOAP operation has been successfully added to the Service Panel.", ResourceManager.getImageIcon(ResourceManager.TICK_ICON), JLabel.CENTER)); } catch (Exception e) { logger.error( "Failed to fetch required details to add this SOAP service into the Service Panel.", e); return (new JLabel( "Failed to fetch required details to add this " + "SOAP service into the Service Panel.", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } case RESTMethod: try { // received object may only contain limited data, therefore need to fetch full details first RestMethod restMethod = BioCatalogueClient.getInstance() .getBioCatalogueRestMethod(processorResource.getHref()); RESTFromBioCatalogueServiceDescription restServiceDescription = createRESTServiceDescriptionFromRESTMethod( restMethod); // actual insertion of the REST method into Service Panel BioCatalogueRESTServiceProvider.registerNewRESTMethod(restServiceDescription, null); // prepare result of the operation to be shown in the the waiting dialog window String warnings = extractWarningsFromRESTServiceDescription(restServiceDescription, true); JLabel outcomes = new JLabel( "<html>Selected REST method has been successfully added to the Service Panel" + warnings + "</html>", ResourceManager.getImageIcon(warnings.length() > 0 ? ResourceManager.WARNING_ICON : ResourceManager.TICK_ICON), JLabel.CENTER); outcomes.setIconTextGap(20); return (outcomes); } catch (UnsupportedHTTPMethodException e) { logger.error(e); return (new JLabel(e.getMessage(), ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } catch (Exception e) { logger.error( "Failed to fetch required details to add this REST service into the Service Panel.", e); return (new JLabel( "Failed to fetch required details to add this " + "REST service into the Service Panel.", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } // type not currently supported, but maybe in the future? default: return (new JLabel( "Adding " + resourceType.getCollectionName() + " to the Service Panel is not yet possible", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } // definitely not supported type return (new JLabel( "<html>It is not possible to add resources of the provided type<br>" + "into the Service Panel.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); }
From source file:io.github.tavernaextras.biocatalogue.integration.Integration.java
/** * Adds a processor to the current workflow. * The processor is specified by WSDL location and the operation name. * /*from w w w . j ava 2s .c o m*/ * @param processorResource Resource to add to the current workflow. * @return Outcome of inserting the processor into the current workflow as a * HTML-formatted string (with no opening and closing HTML tags). */ public static JComponent insertProcessorIntoCurrentWorkflow(ResourceLink processorResource) { // check if this type of resource can be added to workflow diagram TYPE resourceType = Resource.getResourceTypeFromResourceURL(processorResource.getHref()); if (resourceType.isSuitableForAddingToWorkflowDiagram()) { switch (resourceType) { case SOAPOperation: SoapOperation soapOp = (SoapOperation) processorResource; try { SoapService soapService = BioCatalogueClient.getInstance() .getBioCatalogueSoapService(soapOp.getAncestors().getSoapService().getHref()); try { WSDLServiceDescription myServiceDescription = new WSDLServiceDescription(); myServiceDescription.setOperation(soapOp.getName()); myServiceDescription.setUse("literal"); // or "encoded" myServiceDescription.setStyle("document"); // or "rpc" myServiceDescription.setURI(new URI(soapService.getWsdlLocation())); myServiceDescription .setDescription(StringEscapeUtils.escapeHtml(soapService.getDescription())); // TODO - not sure where this is used if (WorkflowView.importServiceDescription(myServiceDescription, false) != null) { return (new JLabel( "Selected " + TYPE.SOAPOperation.getTypeName() + " was successfully added to the current workflow", ResourceManager.getImageIcon(ResourceManager.TICK_ICON), JLabel.CENTER)); } else { return (new JLabel("<html><center>Taverna was unable to add selected " + TYPE.SOAPOperation.getTypeName() + " as a service to the current workflow.<br>This could be because the service is currently not accessible.</center></html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } catch (URISyntaxException e) { logger.error("Couldn't add " + TYPE.SOAPOperation + " to the current workflow", e); return (new JLabel( "<html>Could not add the selected " + TYPE.SOAPOperation.getTypeName() + " to the current workflow.<br>" + "Log file will containt additional details about this error.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } catch (Exception e) { logger.error("Failed to fetch required details to add this " + TYPE.SOAPOperation + " into the current workflow.", e); return (new JLabel( "<html>Failed to fetch required details to add this<br>" + TYPE.SOAPOperation.getTypeName() + " into the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } case RESTMethod: // received object may only contain limited data, therefore need to fetch full details first try { RestMethod restMethod = BioCatalogueClient.getInstance() .getBioCatalogueRestMethod(processorResource.getHref()); // actual import of the service into the workflow RESTFromBioCatalogueServiceDescription restServiceDescription = createRESTServiceDescriptionFromRESTMethod( restMethod); WorkflowView.importServiceDescription(restServiceDescription, false); // prepare result of the operation to be shown in the the waiting dialog window String warnings = extractWarningsFromRESTServiceDescription(restServiceDescription, false); JLabel outcomes = new JLabel( "<html>Selected " + TYPE.RESTMethod.getTypeName() + " was successfully added to the current workflow" + warnings + "</html>", ResourceManager.getImageIcon(warnings.length() > 0 ? ResourceManager.WARNING_ICON : ResourceManager.TICK_ICON), JLabel.CENTER); outcomes.setIconTextGap(20); return (outcomes); } catch (UnsupportedHTTPMethodException e) { logger.error(e); return (new JLabel(e.getMessage(), ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } catch (Exception e) { logger.error("Failed to fetch required details to add this " + TYPE.RESTMethod + " as a service to the current workflow.", e); return (new JLabel( "<html>Failed to fetch required details to add this " + TYPE.RESTMethod.getTypeName() + "<br>" + "as a service to the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } // type not currently supported, but maybe in the future? default: return (new JLabel( "Adding " + resourceType.getCollectionName() + " to the current workflow is not yet possible", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); } } // definitely not supported type return (new JLabel( "<html>It is not possible to add resources of the provided type<br>" + "into the current workflow.</html>", ResourceManager.getImageIcon(ResourceManager.ERROR_ICON), JLabel.CENTER)); }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java
/*********************************************************************************************** * Create the default Toolbar for a Chart. * * @param obsinstrument//from w w w. j av a2 s . co m * @param chart * @param title * @param fontdata * @param colourforeground * @param colourbackground * @param debug * * @return JToolBar */ public static JToolBar createDefaultToolbar(final ObservatoryInstrumentInterface obsinstrument, final ChartUIComponentPlugin chart, final String title, final FontInterface fontdata, final ColourInterface colourforeground, final ColourInterface colourbackground, final boolean debug) { final JToolBar toolbar; if ((obsinstrument != null) && (chart != null)) { final List<Component> listComponentsToAdd; final JLabel labelName; listComponentsToAdd = new ArrayList<Component>(10); //------------------------------------------------------------------------------------- // Initialise the Label labelName = new JLabel(title, RegistryModelUtilities.getAtomIcon(obsinstrument.getHostAtom(), ObservatoryInterface.FILENAME_ICON_CHART_VIEWER), SwingConstants.LEFT) { static final long serialVersionUID = 7580736117336162922L; // Enable Antialiasing in Java 1.5 protected void paintComponent(final Graphics graphics) { final Graphics2D graphics2D = (Graphics2D) graphics; // For antialiasing text graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); super.paintComponent(graphics2D); } }; labelName.setFont( fontdata.getFont().deriveFont(ReportTableHelper.SIZE_HEADER_FONT).deriveFont(Font.BOLD)); labelName.setForeground(colourforeground.getColor()); labelName.setIconTextGap(UIComponentPlugin.TOOLBAR_ICON_TEXT_GAP); listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR_BUTTON)); listComponentsToAdd.add(labelName); listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR)); listComponentsToAdd.add(Box.createHorizontalGlue()); UIComponentHelper.addToolbarPrintButtons(listComponentsToAdd, chart, chart.getChartPanel(), title, fontdata, colourforeground, colourbackground, debug); // Build the Toolbar using the Components, if any toolbar = UIComponentHelper.buildToolbar(listComponentsToAdd); } else { toolbar = new JToolBar(); } toolbar.setFloatable(false); toolbar.setMinimumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE); toolbar.setPreferredSize(UIComponentPlugin.DIM_TOOLBAR_SIZE); toolbar.setMaximumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE); toolbar.setBackground(colourbackground.getColor()); NavigationUtilities.updateComponentTreeUI(toolbar); return (toolbar); }
From source file:course_generator.frmMain.java
/** * Add a tab to JTabbedPane. The icon is at the left of the text and there * some space between the icon and the label * /*from www .j av a 2 s. c o m*/ * @param tabbedPane * JTabbedPane where we want to add the tab * @param tab * Tab to add * @param title * Title of the tab * @param icon * Icon of the tab */ private void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) { tabbedPane.add(tab); // Create bespoke component for rendering the tab. javax.swing.JLabel lbl = new javax.swing.JLabel(title); lbl.setIcon(icon); // Add some spacing between text and icon, and position text to the RHS. lbl.setIconTextGap(5); lbl.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl); }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes aboutDialog * //from w w w.j a va 2 s . c om * @return javax.swing.JDialog */ private JDialog getAboutDialog() { if (aboutDialog == null) { aboutDialog = new JDialog(getJFrame(), true); aboutDialog.setTitle(Messages.getString("GTDFree.About.Free")); //$NON-NLS-1$ Image i = ApplicationHelper.loadImage(ApplicationHelper.icon_name_large_logo); //$NON-NLS-1$ ImageIcon ii = new ImageIcon(i); JTabbedPane jtp = new JTabbedPane(); JPanel jp = new JPanel(); jp.setLayout(new GridBagLayout()); JLabel jl = new JLabel("GTD-Free", ii, SwingConstants.CENTER); //$NON-NLS-1$ jl.setIconTextGap(22); jl.setFont(jl.getFont().deriveFont((float) 24)); jp.add(jl, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0)); String s = "Version " + ApplicationHelper.getVersion(); //$NON-NLS-1$ jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 11, 4, 11), 0, 0)); s = Messages.getString("GTDFree.About.DBType") //$NON-NLS-1$ + getEngine().getGTDModel().getDataRepository().getDatabaseType(); jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 2, 11), 0, 0)); s = Messages.getString("GTDFree.About.DBloc") + getEngine().getDataFolder(); //$NON-NLS-1$ jp.add(new JLabel(s, SwingConstants.CENTER), new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 11, 4, 11), 0, 0)); jp.add(new JLabel("Copyright 2008,2009 ikesan@users.sourceforge.net", SwingConstants.CENTER), //$NON-NLS-1$ new GridBagConstraints(0, 4, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(11, 11, 11, 11), 0, 0)); jtp.addTab("About", jp); //$NON-NLS-1$ jp = new JPanel(); jp.setLayout(new GridBagLayout()); TableModel tm = new AbstractTableModel() { private static final long serialVersionUID = -8449423008172417278L; private String[] props; private String[] getProperties() { if (props == null) { props = System.getProperties().keySet().toArray(new String[System.getProperties().size()]); Arrays.sort(props); } return props; } @Override public String getColumnName(int column) { switch (column) { case 0: return Messages.getString("GTDFree.About.Prop"); //$NON-NLS-1$ case 1: return Messages.getString("GTDFree.About.Val"); //$NON-NLS-1$ default: return null; } } public int getColumnCount() { return 2; } public int getRowCount() { return getProperties().length; } public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return getProperties()[rowIndex]; case 1: return System.getProperty(getProperties()[rowIndex]); default: return null; } } }; JTable jt = new JTable(tm); jp.add(new JScrollPane(jt), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); jtp.addTab(Messages.getString("GTDFree.About.SysP"), jp); //$NON-NLS-1$ jp = new JPanel(); jp.setLayout(new GridBagLayout()); JTextArea ta = new JTextArea(); ta.setEditable(false); ta.setText(ApplicationHelper.loadLicense()); ta.setCaretPosition(0); jp.add(new JScrollPane(ta), new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 11, 11, 11), 0, 0)); jtp.addTab("License", jp); //$NON-NLS-1$ aboutDialog.setContentPane(jtp); aboutDialog.setSize(550, 300); //aboutDialog.pack(); aboutDialog.setLocationRelativeTo(getJFrame()); } return aboutDialog; }
From source file:org.interreg.docexplore.DocExploreTool.java
@SuppressWarnings("serial") protected static File askForHome(String text) { final File[] file = { null }; final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true); JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER, SwingConstants.TOP, true, false)); content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT); message.setIconTextGap(20); //message.setFont(Font.decode(Font.SANS_SERIF)); content.add(message);//from w w w . j a va 2 s . co m final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>")); final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore", 40); pathPanel.add(pathField); pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) { JNativeFileDialog nfd = null; public void actionPerformed(ActionEvent arg0) { if (nfd == null) { nfd = new JNativeFileDialog(); nfd.acceptFiles = false; nfd.acceptFolders = true; nfd.multipleSelection = false; nfd.title = XMLResourceBundle.getBundledString("homeLabel"); } nfd.setCurrentFile(new File(pathField.getText())); if (nfd.showOpenDialog()) pathField.setText(nfd.getSelectedFile().getAbsolutePath()); } })); content.add(pathPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) { public void actionPerformed(ActionEvent e) { File res = new File(pathField.getText()); if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs()) JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"), XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE); else { file[0] = res; dialog.setVisible(false); } } })); buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } })); content.add(buttonPanel); dialog.getContentPane().add(content); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); return file[0]; }
From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java
/** * helper method. creates tab labels with icons on the left side. *///from w ww . j a va 2 s. c o m private void addTab(Component tab, String title, Icon icon) { this.pane.add(tab); // Create bespoke component for rendering the tab. JLabel lbl = new JLabel(title); lbl.setIcon(icon); // Add some spacing between text and icon, and position text to the RHS. lbl.setIconTextGap(2); lbl.setHorizontalTextPosition(SwingConstants.RIGHT); this.pane.setTabComponentAt(this.pane.getTabCount() - 1, lbl); }
From source file:org.openconcerto.task.TodoListPanel.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*w w w . j av a 2 s . co m*/ label.setIcon(this.icon); label.setBorder(BorderFactory.createEmptyBorder()); label.setIconTextGap(0); label.setHorizontalTextPosition(0); label.setHorizontalAlignment(SwingConstants.CENTER); return label; }
From source file:org.owasp.jbrofuzz.update.StartUpdateChecker.java
/** * <p>//from w ww . jav a 2 s . co m * Main constructor that displays a JDialog if a new version is identified * on the website.</p. * * @param parent * JBroFuzzwindow the main window * * @author subere@uncon.org * @version 1.7 * @since 1.3 */ protected StartUpdateChecker(final JBroFuzzWindow parent) { super(parent, " JBroFuzz - New Version Available ", true); // Version comparison to see if we will display or dispose final double latest = StartUpdateChecker.getWebsiteVersion(); if (latest == StartUpdateChecker.ZERO_VERSION) { StartUpdateChecker.this.dispose(); return; } double current; try { current = Double.parseDouble(JBroFuzzFormat.VERSION); } catch (final NumberFormatException e1) { current = StartUpdateChecker.ZERO_VERSION; } if (latest <= current) { StartUpdateChecker.this.dispose(); return; } final String text = "<html><b>A new version of JBroFuzz is available: " + latest + "<br><br>You are currently running version: " + current + "<br><br>Do you wish to download the <br>new version now?" + "</b></html>"; setIconImage(ImageCreator.IMG_FRAME.getImage()); setLayout(new BorderLayout()); setFont(new Font("Verdana", Font.PLAIN, 12)); final JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 15)); final JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15)); // The about editor label final JLabel mainLabel = new JLabel(text, ImageCreator.IMG_OWASP, SwingConstants.LEFT); mainLabel.setIconTextGap(20); mainLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); centerPanel.add(mainLabel); // Bottom buttons final JButton download = new JButton("Download"); final JButton close = new JButton("Close"); southPanel.add(download); southPanel.add(close); // Action Listeners download.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent even) { SwingUtilities.invokeLater(new Runnable() { public void run() { Browser.init(); try { Browser.displayURL(JBroFuzzFormat.URL_WEBSITE); } catch (final IOException e) { System.out.println("An IOException occurred."); } StartUpdateChecker.this.dispose(); } }); } }); close.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent even) { SwingUtilities.invokeLater(new Runnable() { public void run() { StartUpdateChecker.this.dispose(); } }); } }); // Add the panels to the dialog getContentPane().add(centerPanel, BorderLayout.CENTER); getContentPane().add(southPanel, BorderLayout.SOUTH); // Global frame issues final int xLocation = parent.getLocationOnScreen().x - (StartUpdateChecker.SIZE_X / 2) + (parent.getWidth() / 2); final int yLocation = parent.getLocationOnScreen().y - (StartUpdateChecker.SIZE_Y / 2) + (parent.getHeight() / 2); setSize(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y); setLocation(xLocation, yLocation); setMinimumSize(new Dimension(StartUpdateChecker.SIZE_X, StartUpdateChecker.SIZE_Y)); setResizable(true); setVisible(true); }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
/** * Add a tab and ensure that the icon is to the left of the text in the * tab label.// www . j a v a 2 s . c o m * * @param title * @param icon * @param component */ private void addTab(String title, Texture icon, Component component) { int index = tabbedPane.getTabCount(); tabbedPane.add(title, component); if (icon != null) { JLabel lbl = new JLabel(title, icon.imageIcon(), SwingConstants.RIGHT); lbl.setIconTextGap(5); tabbedPane.setTabComponentAt(index, lbl); } }