List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:es.emergya.ui.gis.popups.GPSDialog.java
public GPSDialog(Recurso r) { super();//from w w w .j a v a 2s .c o m setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_actualizando"); target = r; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.gps.titleBar") + " " + target.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.gps.title"), LogicConstants.getIcon("tittleventana_icon_actualizargps"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("PLACEHOLDER"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); actualizar = new JButton(i18n.getString("window.gps.button.actualizar"), LogicConstants.getIcon("ventanacontextual_button_solicitargps")); actualizar.addActionListener(this); buttons.add(actualizar); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosing(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (last_bandejaSalida != null) { MessageGenerator.remove(last_bandejaSalida.getId()); } return null; } @Override protected void done() { super.done(); GPSDialog.this.progressIcon.setIcon(iconTransparente); GPSDialog.this.progressIcon.repaint(); last_bandejaSalida = null; GPSDialog.this.notification.setText(""); GPSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:com.game.ui.views.ItemPanel.java
public void doCommonStuffForContent() { JPanel panel1 = new JPanel(); panel1.setAlignmentX(0);// w w w . j a v a2 s. c o m panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new Insets(5, 5, 5, 5); c.weightx = 1; c.weighty = 0.2; c.gridwidth = 2; JLabel dtlLbl = new JLabel(type + "Details : "); dtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); panel1.add(dtlLbl, c); c.gridwidth = 1; c.gridy = 1; JLabel nameLbl = new JLabel("Name : "); panel1.add(nameLbl, c); c.gridx = 1; JTextField name = new JTextField(""); name.setColumns(20); panel1.add(name, c); if (ringPanel) { createComponentsForRing(panel1, c); } else if (armourPanel) { createComponentsForArmour(panel1, c); } else if (potionPanel) { createComponentsForPotion(panel1, c); } else if (treasurePanel) { createComponentsForTreasure(panel1, c); } c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; JButton submit = new JButton("Save"); submit.addActionListener(this); submit.setActionCommand("button"); panel1.add(submit, c); c.gridx = 0; c.gridy = c.gridy + 1; c.gridwidth = 2; c.weighty = 0; c.weightx = 1; validationMess = new JLabel("Pls enter all the fields or pls choose a " + type + " from the drop down"); validationMess.setForeground(Color.red); validationMess.setVisible(false); panel1.add(validationMess, c); c.gridy++; c.weighty = 1; c.weightx = 1; panel1.add(new JPanel(), c); panel1.setBorder(LineBorder.createGrayLineBorder()); add(panel1); add(Box.createVerticalGlue()); }
From source file:analysers.FilterValidatedDialog.java
/** * Create the dialog.// w w w. j av a 2 s .co m */ public FilterValidatedDialog() { setTitle("Validated Lineages: Export Filter"); setBounds(100, 100, 632, 348); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 160, 440, 0 }; gbl_contentPanel.rowHeights = new int[] { 1, 28, 28, 28, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblCriterion = new JLabel("Lineage Criterion"); lblCriterion.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblCriterion = new GridBagConstraints(); gbc_lblCriterion.insets = new Insets(0, 0, 5, 5); gbc_lblCriterion.gridx = 0; gbc_lblCriterion.gridy = 0; contentPanel.add(lblCriterion, gbc_lblCriterion); } { JLabel lblValue = new JLabel("Value"); lblValue.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblValue = new GridBagConstraints(); gbc_lblValue.insets = new Insets(0, 0, 5, 0); gbc_lblValue.gridx = 1; gbc_lblValue.gridy = 0; contentPanel.add(lblValue, gbc_lblValue); } { lblMinLineageLength = new JLabel("Min. Length (frames)"); GridBagConstraints gbc_lblMinLineageLength = new GridBagConstraints(); gbc_lblMinLineageLength.fill = GridBagConstraints.BOTH; gbc_lblMinLineageLength.insets = new Insets(0, 0, 5, 5); gbc_lblMinLineageLength.gridx = 0; gbc_lblMinLineageLength.gridy = 1; contentPanel.add(lblMinLineageLength, gbc_lblMinLineageLength); } { minLinLen = new JTextField(); GridBagConstraints gbc_minLinLen = new GridBagConstraints(); gbc_minLinLen.anchor = GridBagConstraints.NORTH; gbc_minLinLen.fill = GridBagConstraints.HORIZONTAL; gbc_minLinLen.insets = new Insets(0, 0, 5, 0); gbc_minLinLen.gridx = 1; gbc_minLinLen.gridy = 1; contentPanel.add(minLinLen, gbc_minLinLen); minLinLen.setText("1"); minLinLen.setColumns(3); } { lblStartFrameOf = new JLabel("Max. Start Frame"); GridBagConstraints gbc_lblStartFrameOf = new GridBagConstraints(); gbc_lblStartFrameOf.fill = GridBagConstraints.HORIZONTAL; gbc_lblStartFrameOf.insets = new Insets(0, 0, 5, 5); gbc_lblStartFrameOf.gridx = 0; gbc_lblStartFrameOf.gridy = 2; contentPanel.add(lblStartFrameOf, gbc_lblStartFrameOf); } { startLin = new JTextField(); GridBagConstraints gbc_startLin = new GridBagConstraints(); gbc_startLin.insets = new Insets(0, 0, 5, 0); gbc_startLin.fill = GridBagConstraints.HORIZONTAL; gbc_startLin.gridx = 1; gbc_startLin.gridy = 2; contentPanel.add(startLin, gbc_startLin); startLin.setText("-1"); startLin.setColumns(3); } { JButton btnPreview = new JButton("Preview"); btnPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { preview.setText(makePreview()); } }); GridBagConstraints gbc_btnPreview = new GridBagConstraints(); gbc_btnPreview.insets = new Insets(0, 0, 5, 5); gbc_btnPreview.gridx = 0; gbc_btnPreview.gridy = 3; contentPanel.add(btnPreview, gbc_btnPreview); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 3; contentPanel.add(scrollPane, gbc_scrollPane); { preview = new JTextArea(); scrollPane.setViewportView(preview); preview.setEditable(false); preview.setColumns(10); preview.setTabSize(4); } } { JLabel lblOptions = new JLabel("Options"); GridBagConstraints gbc_lblOptions = new GridBagConstraints(); gbc_lblOptions.insets = new Insets(0, 0, 0, 5); gbc_lblOptions.gridx = 0; gbc_lblOptions.gridy = 4; contentPanel.add(lblOptions, gbc_lblOptions); } { JPanel panel = new JPanel(); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.anchor = GridBagConstraints.NORTH; gbc_panel.fill = GridBagConstraints.HORIZONTAL; gbc_panel.gridx = 1; gbc_panel.gridy = 4; contentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 69, 169, 162, 0 }; gbl_panel.rowHeights = new int[] { 23, 23, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { rdbtnExportMeanIntensity = new JRadioButton("Export Mean Intensity"); rdbtnExportMeanIntensity.setSelected(true); buttonGroup.add(rdbtnExportMeanIntensity); GridBagConstraints gbc_rdbtnExportMeanIntensity = new GridBagConstraints(); gbc_rdbtnExportMeanIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMeanIntensity.insets = new Insets(0, 0, 5, 5); gbc_rdbtnExportMeanIntensity.gridx = 1; gbc_rdbtnExportMeanIntensity.gridy = 0; panel.add(rdbtnExportMeanIntensity, gbc_rdbtnExportMeanIntensity); } { rdbtnExportMaxIntensity = new JRadioButton("Export Max Intensity"); buttonGroup.add(rdbtnExportMaxIntensity); GridBagConstraints gbc_rdbtnExportMaxIntensity = new GridBagConstraints(); gbc_rdbtnExportMaxIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMaxIntensity.insets = new Insets(0, 0, 5, 0); gbc_rdbtnExportMaxIntensity.gridx = 2; gbc_rdbtnExportMaxIntensity.gridy = 0; panel.add(rdbtnExportMaxIntensity, gbc_rdbtnExportMaxIntensity); } { chckbxExportPositions = new JCheckBox("Export Cell Positions and Areas in CSV"); GridBagConstraints gbc_chckbxExportPositions = new GridBagConstraints(); gbc_chckbxExportPositions.anchor = GridBagConstraints.NORTH; gbc_chckbxExportPositions.gridwidth = 2; gbc_chckbxExportPositions.gridx = 1; gbc_chckbxExportPositions.gridy = 1; panel.add(chckbxExportPositions, gbc_chckbxExportPositions); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (validateFields()) { Prefs.set("TrackApp.FilterValidatedDialog.startLin", valStartLin); Prefs.set("TrackApp.FilterValidatedDialog.minLinLen", valMinLinLen); Prefs.set("TrackApp.FilterValidatedDialog.exportMean", doExportMean); Prefs.set("TrackApp.FilterValidatedDialog.exportPositions", doExportPositions); Prefs.savePreferences(); dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:es.emergya.ui.gis.popups.SummaryDialog.java
public SummaryDialog(Recurso r) { super();/*from ww w . j a v a 2 s. c om*/ r = (r == null) ? null : RecursoConsultas.getByIdentificador(r.getIdentificador()); setAlwaysOnTop(true); setResizable(false); setName(r.getIdentificador()); setBackground(Color.WHITE); setSize(600, 400); setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.setBackground(Color.WHITE); r = RecursoConsultas.getByIdentificador(r.getIdentificador()); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel labelTitle = new JLabel(i18n.getString("Resources.summary.title") + " " + r.getIdentificador(), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12f)); title.setBackground(Color.WHITE); title.add(labelTitle); base.add(title); // Nombre JPanel mid = new JPanel(new SpringLayout()); mid.setBackground(Color.WHITE); mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT)); JTextField name = new JTextField(25); if (r != null) name.setText(r.getIdentificador()); name.setEditable(false); mid.add(name); // Patrulla mid.add(new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT)); // JComboBox squads = new // JComboBox(PatrullaConsultas.getAll().toArray()); JTextField squads = new JTextField(r.getPatrullas() == null ? null : r.getPatrullas().getNombre()); // squads.setSelectedItem(r.getPatrullas()); squads.setEditable(false); squads.setColumns(21); // squads.setEnabled(false); mid.add(squads); // Tipo mid.add(new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT)); JTextField types = new JTextField(r.getTipo()); types.setEditable(false); mid.add(types); // Estado Eurocop mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT)); JTextField status = new JTextField(); if (r.getEstadoEurocop() != null) status.setText(r.getEstadoEurocop().getIdentificador()); status.setEditable(false); mid.add(status); // Subflota mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT)); JTextField subfleets = new JTextField(r.getFlotas() == null ? null : r.getFlotas().getNombre()); subfleets.setEditable(false); mid.add(subfleets); // Referencia Humana mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT)); JTextField rHumana = new JTextField(); // if (r.getIncidencias() != null) // rHumana.setText(r.getIncidencias().getReferenciaHumana()); rHumana.setEditable(false); mid.add(rHumana); // dispositivo mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT)); JTextField issi = new JTextField(); issi.setEditable(false); mid.add(issi); mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT)); JCheckBox enabled = new JCheckBox("", true); enabled.setEnabled(false); enabled.setOpaque(false); if (r.getDispositivo() != null) { final String valueOf = String.valueOf(r.getDispositivo()); try { issi.setText(String.format(FORMAT, r.getDispositivo())); } catch (Throwable t) { issi.setText(valueOf); } enabled.setSelected(r.getHabilitado()); } mid.add(enabled); // Fecha ultimo gps mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT)); JTextField lastGPS = new JTextField(); final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r); if (lastGPSDateForRecurso != null) { lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso)); } lastGPS.setEditable(false); mid.add(lastGPS); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18); base.add(mid); // informacion adicional JPanel infoPanel = new JPanel(new SpringLayout()); JTextField info = new JTextField(25); info.setText(r.getInfoAdicional()); info.setEditable(false); infoPanel.setOpaque(false); infoPanel.add(new JLabel(i18n.getString("Resources.info"))); infoPanel.add(info); SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18); base.add(infoPanel); JPanel buttons = new JPanel(); buttons.setBackground(Color.WHITE); JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept")); accept.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); buttons.add(accept); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:MainClass.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Font theFont = null;//from w ww. j a v a 2 s .co m Color theForeground = null; String theText = null; JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Object[]) { Object values[] = (Object[]) value; theFont = (Font) values[0]; theForeground = (Color) values[1]; theText = (String) values[2]; } else { theFont = list.getFont(); theForeground = list.getForeground(); theText = ""; } if (!isSelected) { renderer.setForeground(theForeground); } renderer.setText(theText); renderer.setFont(theFont); return renderer; }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Updates the chat message panel in the Swing event thread *///from ww w. j ava 2 s. c o m public void updateChatMessagePanel() { // Ensure that we operate in the Swing event thread if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateChatMessagePanel(); } }); return; } // Only enable send-function when there is chat data, and hence a target addBtn.setEnabled(true); messageText.setEditable(true); // Remove all components from the messages panel messagesPanel.removeAll(); Insets insets = new Insets(0, 2, 2, 2); Insets insets2 = new Insets(6, 2, 0, 2); // if (chatData != null && chatData.getMessageCount() > 0) { // First, add a filler component int y = 0; messagesPanel.add(new JLabel(""), new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0)); // Add the messages long lastMessageTime = 0; long ownMMSI = MaritimeCloudUtils.toMmsi(EPD.getInstance().getMaritimeId()); for (VOCTSARInfoMessage message : EPD.getInstance().getVoctHandler().getAdditionalInformationMsgs()) { boolean ownMessage = false; if (message.getSender() == ownMMSI) { ownMessage = true; } // EPD.getInstance().getIdentityHandler().getActor(mmsi) // Check if we need to add a time label if (message.getDate() - lastMessageTime > PRINT_DATE_INTERVAL) { JLabel dateLabel = new JLabel(String.format(ownMessage ? "Added %s" : "Received %s", Formatter.formatShortDateTimeNoTz(new Date(message.getDate())))); dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN)); dateLabel.setHorizontalAlignment(SwingConstants.CENTER); dateLabel.setForeground(Color.LIGHT_GRAY); messagesPanel.add(dateLabel, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0)); } // Add a chat message field JPanel msg = new JPanel(); msg.setBorder(new ChatMessageBorder(message, ownMessage)); JLabel msgLabel = new ChatMessageLabel(message.getMessage(), ownMessage); msg.add(msgLabel); messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0)); lastMessageTime = message.getDate(); } // Scroll to the bottom validate(); scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); messagesPanel.repaint(); // } else if (chatData == null && noDataComponent != null) { // // The noDataComponent may e.g. be a message // messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
/** * @param key/*from w w w . j a v a2 s.co m*/ * @return */ protected JLabel createI18NFormLabelBold(final String key) { JLabel lbl = createI18NFormLabel(key); Font lblFont = lbl.getFont().deriveFont(Font.BOLD); lbl.setFont(lblFont); return lbl; }
From source file:utybo.easypastebin.windows.MainWindow.java
/** * Creates the window/*w w w . j a va2 s. c om*/ */ @SuppressWarnings({ "rawtypes", "unchecked" }) public MainWindow() { EasyPastebin.LOGGER.log("Initializing the window", SinkJLevel.INFO); setTitle("EasyPastebin"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 664, 431); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); JPanel main = new JPanel(); tabbedPane.addTab("EasyPastebin", null, main, null); main.setLayout(null); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(62, 39, 312, 132); main.add(scrollPane); pasteContent = new JTextArea(); pasteContent.setFont(new Font("Monospaced", Font.PLAIN, 11)); pasteContent.setWrapStyleWord(true); pasteContent.setLineWrap(true); pasteContent.setToolTipText("Put your paste here!"); scrollPane.setViewportView(pasteContent); JLabel titleLabel = new JLabel("Title :"); titleLabel.setFont(new Font("Tahoma", Font.PLAIN, 12)); titleLabel.setBounds(10, 11, 42, 21); main.add(titleLabel); pasteTitle = new JTextField(); pasteTitle.setBounds(62, 12, 312, 20); main.add(pasteTitle); pasteTitle.setColumns(10); JLabel lblPaste = new JLabel("Paste :"); lblPaste.setForeground(Color.RED); lblPaste.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblPaste.setBounds(10, 85, 53, 21); main.add(lblPaste); pasteExpireDate = new JComboBox(); pasteExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12)); pasteExpireDate.setModel(new DefaultComboBoxModel(EnumExpireDate.values())); pasteExpireDate.setBounds(468, 12, 155, 21); main.add(pasteExpireDate); JLabel lblExpireDate = new JLabel("Expire Date :"); lblExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblExpireDate.setBounds(384, 14, 81, 14); main.add(lblExpireDate); JLabel lblfieldsInRed = new JLabel("(Fields in red are required)"); lblfieldsInRed.setBounds(72, 182, 302, 14); main.add(lblfieldsInRed); btnSubmit = new JButton("Submit!"); btnSubmit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { EasyPastebin.LOGGER.log("Starting Submit script", SinkJLevel.INFO); btnSubmit.setEnabled(false); btnSubmit.setText("Please wait..."); boolean success = true; String paste = pasteContent.getText(); String title = pasteTitle.getText(); EnumExpireDate expireDate = (EnumExpireDate) pasteExpireDate.getSelectedItem(); if (paste.equals("") || paste.equals(" ") || paste.equals(null)) { pastebinUrl.setText("ERROR"); JOptionPane.showMessageDialog(null, "You cannot send empty pastes!", "Error while processing paste", JOptionPane.ERROR_MESSAGE); } else { try { EasyPastebin.LOGGER.log("Setting options", SinkJLevel.INFO); Map map = new HashMap<String, String>(); map.put("api_dev_key", HttpHelper.API_KEY); map.put("api_option", "paste"); map.put("api_paste_code", paste); if (!(expireDate.equals(null) || expireDate.equals(EnumExpireDate.NEVER))) map.put("api_paste_expire_date", expireDate.getRawName()); if (!(title.equals("") || title.equals(" ") || title.equals(null))) map.put("api_paste_name", title); EasyPastebin.LOGGER.log("Sending paste", SinkJLevel.INFO); String actionResult = HttpHelper.sendPost("http://pastebin.com/api/api_post.php", map) .asString(); EasyPastebin.LOGGER.log("Paste sent, checking output", SinkJLevel.INFO); // Exception handlers if (actionResult.equals("Bad API request, invalid api_option")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Incorrect Pastebin option!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_dev_key")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Incorrect dev key! Try again with a more recent version!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, IP blocked")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Your IP is blocked!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals( "Bad API request, maximum number of 25 unlisted pastes for your free account")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals( "Bad API request, maximum number of 10 private pastes for your free account")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals("Bad API request, api_paste_code was empty")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); } if (actionResult.equals("Bad API request, maximum paste file size exceeded")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Your paste is too big!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_expire_date")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid expire date!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_paste_private")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid privacy value!", "Error", JOptionPane.ERROR_MESSAGE); } if (actionResult.equals("Bad API request, invalid api_paste_format")) { success = false; EasyPastebin.LOGGER.log( "The output is an error message : " + actionResult + ". Submit script failed!", SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid format!", "Error", JOptionPane.ERROR_MESSAGE); } // END // Starting display stuff if (success == false) { EasyPastebin.LOGGER.log("Submit script failed : success == false", SinkJLevel.ERROR); pastebinUrl.setText("ERROR"); } if (success == true) { EasyPastebin.LOGGER.log("Paste sent! Starting display script!", SinkJLevel.INFO); pastebinUrl.setText(actionResult); JOptionPane.showMessageDialog(null, "Paste successfully sent!", "Done!", JOptionPane.INFORMATION_MESSAGE); EasyPastebin.LOGGER.log("Display script finished! Paste URL is : " + actionResult, SinkJLevel.INFO); } } catch (ClientProtocolException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (IOException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (MissingParamException e) { EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR); JOptionPane.showMessageDialog(null, "Error while processing paste : " + e + "! This is a severe programming error! Try again with a more recent version!", "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } EasyPastebin.LOGGER.log("Re-enabling the Submit button ", SinkJLevel.INFO); btnSubmit.setEnabled(true); btnSubmit.setText("Submit another paste!"); EasyPastebin.LOGGER.log("Finished submit script! Success : " + success, SinkJLevel.INFO); } }); btnSubmit.setBounds(386, 45, 237, 44); main.add(btnSubmit); pastebinUrl = new JTextField(); pastebinUrl.setText("The paste's URL will be shown here!"); pastebinUrl.setEditable(false); pastebinUrl.setBounds(384, 198, 239, 32); main.add(pastebinUrl); pastebinUrl.setColumns(10); JPanel about = new JPanel(); tabbedPane.addTab("About", null, about, null); JLabel label = new JLabel("EasyPastebin"); label.setBounds(12, 12, 623, 39); label.setHorizontalAlignment(SwingConstants.CENTER); label.setFont(new Font("Dialog", Font.PLAIN, 25)); JLabel lblTheEasiestWay = new JLabel("The easiest way to use Pastebin.com"); lblTheEasiestWay.setBounds(12, 63, 623, 32); lblTheEasiestWay.setFont(new Font("Dialog", Font.PLAIN, 16)); lblTheEasiestWay.setHorizontalAlignment(SwingConstants.CENTER); about.setLayout(null); about.add(label); about.add(lblTheEasiestWay); JButton btnForkM = new JButton("Fork me on Github!"); btnForkM.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("https://github.com/utybo/EasyPastebin"); } }); btnForkM.setBounds(12, 117, 623, 25); about.add(btnForkM); JButton btnCheckOutUtybos = new JButton("Check out utybo's projects!"); btnCheckOutUtybos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("http://utybo.github.io/"); } }); btnCheckOutUtybos.setBounds(12, 154, 623, 25); about.add(btnCheckOutUtybos); JButton btnGoToPastebincom = new JButton("Go to Pastebin.com!"); btnGoToPastebincom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { goToUrl("http://www.pastebin.com"); } }); btnGoToPastebincom.setBounds(12, 191, 623, 25); about.add(btnGoToPastebincom); JLabel lblcUtybo = new JLabel( "This soft was made by utybo. It uses Apache's libraries for the interaction with Pastebin's API"); lblcUtybo.setFont(new Font("Dialog", Font.PLAIN, 10)); lblcUtybo.setHorizontalAlignment(SwingConstants.CENTER); lblcUtybo.setBounds(12, 324, 623, 15); about.add(lblcUtybo); JLabel lblClickMeTo = new JLabel("Click me to go to Apache's licence official website"); lblClickMeTo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { goToUrl("http://www.apache.org/licenses/LICENSE-2.0"); } }); lblClickMeTo.setHorizontalAlignment(SwingConstants.CENTER); lblClickMeTo.setFont(new Font("Dialog", Font.PLAIN, 10)); lblClickMeTo.setBounds(12, 342, 623, 15); about.add(lblClickMeTo); setVisible(true); EasyPastebin.LOGGER.log("Done!", SinkJLevel.INFO); }
From source file:edu.ku.brc.specify.tasks.StatsTrackerTask.java
@Override protected void showClosingFrame() { if (hasChanged) { ImageIcon img = IconManager.getIcon("SpecifySplash"); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,150px", "f:p:g,2px,p")); pb.setDefaultDialogBorder();/*from w ww .j a v a2s .c om*/ JLabel lbl = new JLabel(img); pb.add(lbl, cc.xyw(1, 1, 2)); lbl = UIHelper.createI18NLabel("SPECIFY_SHUTDOWN", SwingConstants.CENTER); lbl.setFont(lbl.getFont().deriveFont(18.0f)); pb.add(lbl, cc.xy(1, 3)); progress = new JProgressBar(0, 100); pb.add(progress, cc.xy(2, 3)); JFrame frame = new JFrame(); frame.setUndecorated(true); frame.setContentPane(pb.getPanel()); frame.pack(); UIHelper.centerAndShow(frame); } }
From source file:ecg.ecgshow.ECGShowUI.java
private void createGuardData() { GuardDataPanel = new JPanel(); GuardDataPanel.setBackground(new Color(0, 150, 255)); // GuardDataPanel.setBounds(); // BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS); // GuardDataPanel.setLayout(layout); GroupLayout layout = new GroupLayout(GuardDataPanel); GuardDataPanel.setLayout(layout);//from w w w .java 2 s . c o m JPanel temperatureData = new JPanel(); temperatureData.setLayout(new FlowLayout()); // temperatureData.setLayout(null); // temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11)); temperatureData.setBackground(new Color(0, 150, 255)); temperatureLabel = new JLabel("--.- "); temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070))); temperatureLabel.setBackground(new Color(0, 150, 255)); temperatureLabel.setForeground(Color.RED); // temperatureLabel.setBounds(0,0,200,100); temperatureLabel.setOpaque(true); JLabel temperatureLabelName = new JLabel(" "); temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); temperatureLabelName.setBackground(new Color(0, 150, 255)); temperatureLabelName.setForeground(Color.BLACK); temperatureLabelName.setBounds(0, 0, 100, 100); temperatureLabelName.setOpaque(true); //?? temperatureData.add(temperatureLabelName); temperatureData.add(temperatureLabel); // JPanel emptyPanel=new JPanel(); // emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2)); // emptyPanel.setBackground(new Color(0,150,255)); // GuardDataPanel.add(emptyPanel); JPanel lightValueData = new JPanel(); lightValueData.setLayout(new BorderLayout()); lightValueData.setBackground(new Color(0, 150, 255)); // lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30)); lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22)); lightValueDataSet = new DefaultValueDataset(); DialPlot lightValueDialPlot = new DialPlot(); lightValueDialPlot.setDataset(lightValueDataSet); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setVisible(false); lightValueDialPlot.setDialFrame(dialFrame); GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 170)); DialBackground dialBackground = new DialBackground(gradientpaint); dialBackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); lightValueDialPlot.setBackground(dialBackground); // ?? DialTextAnnotation dialtextannotation = new DialTextAnnotation(""); dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT))); dialtextannotation.setRadius(0.1D); lightValueDialPlot.addLayer(dialtextannotation); DialValueIndicator dialValueIndicator = new DialValueIndicator(0); dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT))); dialValueIndicator.setOutlinePaint(Color.darkGray); dialValueIndicator.setRadius(0.4D); dialValueIndicator.setAngle(-90.0); lightValueDialPlot.addLayer(dialValueIndicator); StandardDialScale dialScale = new StandardDialScale(); dialScale.setLowerBound(0D); // dialScale.setUpperBound(1024); // dialScale.setMajorTickIncrement(100); dialScale.setStartAngle(-120D); // 120,? dialScale.setExtent(-300D); // 300,? dialScale.setTickRadius(0.85D); // , dialScale.setTickLabelOffset(0.1D); // ,0 bloodDialRange = new StandardDialRange(500D, 750D, Color.red); bloodDialRange.setInnerRadius(0.52000000000000002D); bloodDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bloodDialRange); // bubbleDialRange = new StandardDialRange(0D, 500D, Color.black); bubbleDialRange.setInnerRadius(0.52000000000000002D); bubbleDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bubbleDialRange); // normalDialRange = new StandardDialRange(750D, 1024D, Color.green); normalDialRange.setInnerRadius(0.52000000000000002D); normalDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(normalDialRange); dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // lightValueDialPlot.addScale(0, dialScale); DialPointer.Pointer pointer = new DialPointer.Pointer(); lightValueDialPlot.addPointer(pointer); lightValueDialPlot.mapDatasetToScale(0, 0); DialCap dialCap = new DialCap(); dialCap.setRadius(0.07D); JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot); lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255)); lightValueDialChart.setTitle("??"); lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15), (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(temperatureData, GroupLayout.Alignment.LEADING) .addComponent(lightValueData, GroupLayout.Alignment.LEADING)))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(temperatureData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(lightValueData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)))); // JPanel alarmMessage=new JPanel(); // alarmMessage.setBackground(new Color(0,150,255)); // alarmMessLabel=new JLabel(""); // alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020))); // alarmMessLabel.setBackground(new Color(0,150,255)); // alarmMessage.add(alarmMessLabel); // GuardDataPanel.add(alarmMessage); }