List of usage examples for javax.swing JLabel getFont
@Transient
public Font getFont()
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Gets the width of a given label./*from w w w . j a v a 2 s .c om*/ */ public static int width(JLabel c) { FontMetrics fm = c.getFontMetrics(c.getFont()); return fm.stringWidth(c.getText()) + 3; }
From source file:labr_client.xml.ObjToXML.java
public static void saveProfile(Component[] comps, String profile) { try {//from w ww. j a va 2 s.co m if (comps != null) { JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); LabrRequest request = new LabrRequest(); for (Component comp : comps) { if (comp.getName() != null) { if (comp.getName().equals("name")) { request.patient.name.setValue(((JTextField) comp).getText()); request.patient.name.setX(comp.getX()); request.patient.name.setY(comp.getY()); request.patient.name.setWidth(comp.getWidth()); } else if (comp.getName().equals("firstName")) { request.patient.firstName.setValue(((JTextField) comp).getText()); request.patient.firstName.setX(comp.getX()); request.patient.firstName.setY(comp.getY()); request.patient.firstName.setWidth(comp.getWidth()); } else if (comp.getName().equals("birthDate")) { request.patient.birthDate.setValue(((JFormattedTextField) comp).getText()); request.patient.birthDate.setX(comp.getX()); request.patient.birthDate.setY(comp.getY()); request.patient.birthDate.setWidth(comp.getWidth()); } else if (comp.getName().equals("gender")) { request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.gender.setX(comp.getX()); request.patient.gender.setY(comp.getY()); } else if (comp.getName().equals("straatAndNumber")) { request.patient.straatAndNumber.setValue(((JTextField) comp).getText()); request.patient.straatAndNumber.setX(comp.getX()); request.patient.straatAndNumber.setY(comp.getY()); request.patient.straatAndNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("zip")) { request.patient.zip.setValue(((JTextField) comp).getText()); request.patient.zip.setX(comp.getX()); request.patient.zip.setY(comp.getY()); request.patient.zip.setWidth(comp.getWidth()); } else if (comp.getName().equals("city")) { request.patient.city.setValue(((JTextField) comp).getText()); request.patient.city.setX(comp.getX()); request.patient.city.setY(comp.getY()); request.patient.city.setWidth(comp.getWidth()); } else if (comp.getName().equals("country")) { request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.country.setX(comp.getX()); request.patient.country.setY(comp.getY()); } else if (comp.getName().equals("nationalNumber")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("Save")) { JButton jbut = (JButton) comp; ImageIcon icon = (ImageIcon) jbut.getIcon(); request.buttons.save.setX(comp.getX()); request.buttons.save.setY(comp.getY()); request.buttons.save.setValue("Save"); if (icon != null) { request.buttons.save.setIcon(icon.getDescription()); } } else if (comp.getName().equals("Search")) { } else if (comp.getName().equals("saveAndSend")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("print")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else { Class<? extends Component> c = comp.getClass(); if (c.getSimpleName().equals("JLabel")) { JLabel lbl = (JLabel) comp; LabrXMLLabel l = new LabrXMLLabel(); l.setColor(String.valueOf(lbl.getForeground().getRGB())); l.setSize(lbl.getFont().getSize()); l.setId(lbl.getName()); l.setValue(lbl.getText()); l.setX(lbl.getX()); l.setY(lbl.getY()); request.labels.getLabel().add(l); } ; if (c.getSimpleName().equals("JCheckBox")) { JCheckBox chbx = (JCheckBox) comp; LabrXMLRequest req = new LabrXMLRequest(); req.setX(chbx.getX()); req.setY(chbx.getY()); req.setLoinc(chbx.getName()); req.setValue(chbx.getText()); req.setSelected(chbx.isSelected()); request.requests.getRequest().add(req); } ; if (c.getSimpleName().equals("JTextBox")) { } ; } } } m.marshal(request, new File(PublicVars.getUserData()[9] + "\\" + profile + ".xml")); } } catch (JAXBException e) { e.printStackTrace(); } }
From source file:labr_client.xml.ObjToXML.java
public static LabrRequest saveLabrRequest(Component[] comps) { try {//from w ww . j a v a 2s. c o m if (comps != null) { JAXBContext context = JAXBContext.newInstance(LabrRequest.class); Marshaller m = context.createMarshaller(); //for pretty-print XML in JAXB m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); LabrRequest request = new LabrRequest(); for (Component comp : comps) { if (comp.getName() != null) { if (comp.getName().equals("name")) { request.patient.name.setValue(((JTextField) comp).getText()); request.patient.name.setX(comp.getX()); request.patient.name.setY(comp.getY()); request.patient.name.setWidth(comp.getWidth()); } else if (comp.getName().equals("firstName")) { request.patient.firstName.setValue(((JTextField) comp).getText()); request.patient.firstName.setX(comp.getX()); request.patient.firstName.setY(comp.getY()); request.patient.firstName.setWidth(comp.getWidth()); } else if (comp.getName().equals("birthDate")) { request.patient.birthDate.setValue(((JFormattedTextField) comp).getText()); request.patient.birthDate.setX(comp.getX()); request.patient.birthDate.setY(comp.getY()); request.patient.birthDate.setWidth(comp.getWidth()); } else if (comp.getName().equals("gender")) { request.patient.gender.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.gender.setX(comp.getX()); request.patient.gender.setY(comp.getY()); } else if (comp.getName().equals("straatAndNumber")) { request.patient.straatAndNumber.setValue(((JTextField) comp).getText()); request.patient.straatAndNumber.setX(comp.getX()); request.patient.straatAndNumber.setY(comp.getY()); request.patient.straatAndNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("zip")) { request.patient.zip.setValue(((JTextField) comp).getText()); request.patient.zip.setX(comp.getX()); request.patient.zip.setY(comp.getY()); request.patient.zip.setWidth(comp.getWidth()); } else if (comp.getName().equals("city")) { request.patient.city.setValue(((JTextField) comp).getText()); request.patient.city.setX(comp.getX()); request.patient.city.setY(comp.getY()); request.patient.city.setWidth(comp.getWidth()); } else if (comp.getName().equals("country")) { request.patient.country.setValue((String) (((JComboBox) comp).getSelectedItem())); request.patient.country.setX(comp.getX()); request.patient.country.setY(comp.getY()); } else if (comp.getName().equals("nationalNumber")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("Save")) { JButton jbut = (JButton) comp; ImageIcon icon = (ImageIcon) jbut.getIcon(); request.buttons.save.setX(comp.getX()); request.buttons.save.setY(comp.getY()); request.buttons.save.setValue("Save"); if (icon != null) { request.buttons.save.setIcon(icon.getDescription()); } } else if (comp.getName().equals("Search")) { } else if (comp.getName().equals("saveAndSend")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else if (comp.getName().equals("print")) { request.patient.nationalNumber.setValue(((JTextField) comp).getText()); request.patient.nationalNumber.setX(comp.getX()); request.patient.nationalNumber.setY(comp.getY()); request.patient.nationalNumber.setWidth(comp.getWidth()); } else { Class<? extends Component> c = comp.getClass(); if (c.getSimpleName().equals("JLabel")) { JLabel lbl = (JLabel) comp; LabrXMLLabel l = new LabrXMLLabel(); l.setColor(String.valueOf(lbl.getForeground().getRGB())); l.setSize(lbl.getFont().getSize()); l.setId(lbl.getName()); l.setValue(lbl.getText()); l.setX(lbl.getX()); l.setY(lbl.getY()); request.labels.getLabel().add(l); } ; if (c.getSimpleName().equals("JCheckBox")) { JCheckBox chbx = (JCheckBox) comp; LabrXMLRequest req = new LabrXMLRequest(); req.setX(chbx.getX()); req.setY(chbx.getY()); req.setLoinc(chbx.getName()); req.setValue(chbx.getText()); req.setSelected(chbx.isSelected()); request.requests.getRequest().add(req); } ; if (c.getSimpleName().equals("JTextBox")) { } ; } } } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmm"); String date = dateFormat.format(Calendar.getInstance().getTime()); request.attributes.setTitle("LABR-" + PublicVars.getUserData()[5] + "-" + date); return request; } return null; } catch (JAXBException e) { e.printStackTrace(); return null; } }
From source file:Main.java
private JLabel createLabel(String label) { JLabel jLabel = new JLabel(label); jLabel.setHorizontalAlignment(JLabel.CENTER); jLabel.setFont(jLabel.getFont().deriveFont(48.0f)); jLabel.setFocusable(true);/*ww w .ja va 2 s . c o m*/ return jLabel; }
From source file:com.sshtools.common.ui.SshToolsApplicationPanel.java
/** * Show an error message with toggable detail * * @param parent//from ww w.jav a 2 s. c om * @param mesg * @param title * @param exception */ public static void showErrorMessage(Component parent, String mesg, String title, Throwable exception) { boolean details = false; while (true) { String[] opts = new String[] { details ? "Hide Details" : "Details", "Ok" }; StringBuffer buf = new StringBuffer(); if (mesg != null) { buf.append(mesg); } appendException(exception, 0, buf, details); //MultilineLabel message = new MultilineLabel(buf.toString()); javax.swing.JTextArea message = new javax.swing.JTextArea(buf.toString()); message.setEditable(false); message.setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 4, 4, 4)); javax.swing.JLabel jl = new javax.swing.JLabel(); message.setFont(jl.getFont()); message.setBackground(jl.getBackground()); int opt = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, null, opts, opts[1]); if (opt == 0) { details = !details; } else { break; } } }
From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java
private void createInterface() { setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = 2;//from w w w .ja va 2 s . com constraints.gridx = 0; constraints.gridy = -1; constraints.weightx = 1.0D; add(Box.createGlue()); JLabel usernameLabel = new JLabel("Pseudo : "); Font labelFont = usernameLabel.getFont().deriveFont(1); Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F); usernameLabel.setFont(labelFont); add(usernameLabel, constraints); add(this.usernameField, constraints); add(Box.createVerticalStrut(10), constraints); JLabel passwordLabel = new JLabel("Mot de passe :"); passwordLabel.setFont(labelFont); add(passwordLabel, constraints); add(this.passwordField, constraints); JLabel forgotPasswordLabel = new JLabel("(oubli ?)"); forgotPasswordLabel.setCursor(new Cursor(12)); forgotPasswordLabel.setFont(smalltextFont); forgotPasswordLabel.setHorizontalAlignment(4); forgotPasswordLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { Util.openLink(Variables.lost); } catch (Exception e1) { LogInForm.this.login.getLauncher().getLogger() .error("Impossible d'ouvrir le lien pour les logins oublis"); JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(), "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants", "Impossible d'ouvrir l'URL", 0); } } }); add(forgotPasswordLabel, constraints); createUserDropdownPanel(labelFont); add(this.userDropdownPanel, constraints); add(Box.createVerticalStrut(10), constraints); }
From source file:com.aw.swing.mvp.grid.GridManager.java
private void configureGridTitleColor() { JPanel pnlGrid = ipView.getPnlGrid(gridIndex); pnlGrid.setBorder(BorderFactory.createLineBorder(new Color(131, 172, 219))); JPanel pnlTitGrid = ipView.getPnlTitGrid(gridIndex); pnlTitGrid.setBackground(new Color(131, 172, 219)); pnlTitGrid.setLayout(/*from w w w. j a v a 2 s .co m*/ new FormLayout("fill:16dlu:noGrow,left:4dlu:noGrow,fill:d:grow,left:4dlu:noGrow,right:pref:grow", "center:16dlu:noGrow")); JLabel lblTitGrid = ipView.getLblTitGrid(gridIndex); lblTitGrid.setFont(new Font(lblTitGrid.getFont().getName(), Font.BOLD, 14)); lblTitGrid.setForeground(Color.black); numRecords = new JLabel(""); numRecords.setFont(new Font(lblTitGrid.getFont().getName(), Font.BOLD, 14)); numRecords.setForeground(Color.black); numRecords.setVisible(showTotalRegistros); pnlTitGrid.remove(lblTitGrid); CellConstraints cc = new CellConstraints(); pnlTitGrid.add(lblTitGrid, cc.xy(3, 1)); pnlTitGrid.add(numRecords, cc.xy(5, 1)); }
From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java
@Override public CertificateAcceptance checkAcceptance(Certificate genericCert, CertificateException certError) { if (genericCert instanceof X509Certificate && defaultHostVerifier instanceof DefaultHostnameVerifier) { X509Certificate cert = (X509Certificate) genericCert; DefaultHostnameVerifier verifier = (DefaultHostnameVerifier) defaultHostVerifier; JPanel message = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 2;//from ww w . ja v a 2 s . c o m gbc.insets = new Insets(0, 0, 10, 0); gbc.anchor = GridBagConstraints.WEST; message.add( new JLabel("Unable to establish a secure connection because the certificate is not trusted"), gbc); gbc = new GridBagConstraints(); gbc.gridy = 2; gbc.insets = new Insets(2, 0, 2, 0); gbc.anchor = GridBagConstraints.WEST; JLabel issuer = new JLabel("Issuer: "); Font defaultFont = issuer.getFont(); Font bold = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize()); issuer.setFont(bold); message.add(issuer, gbc); gbc.gridx = 1; message.add(new JLabel(cert.getIssuerDN().toString()), gbc); try { JLabel fingerprint = new JLabel("Thumbprint: "); fingerprint.setFont(bold); gbc.gridx = 0; gbc.gridy += 1; message.add(fingerprint, gbc); gbc.gridx = 1; message.add(new JLabel(toHexString(getSHA1(cert.getEncoded()), " ")), gbc); } catch (CertificateEncodingException e) { // this shouldn't actually ever happen } try { verifier.verify(host, cert); } catch (SSLException e) { String cn = getCN(cert); JLabel mismatch = new JLabel("Host Mismatch: "); mismatch.setFont(bold); gbc.gridx = 0; gbc.gridy += 1; message.add(mismatch, gbc); String msg; if (cn != null) { msg = String.format("Expected '%s', but the certificate is for '%s'.", host, cn); } else { msg = e.getMessage(); } gbc.gridx = 1; message.add(new JLabel(msg), gbc); } // Open the dialog, and return its result int choice = JOptionPane.showOptionDialog(burpExtender.getUiComponent(), message, dialogTitle, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, dialogButtons, null); switch (choice) { case (0): return CertificateAcceptance.REJECT; case (1): return CertificateAcceptance.ACCEPT_TEMPORARILY; case (2): return CertificateAcceptance.ACCEPT_PERMANENTLY; } } return CertificateAcceptance.REJECT; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ImportDataFileInfo.java
/** * shows modified (truncated) data after import */// w w w . j av a 2 s . c o m protected void showModifiedData() { if (importer.getTruncations().size() > 0) { JPanel mainPane = new JPanel(new BorderLayout()); JLabel msg = createLabel(getResourceString("WB_TRUNCATIONS")); msg.setFont(msg.getFont().deriveFont(Font.BOLD)); mainPane.add(msg, BorderLayout.NORTH); String[] heads = new String[3]; String[][] vals = new String[importer.getTruncations().size()][3]; heads[0] = getResourceString("WB_ROW"); heads[1] = getResourceString("WB_COLUMN"); heads[2] = getResourceString("WB_TRUNCATED"); int row = 0; for (DataImportTruncation trunc : importer.getTruncations()) { vals[row][0] = String.valueOf(trunc.getRow()); vals[row][1] = trunc.getColHeader(); if (vals[row][1].equals("")) { vals[row][1] = String.valueOf(trunc.getCol() + 1); } vals[row++][2] = trunc.getExcluded(); } JTable mods = new JTable(vals, heads); mods.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); mainPane.add(UIHelper.createScrollPane(mods), BorderLayout.CENTER); CustomFrame cwin = new CustomFrame(getResourceString(MODIFIED_IMPORT_DATA), CustomFrame.OKHELP, mainPane); cwin.setHelpContext("WorkbenchImportData"); //help context could be more specific cwin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); UIHelper.centerAndShow(cwin); } if (importer.getMessages().size() > 0) { JPanel mainPane = new JPanel(new BorderLayout()); JTextArea msgs = new JTextArea(); msgs.setRows(importer.getMessages().size()); for (String msg : importer.getMessages()) { msgs.append(msg); msgs.append("\n"); } mainPane.add(msgs, BorderLayout.CENTER); CustomFrame cwin = new CustomFrame(getResourceString(MODIFIED_IMPORT_DATA), CustomFrame.OKHELP, mainPane); cwin.setHelpContext("WorkbenchImportData"); //help context could be more specific cwin.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); UIHelper.centerAndShow(cwin); } }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrProjectPanelVisual2.java
/** * Fixes the boot version of the dependencies. * <p>//from w w w . j a v a2s .co m * Does nothing if the panel has not been initialized. * * @param bootVersion */ public void fixBootVersion(String bootVersion) { Objects.requireNonNull(bootVersion); if (initialized) { // substitute combo with label javax.swing.GroupLayout layout = (javax.swing.GroupLayout) this.getLayout(); final JLabel label = new JLabel(bootVersion); label.setFont(label.getFont().deriveFont(Font.BOLD)); layout.replace(cbBootVersion, label); // adapt dependencies panel pBootDependencies.adaptToBootVersion(bootVersion); } }