List of usage examples for javax.swing JLabel setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java
private JPanel createGeneralTab() { JPanel jpGeneral = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // All components to be anchored WEST c.anchor = GridBagConstraints.WEST; c.gridx = 0;//from ww w .j ava 2 s. c om c.gridy = 0; c.gridwidth = 1; c.insets = new Insets(7, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; JLabel labelMethod = new JLabel("HTTP Method:", infoIcon, JLabel.LEFT); labelMethod.setToolTipText( "<html>HTTP method determines how a request to the remote server will be made.<br><br>" + "Supported HTTP methods are normally used for different purposes:<br>" + "<b>GET</b> - to fetch data;<br>" + "<b>POST</b> - to create new resources;<br>" + "<b>PUT</b> - to update existing resources;<br>" + "<b>DELETE</b> - to remove existing resources.<br><br>" + "Documentation of the server that is about to be used may suggest the<br>" + "HTTP method that should be used.</html>"); jpGeneral.add(labelMethod, c); // the HTTP method combo-box will always contain the same values - it is // the selected // method which is important; therefore, can prepopulate as the set of // values is known c.gridx++; c.insets = new Insets(7, 3, 3, 7); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; cbHTTPMethod = new JComboBox<>(HTTP_METHOD.values()); cbHTTPMethod.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean contentTypeSelEnabled = RESTActivity .hasMessageBodyInputPort((HTTP_METHOD) cbHTTPMethod.getSelectedItem()); jlContentTypeExplanation.setVisible(contentTypeSelEnabled); jlContentType.setVisible(contentTypeSelEnabled); cbContentType.setVisible(contentTypeSelEnabled); jlSendDataAs.setVisible(contentTypeSelEnabled); cbSendDataAs.setVisible(contentTypeSelEnabled); jlContentTypeExplanationPlaceholder.setVisible(!contentTypeSelEnabled); jlContentTypeLabelPlaceholder.setVisible(!contentTypeSelEnabled); jlContentTypeFieldPlaceholder.setVisible(!contentTypeSelEnabled); jlSendDataAsLabelPlaceholder.setVisible(!contentTypeSelEnabled); jlSendDataAsFieldPlaceholder.setVisible(!contentTypeSelEnabled); } }); jpGeneral.add(cbHTTPMethod, c); c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.fill = GridBagConstraints.NONE; c.weightx = 0.0; JLabel labelString = new JLabel("URL Template:", infoIcon, JLabel.LEFT); labelString.setToolTipText("<html>URL template enables to define a URL with <b>configurable<br>" + "parameters</b> that will be used to access a remote server.<br><br>" + "The template may contain zero or more <b>parameters</b> - each<br>" + "enclosed within curly braces <b>\"{\"</b> and <b>\"}\"</b>.<br>" + "Taverna will automatically create an individual input port for<br>" + "this activity for each parameter.<br><br>" + "Values extracted from these input ports during the workflow<br>" + "execution these will be used to replace the parameters to<br>" + "produce complete URLs.<br><br>" + "For example, if the URL template is configured as<br>" + "\"<i>http://www.myexperiment.org/user.xml?id={userID}</i>\", a<br>" + "single input port with the name \"<i>userID</i>\" will be created.</html>"); labelString.setLabelFor(tfURLSignature); jpGeneral.add(labelString, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; tfURLSignature = new JTextField(40); tfURLSignature.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { tfURLSignature.selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); jpGeneral.add(tfURLSignature, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; c.insets = new Insets(18, 7, 3, 7); JLabel jlAcceptsExplanation = new JLabel( "Preferred MIME type for data to be fetched from the remote server --"); jpGeneral.add(jlAcceptsExplanation, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; JLabel jlAccepts = new JLabel("'Accept' header:", infoIcon, JLabel.LEFT); jlAccepts.setToolTipText( "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</br>"); jlAccepts.setLabelFor(cbAccepts); jpGeneral.add(jlAccepts, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbAccepts = new JComboBox<>(getMediaTypes()); cbAccepts.setEditable(true); cbAccepts.getEditor().getEditorComponent().addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { cbAccepts.getEditor().selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); jpGeneral.add(cbAccepts, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.insets = new Insets(18, 7, 3, 7); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeExplanation = new JLabel("MIME type of data that will be sent to the remote server --"); jpGeneral.add(jlContentTypeExplanation, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentType = new JLabel("'Content-Type' header:", infoIcon, JLabel.LEFT); jlContentType.setToolTipText( "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</html>"); jlContentType.setLabelFor(cbContentType); jpGeneral.add(jlContentType, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbContentType = new JComboBox<>(getMediaTypes()); cbContentType.setEditable(true); cbContentType.getEditor().getEditorComponent().addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { cbContentType.getEditor().selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); cbContentType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // change selection in the "Send data as" combo-box, based on // the selection of Content-Type String selectedContentType = (String) cbContentType.getSelectedItem(); if (selectedContentType.startsWith("text")) { cbSendDataAs.setSelectedItem(DATA_FORMAT.String); } else { cbSendDataAs.setSelectedItem(DATA_FORMAT.Binary); } } }); jpGeneral.add(cbContentType, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.insets = new Insets(18, 7, 3, 7); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeExplanationPlaceholder = new JLabel(); jlContentTypeExplanationPlaceholder.setPreferredSize(jlContentTypeExplanation.getPreferredSize()); jpGeneral.add(jlContentTypeExplanationPlaceholder, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeLabelPlaceholder = new JLabel(); jlContentTypeLabelPlaceholder.setPreferredSize(jlContentType.getPreferredSize()); jpGeneral.add(jlContentTypeLabelPlaceholder, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; jlContentTypeFieldPlaceholder = new JLabel(); jlContentTypeFieldPlaceholder.setPreferredSize(cbContentType.getPreferredSize()); jpGeneral.add(jlContentTypeFieldPlaceholder, c); c.gridx = 0; c.gridy++; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; c.insets = new Insets(3, 7, 8, 3); jlSendDataAs = new JLabel("Send data as:", infoIcon, JLabel.LEFT); jlSendDataAs.setToolTipText("Select the format for the data to be sent to the remote server"); jlSendDataAs.setLabelFor(cbSendDataAs); jpGeneral.add(jlSendDataAs, c); c.gridx++; c.insets = new Insets(3, 3, 8, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbSendDataAs = new JComboBox<>(DATA_FORMAT.values()); cbSendDataAs.setEditable(false); jpGeneral.add(cbSendDataAs, c); c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 8, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlSendDataAsLabelPlaceholder = new JLabel(); jlSendDataAsLabelPlaceholder.setPreferredSize(jlSendDataAs.getPreferredSize()); jpGeneral.add(jlSendDataAsLabelPlaceholder, c); c.gridx++; c.insets = new Insets(3, 3, 8, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; jlSendDataAsFieldPlaceholder = new JLabel(); jlSendDataAsFieldPlaceholder.setPreferredSize(cbSendDataAs.getPreferredSize()); jpGeneral.add(jlSendDataAsFieldPlaceholder, c); JPanel finalPanel = new JPanel(new BorderLayout()); finalPanel.add(jpGeneral, BorderLayout.NORTH); return (finalPanel); }
From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java
private void buildLibraryPanel(final String libraryName) { ActionListener nameChkAL = new ActionListener() { @Override// w ww . j a va 2 s. com public void actionPerformed(ActionEvent e) { if (((CompactCheckBox) e.getSource()).isSelected()) { if (!Ctx.cfgSetup.libraries.contains(libraryName)) Ctx.cfgSetup.libraries.add(libraryName); if (!Ctx.cfgUpdate.libraries.contains(libraryName)) Ctx.cfgUpdate.libraries.add(libraryName); } else { Ctx.cfgSetup.libraries.remove(libraryName); Ctx.cfgUpdate.libraries.remove(libraryName); } Ctx.fireCfgSetupChanged(); Ctx.fireCfgUpdateChanged(); } }; Action infoAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showInfo(libraryName); } }; Action browseAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { browse(libraryName); } }; Action getStableAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getStable(libraryName); } }; Action getLatestAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getLatest(libraryName); } }; LibraryDef def = Ctx.libs.getDef(libraryName); CompactCheckBox nameChk = new CompactCheckBox(def.name + " "); JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png")); JButton infoBtn = new JButton(infoAction); JButton browseBtn = new JButton(browseAction); JButton getStableBtn = new JButton(getStableAction); JButton getLatestBtn = new JButton(getLatestAction); nameChk.addActionListener(nameChkAL); nameChk.setForeground(LIB_NOTFOUND_COLOR); html5Label.setToolTipText("Compatible with HTML backend"); infoBtn.setIcon(Res.getImage("gfx/ic_info.png")); browseBtn.setIcon(Res.getImage("gfx/ic_browse.png")); getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png")); getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png")); infoBtn.setFocusable(false); browseBtn.setFocusable(false); getStableBtn.setFocusable(false); getLatestBtn.setFocusable(false); JToolBar toolBar = new JToolBar(); toolBar.setOpaque(false); toolBar.setFloatable(false); toolBar.add(Box.createHorizontalGlue()); toolBar.add(infoBtn); toolBar.add(browseBtn); if (def.stableUrl != null) toolBar.add(getStableBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width)); if (def.latestUrl != null) toolBar.add(getLatestBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width)); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setOpaque(false); leftPanel.add(nameChk, BorderLayout.CENTER); if (def.gwtModuleName != null) leftPanel.add(html5Label, BorderLayout.EAST); JPanel panel = new JPanel(new BorderLayout()); panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); panel.setOpaque(false); panel.add(leftPanel, BorderLayout.WEST); panel.add(toolBar, BorderLayout.CENTER); librariesPanel.add(panel); Style.apply(librariesPanel, style); libsNamesCmps.put(libraryName, nameChk); }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java
public NumberComposite() { setName("Number to Composite"); // System.out.println("Created a new NumberComposite"); setDescription("A renderer that can be used to assign renderers to different aggregations"); configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;/*from w w w . j av a 2s.co m*/ c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(2, 2, 2, 2); c.gridwidth = 1; //This combo box will need to be able to add registered singleComboBox = new JComboBox(); rowComboBox = new JComboBox(); columnComboBox = new JComboBox(); rowColumnComboBox = new JComboBox(); singleLegend = new JLabel(); rowLegend = new JLabel(); columnLegend = new JLabel(); rowColumnLegend = new JLabel(); singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); //Add them JLabel label = new JLabel("Default:"); label.setToolTipText("Default renderer"); c.gridx = 0; c.gridy++; configUI.add(label, c); c.gridx = 1; configUI.add(singleComboBox, c); singleComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 2; JButton config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (singleRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(singleLegend, c); ////////////////////////////////////////////////////////////// c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row Group:"); label.setToolTipText("Renderer for row ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowLegend, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Column Group:"); label.setToolTipText("Renderer for column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(columnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (columnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), columnGroupRenderer.getConfigUI(), "Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(columnLegend, c); columnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row & Column Group:"); label.setToolTipText("Renderer for row and column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowColumnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowColumnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowColumnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowColumnLegend, c); JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateRenderer(); } }); c.gridx = 0; c.gridy++; c.gridwidth = 2; configUI.add(button, c); singleComboBox.setRenderer(new ComboRenderer()); rowComboBox.setRenderer(new ComboRenderer()); columnComboBox.setRenderer(new ComboRenderer()); rowColumnComboBox.setRenderer(new ComboRenderer()); _updateLists(); }
From source file:lcmc.common.ui.EditableInfo.java
/** Adds jlabel field with tooltip. */ public final void addLabelField(final JPanel panel, final String left, final String right, final int leftWidth, final int rightWidth, final int height) { final JLabel leftLabel = new JLabel(left); leftLabel.setToolTipText(left); final JLabel rightLabel = new JLabel(right); rightLabel.setToolTipText(right);//from ww w . j a v a 2 s.co m addField(panel, leftLabel, rightLabel, leftWidth, rightWidth, height); }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
/** * Create the panel.//from www .j a v a2s.co m */ private JPanel createloginPanelV2() { JPanel contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(36, 36, 36, 36)); contentPane.setLayout(null); JPanel loginUserPanel = new JPanel(); loginUserPanel.setBounds(40, 91, 825, 306); contentPane.add(loginUserPanel); loginUserPanel .setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(153, 180, 209), null), "", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 120, 215))); loginUserPanel.setLayout(null); JLabel lblNewLabel_1 = new JLabel("User Name"); lblNewLabel_1.setBounds(70, 80, 118, 36); loginUserPanel.add(lblNewLabel_1); JButton submitBtn = new JButton(SubmitBtnLbl); submitBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { userId = userNameFld.getText(); password = passwdFld.getText(); if ((userId.length() < 1) || (password.length() < 1)) { setStatus(statusLbl, "Please enter a valid user name and password.", Color.red); } else { setStatus(statusLbl, "Checking your access permission...", Color.blue); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { submitRequest(userId, password); } }); } } }); submitBtn.setBounds(606, 238, 140, 36); loginUserPanel.add(submitBtn); userNameFld = new JTextField(); userNameFld.setBounds(200, 80, 333, 36); loginUserPanel.add(userNameFld); userNameFld.setColumns(10); JLabel lblPassword = new JLabel("Password"); lblPassword.setBounds(70, 156, 118, 36); loginUserPanel.add(lblPassword); passwdFld = new JPasswordField(); passwdFld.setBounds(200, 156, 333, 36); loginUserPanel.add(passwdFld); statusLbl = new JLabel(""); statusLbl.setBounds(70, 226, 524, 36); statusLbl.setFont(new Font("SansSerif", Font.PLAIN, 13)); statusLbl.setVerticalAlignment(SwingConstants.BOTTOM); loginUserPanel.add(statusLbl); JLabel versionLabel = new JLabel("Release " + DownloaderProperties.getAppVersion() + " Build \"" + DownloaderProperties.getBuildTime() + "\""); versionLabel.setHorizontalAlignment(SwingConstants.CENTER); versionLabel.setForeground(new Color(70, 130, 180)); versionLabel.setBounds(318, 427, 266, 20); contentPane.add(versionLabel); JLabel infoLbl = new JLabel( "This download contains restricted data. Log in or contact the help desk for access."); infoLbl.setForeground(new Color(105, 105, 105)); infoLbl.setFont(new Font("SansSerif", Font.BOLD, 13)); infoLbl.setBounds(40, 34, 796, 42); contentPane.add(infoLbl); JLabel helpDeskLbl; helpDeskLbl = new JLabel(); ImageIcon image = new ImageIcon(this.getClass().getClassLoader().getResource("info.png")); helpDeskLbl = new JLabel(image); helpDeskLbl.setToolTipText("Click to get phone number/email address of the Help Desk."); helpDeskLbl.setBounds(826, 20, 36, 36); contentPane.add(helpDeskLbl); helpDeskLbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.out.println("mouse clicked"); //BrowserLauncher.openUrl(DownloaderProperties.getHelpDeskUrl()); BrowserLauncher.openUrlForHelpDesk(); } }); userNameFld.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { passwdFld.requestFocus(); } }); userNameFld.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { statusLbl.setText(""); } @Override public void focusLost(FocusEvent e) { } }); passwdFld.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { userId = userNameFld.getText(); password = passwdFld.getText(); if ((userId.length() < 1) || (password.length() < 1)) { setStatus(statusLbl, "Please enter a valid user name and password.", Color.red); } else { setStatus(statusLbl, "Checking your access permission...", Color.blue); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { submitRequest(userId, password); } }); } } }); passwdFld.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { statusLbl.setText(""); } @Override public void focusLost(FocusEvent e) { } }); return contentPane; }
From source file:gate.gui.docview.AnnotationStack.java
/** * Draw the annotation stack in a JPanel with a GridBagLayout. *//*w w w .ja va 2 s . com*/ public void drawStack() { // clear the panel removeAll(); boolean textTooLong = text.length() > maxTextLength; int upperBound = text.length() - (maxTextLength / 2); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; /********************** * First row of text * *********************/ gbc.gridwidth = 1; gbc.insets = new java.awt.Insets(10, 10, 10, 10); JLabel labelTitle = new JLabel("Context"); labelTitle.setOpaque(true); labelTitle.setBackground(Color.WHITE); labelTitle.setBorder(new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); labelTitle.setToolTipText("Expression and its context."); add(labelTitle, gbc); gbc.insets = new java.awt.Insets(10, 0, 10, 0); int expressionStart = contextBeforeSize; int expressionEnd = text.length() - contextAfterSize; // for each character for (int charNum = 0; charNum < text.length(); charNum++) { gbc.gridx = charNum + 1; if (textTooLong) { if (charNum == maxTextLength / 2) { // add ellipsis dots in case of a too long text displayed add(new JLabel("..."), gbc); // skip the middle part of the text if too long charNum = upperBound + 1; continue; } else if (charNum > upperBound) { gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } } // set the text and color of the feature value JLabel label = new JLabel(text.substring(charNum, charNum + 1)); if (charNum >= expressionStart && charNum < expressionEnd) { // this part is matched by the pattern, color it label.setBackground(new Color(240, 201, 184)); } else { // this part is the context, no color label.setBackground(Color.WHITE); } label.setOpaque(true); // get the word from which belongs the current character charNum int start = text.lastIndexOf(" ", charNum); int end = text.indexOf(" ", charNum); String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end); // add a mouse listener that modify the query label.addMouseListener(textMouseListener.createListener(word)); add(label, gbc); } /************************************ * Subsequent rows with annotations * ************************************/ // for each row to display for (StackRow stackRow : stackRows) { String type = stackRow.getType(); String feature = stackRow.getFeature(); if (feature == null) { feature = ""; } String shortcut = stackRow.getShortcut(); if (shortcut == null) { shortcut = ""; } gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.insets = new Insets(0, 0, 3, 0); // add the header of the row JLabel annotationTypeAndFeature = new JLabel(); String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature; annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature); annotationTypeAndFeature.setOpaque(true); annotationTypeAndFeature.setBackground(Color.WHITE); annotationTypeAndFeature .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); if (feature.equals("")) { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type)); } else { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature)); } gbc.insets = new java.awt.Insets(0, 10, 3, 10); add(annotationTypeAndFeature, gbc); gbc.insets = new java.awt.Insets(0, 0, 3, 0); // add all annotations for this row HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>(); int gridyMax = gbc.gridy; for (StackAnnotation ann : stackRow.getAnnotations()) { gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize + 1; gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue(); if (gbc.gridx == 0) { // column 0 is already the row header gbc.gridwidth -= 1; gbc.gridx = 1; } else if (gbc.gridx < 0) { // annotation starts before displayed text gbc.gridwidth += gbc.gridx - 1; gbc.gridx = 1; } if (gbc.gridx + gbc.gridwidth > text.length()) { // annotation ends after displayed text gbc.gridwidth = text.length() - gbc.gridx + 1; } if (textTooLong) { if (gbc.gridx > (upperBound + 1)) { // x starts after the hidden middle part gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } else if (gbc.gridx > (maxTextLength / 2)) { // x starts in the hidden middle part if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) { // x ends in the hidden middle part continue; // skip the middle part of the text } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - gbc.gridx + 2; gbc.gridx = (maxTextLength / 2) + 2; } } else { // x starts before the hidden middle part if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) { // x ends before the hidden middle part // do nothing } else if (gbc.gridx + gbc.gridwidth < upperBound) { // x ends in the hidden middle part gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1; } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1; } } } if (gbc.gridwidth == 0) { gbc.gridwidth = 1; } JLabel label = new JLabel(); Object object = ann.getFeatures().get(feature); String value = (object == null) ? " " : Strings.toString(object); if (value.length() > maxFeatureValueLength) { // show the full text in the tooltip label.setToolTipText((value.length() > 500) ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">" + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>" : ((value.length() > 100) ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>" + value.replaceAll("\n", "<br>") + "</td></tr></table></html>" : value)); if (stackRow.getCrop() == CROP_START) { value = "..." + value.substring(value.length() - maxFeatureValueLength - 1); } else if (stackRow.getCrop() == CROP_END) { value = value.substring(0, maxFeatureValueLength - 2) + "..."; } else {// cut in the middle value = value.substring(0, maxFeatureValueLength / 2) + "..." + value.substring(value.length() - (maxFeatureValueLength / 2)); } } label.setText(value); label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType())); label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); label.setOpaque(true); label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, String.valueOf(ann.getId()))); // show the feature values in the tooltip if (!ann.getFeatures().isEmpty()) { String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%"; String toolTip = "<html><table width=\"" + width + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"; Color color = (Color) UIManager.get("ToolTip.background"); float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen()) + Integer.toHexString(color.getBlue()); boolean odd = false; // alternate background color every other row List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet()); //sort the features into alphabetical order Collections.sort(features, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { return o1.toString().compareToIgnoreCase(o2.toString()); } }); for (Object key : features) { String fv = Strings.toString(ann.getFeatures().get(key)); toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "") + "><td><strong>" + key + "</strong></td><td>" + ((fv.length() > 500) ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>" : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>")) + "</td></tr>"; odd = !odd; } label.setToolTipText(toolTip + "</table></html>"); } else { label.setToolTipText("No features."); } if (!feature.equals("")) { label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature, Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId()))); } // find the first empty row span for this annotation int oldGridy = gbc.gridy; for (int y = oldGridy; y <= (gridyMax + 1); y++) { // for each cell of this row where spans the annotation boolean xSpanIsEmpty = true; for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) { xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y)); } if (xSpanIsEmpty) { gbc.gridy = y; break; } } // save the column x and row y of the current value TreeSet<Integer> ts; for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) { ts = gridSet.get(x); if (ts == null) { ts = new TreeSet<Integer>(); } ts.add(gbc.gridy); gridSet.put(x, ts); } add(label, gbc); gridyMax = Math.max(gridyMax, gbc.gridy); gbc.gridy = oldGridy; } // add a button at the end of the row gbc.gridwidth = 1; if (stackRow.getLastColumnButton() != null) { // last cell of the row gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.insets = new Insets(0, 10, 3, 0); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; add(stackRow.getLastColumnButton(), gbc); gbc.insets = new Insets(0, 0, 3, 0); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; } // set the new gridy to the maximum row we put a value gbc.gridy = gridyMax; } if (lastRowButton != null) { // add a configuration button on the last row gbc.insets = new java.awt.Insets(0, 10, 0, 10); gbc.gridx = 0; gbc.gridy++; add(lastRowButton, gbc); } // add an empty cell that takes all remaining space to // align the visible cells at the top-left corner gbc.gridy++; gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 1; add(new JLabel(""), gbc); validate(); updateUI(); }
From source file:edu.harvard.i2b2.query.ui.QueryTopPanel.java
public void addPanel() { int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override//from w ww. jav a 2 s . com public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); // jPanel1.add(label); // label.setBounds(rightmostPosition, 90, 30, 18); QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:edu.harvard.i2b2.query.ui.QueryTopPanel.java
private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) { if (dataModel.hasEmptyPanels()) { JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one."); return;/*ww w. jav a2s.com*/ } int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); /* * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":" * + jScrollPane4.getViewport().getExtentSize().height); * System.out.println * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":" * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height); * System * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount * ()); * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue()); */ jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); // this.jScrollPane4.removeAll(); // this.jScrollPane4.setViewportView(jPanel1); // revalidate(); // jScrollPane3.setBounds(420, 0, 170, 300); // jScrollPane4.setBounds(20, 35, 335, 220); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:davmail.ui.SettingsFrame.java
protected void addSettingComponent(JPanel panel, String label, JComponent component, String toolTipText) { JLabel fieldLabel = new JLabel(label); fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT); fieldLabel.setVerticalAlignment(SwingConstants.CENTER); panel.add(fieldLabel);/* w w w .j a v a 2s . c om*/ component.setMaximumSize(component.getPreferredSize()); JPanel innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); innerPanel.add(component); panel.add(innerPanel); if (toolTipText != null) { fieldLabel.setToolTipText(toolTipText); component.setToolTipText(toolTipText); } }
From source file:lcmc.common.ui.EditableInfo.java
/** Adds parameters to the panel. */ private void addParams(final JPanel optionsPanel, final String prefix, final String[] params, final MyButton thisApplyButton, final int leftWidth, final int rightWidth, final Map<String, Widget> sameAsFields) { swingUtils.isSwingThread();// www . j av a 2 s. c o m if (params == null) { return; } final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>(); final Collection<PanelPart> panelPartsList = new ArrayList<PanelPart>(); final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>(); for (final String param : params) { final Widget paramWi = createWidget(param, prefix, rightWidth); /* sub panel */ final String section = getSection(param); final JPanel panel; final AccessMode.Type accessType = getAccessType(param); final String accessTypeString = accessType.toString(); final Boolean advanced = isAdvanced(param); final String advancedString = advanced.toString(); if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) { panel = panelPartsMap.get(section, accessTypeString, advancedString); panelPartRowsMap.put(section, accessTypeString, advancedString, panelPartRowsMap.get(section, accessTypeString, advancedString) + 1); } else { panel = new JPanel(new SpringLayout()); panel.setBackground(getSectionColor(section)); if (advanced) { advancedPanelList.add(panel); panel.setVisible(access.isAdvancedMode()); } panelPartsMap.put(section, accessTypeString, advancedString, panel); panelPartsList.add(new PanelPart(section, accessType, advanced)); panelPartRowsMap.put(section, accessTypeString, advancedString, 1); } /* label */ final JLabel label = new JLabel(getParamShortDesc(param)); final String longDesc = getParamLongDesc(param); paramWi.setLabel(label, longDesc); /* tool tip */ paramWi.setToolTipText(getToolTipText(param, paramWi)); label.setToolTipText(longDesc + additionalToolTip(param)); int height = 0; if (paramWi instanceof Label) { height = application.getDefaultSize("Browser.LabelFieldHeight"); } addField(panel, label, paramWi.getComponent(), leftWidth, rightWidth, height); } final boolean wizard = Widget.WIZARD_PREFIX.equals(prefix); for (final String param : params) { final Widget paramWi = getWidget(param, prefix); if (wizard) { final Widget rpwi = getWidget(param, null); if (rpwi == null) { LOG.error("addParams: unknown param: " + param); continue; } if (paramWi.getValue() == null || paramWi.getValue().isNothingSelected()) { rpwi.setValueAndWait(null); } else { final Value value = paramWi.getValue(); rpwi.setValueAndWait(value); } } } for (final String param : params) { final Widget paramWi = getWidget(param, prefix); Widget rpwi = null; if (wizard) { rpwi = getWidget(param, null); } final Widget realParamWi = rpwi; paramWi.addListeners(new WidgetListener() { @Override public void check(final Value value) { checkParameterFields(paramWi, realParamWi, param, getParametersFromXML(), thisApplyButton); } }); } /* add sub panels to the option panel */ final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>(); final Collection<JPanel> notAdvancedSections = new HashSet<JPanel>(); final Collection<JPanel> advancedSections = new HashSet<JPanel>(); for (final PanelPart panelPart : panelPartsList) { final String section = panelPart.getSection(); final AccessMode.Type accessType = panelPart.getType(); final String accessTypeString = accessType.toString(); final Boolean advanced = panelPart.isAdvanced(); final String advancedString = advanced.toString(); final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString); final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString); final int columns = 2; SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY 1, 1); // xPad, yPad final JPanel sectionPanel; if (sectionMap.containsKey(section)) { sectionPanel = sectionMap.get(section); } else { sectionPanel = getParamPanel(getSectionDisplayName(section), getSectionColor(section)); sectionMap.put(section, sectionPanel); addSectionPanel(section, wizard, sectionPanel); optionsPanel.add(sectionPanel); if (sameAsFields != null) { final Widget sameAsCombo = sameAsFields.get(section); if (sameAsCombo != null) { final JPanel saPanel = new JPanel(new SpringLayout()); saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND); final JLabel label = new JLabel(Tools.getString("ClusterBrowser.SameAs")); sameAsCombo.setLabel(label, ""); addField(saPanel, label, sameAsCombo.getComponent(), leftWidth, rightWidth, 0); SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY 1, 1); // xPad, yPad sectionPanel.add(saPanel); } } } sectionPanel.setVisible(isSectionEnabled(section)); sectionPanel.add(panel); if (advanced) { advancedSections.add(sectionPanel); } else { notAdvancedSections.add(sectionPanel); } } boolean advanced = false; for (final Map.Entry<String, JPanel> sectionEntry : sectionMap.entrySet()) { final JPanel sectionPanel = sectionEntry.getValue(); if (advancedSections.contains(sectionPanel)) { advanced = true; } if (!notAdvancedSections.contains(sectionPanel)) { advancedOnlySectionList.add(sectionEntry.getKey()); sectionPanel.setVisible(access.isAdvancedMode() && isSectionEnabled(sectionEntry.getKey())); } } moreOptionsPanel.setVisible(advanced && !access.isAdvancedMode()); }