List of usage examples for javax.swing JLabel setFocusable
public void setFocusable(boolean focusable)
From source file:Main.java
/** * Initializes label with text field.//w w w .j a va2s . c o m * * @param label label * @param textField text field */ public static void initLabelComponent(final JLabel label, final JTextField textField) { label.setLabelFor(textField); label.setFocusable(false); }
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); return jLabel; }
From source file:ja.centre.gui.resources.Resources.java
public JLabel label(String key) { JLabel label = new JLabel(text(key)); label.setFocusable(false); return label; }
From source file:com.ssn.ui.custom.component.SSNImageThumbnailControl.java
public SSNImageThumbnailControl getSsnImageThumbnailControl(String imagePath, int index) { //this.setLayout(); iF = 0;//from www . j ava2 s . c o m BufferedImage thumbImg1 = null; this.index = index; BufferedImage image; String[] videoSupported = SSNConstants.SSN_VIDEO_FORMAT_SUPPORTED; final List<String> videoSupportedList = Arrays.asList(videoSupported); try { // add code to check file is video or image if video then write code to create thumbnail String fileExtention = imagePath.substring(imagePath.lastIndexOf(".") + 1, imagePath.length()); if (videoSupportedList.contains(fileExtention.toUpperCase())) { IMediaReader reader = null; try { if (true) { reader = ToolFactory.makeReader(imagePath); reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR); reader.addListener(new MediaListenerAdapter() { @Override public void onVideoPicture(IVideoPictureEvent event) { setVideoFrame(event.getImage()); iF++; } }); while (reader.readPacket() == null && iF == 0) ; thumbImg1 = SSNHelper.resizeImage(getVideoFrame(), 50, 50); } } catch (Throwable e) { e.printStackTrace(); } finally { if (reader != null) reader.close(); } } else { image = ImageIO.read(new File(imagePath)); thumbImg1 = SSNHelper.resizeImage(image, 50, 50); } } catch (IOException ex) { Logger.getLogger(SSNImageThumbnailControl.class.getName()).log(Level.SEVERE, null, ex); } ImageIcon imageIcon = new ImageIcon(thumbImg1); JLabel thumbnailLabel = new JLabel(imageIcon, SwingConstants.HORIZONTAL); JLabel closeLabel = new JLabel(new ImageIcon(getClass().getResource("/icon/remove-icon.png")), SwingConstants.HORIZONTAL); closeLabel.setFocusable(true); closeLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.add(thumbnailLabel); this.add(closeLabel); closeLabel.addMouseListener(this); this.setFocusable(true); this.setSize(new Dimension(50, 50)); this.setBackground(new Color(0, 0, 0, 1)); return this; }
From source file:Clavis.Windows.WShedule.java
public synchronized void create() { initComponents();// w w w .jav a 2 s . c om this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": " + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " " + lingua.translate(mat.getDescription())); KeyQuest.addtoPropertyListener(jPanelInicial, true); String dat = new TimeDate.Date().toString(); String[] auxiliar = prefs.get("datainicio", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); auxiliar = prefs.get("datafim", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); Date date; try { date = sdf.parse(fim.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerFim.setDate(date); try { date = sdf.parse(inicio.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerInicio.setDate(date); andamento = 0; if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); java.util.List<Keys.Request> requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); estado = lingua.translate("Todos"); DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (requisicoes.size() > 0) { valores = new String[requisicoes.size()][4]; lista = new java.util.ArrayList<>(); requisicoes.stream().map((req) -> { if (mat.getMaterialTypeID() == 1) { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0); valores[andamento][2] = req.getBeginDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = lingua.translate(multipla[0]) + ""; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() }; modelo.addRow(ob); } else { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getBeginDate().toString(); valores[andamento][2] = req.getEndDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = multipla[0]; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), valores[andamento][3] }; modelo.addRow(ob); } return req; }).map((req) -> { lista.add(req); return req; }).forEach((_item) -> { andamento++; }); } } jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0)); String[] opcoes = { lingua.translate("Ver detalhes da requisio"), lingua.translate("Ver requisices com a mesma data"), lingua.translate("Ver requisices com o mesmo estado") }; ActionListener[] eventos = new ActionListener[opcoes.length]; eventos[0] = (ActionEvent r) -> { Border border = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK, 3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)), BorderFactory.createEmptyBorder(0, 10, 0, 10)); int val = jTable1.getSelectedRow(); Keys.Request req = lista.get(val); javax.swing.JPanel pan = new javax.swing.JPanel(null); pan.setPreferredSize(new Dimension(500, 300)); pan.setBounds(0, 20, 500, 400); pan.setBackground(Components.MessagePane.BACKGROUND_COLOR); javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": "); lrecurso1.setBounds(10, 20, 120, 26); lrecurso1.setFocusable(true); lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso1); javax.swing.JLabel lrecurso11 = new javax.swing.JLabel( lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " " + lingua.translate(req.getMaterial().getDescription())); lrecurso11.setBounds(140, 20, 330, 26); lrecurso11.setBorder(border); pan.add(lrecurso11); javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": "); lrecurso2.setBounds(10, 50, 120, 26); lrecurso2.setFocusable(true); lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso2); javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName()); lrecurso22.setBounds(140, 50, 330, 26); lrecurso22.setBorder(border); pan.add(lrecurso22); javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": "); lrecurso3.setBounds(10, 80, 120, 26); lrecurso3.setFocusable(true); lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso3); javax.swing.JLabel lrecurso33 = new javax.swing.JLabel( req.getBeginDate().toStringWithMonthWord(lingua)); lrecurso33.setBounds(140, 80, 330, 26); lrecurso33.setBorder(border); pan.add(lrecurso33); javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": "); lrecurso4.setBounds(10, 110, 120, 26); lrecurso4.setFocusable(true); lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso4); javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua)); lrecurso44.setBounds(140, 110, 330, 26); lrecurso44.setBorder(border); pan.add(lrecurso44); javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": "); lrecurso5.setBounds(10, 140, 120, 26); lrecurso5.setFocusable(true); lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso5); javax.swing.JLabel lrecurso55; if (req.getActivity().equals("")) { lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio")); } else { String[] saux = req.getActivity().split(":::"); String atividade; boolean situacao = false; if (saux.length > 1) { situacao = true; atividade = saux[0]; } else { atividade = req.getActivity(); } if (req.getSubject().getId() > 0) { lrecurso55 = new javax.swing.JLabel( lingua.translate(atividade) + ": " + req.getSubject().getName()); } else { lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade)); } if (situacao) { Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua); pop.create(); lrecurso55.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { pop.show(e.getComponent(), e.getX(), e.getY()); } @Override public void mouseExited(MouseEvent e) { pop.setVisible(false); } }); } } lrecurso55.setBounds(140, 140, 330, 26); lrecurso55.setBorder(border); pan.add(lrecurso55); int distancia = 170; if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": "); lrecurso6.setBounds(10, distancia, 120, 26); lrecurso6.setFocusable(true); lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso6); javax.swing.JLabel lrecurso66 = new javax.swing.JLabel( req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0)); lrecurso66.setBounds(140, distancia, 330, 26); lrecurso66.setBorder(border); pan.add(lrecurso66); distancia = 200; } if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": "); lrecurso7.setBounds(10, distancia, 120, 26); lrecurso7.setFocusable(true); lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso7); javax.swing.JLabel lrecurso77 = new javax.swing.JLabel( lingua.translate(req.getWeekDay().perDayName())); lrecurso77.setBounds(140, distancia, 330, 26); lrecurso77.setBorder(border); pan.add(lrecurso77); if (distancia == 200) { distancia = 230; } else { distancia = 200; } } if (req.isTerminated() || req.isActive()) { javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": "); lrecurso8.setBounds(10, distancia, 120, 26); lrecurso8.setFocusable(true); lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso8); javax.swing.JLabel lrecurso88; if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) { lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s") + " " + req.getLiftTime().toString(0)); } else { lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso88.setBounds(140, distancia, 330, 26); lrecurso88.setBorder(border); pan.add(lrecurso88); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; default: distancia = 200; break; } } if (req.isTerminated()) { javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": "); lrecurso9.setBounds(10, distancia, 120, 26); lrecurso9.setFocusable(true); lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso9); javax.swing.JLabel lrecurso99; if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) { lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " " + lingua.translate("s") + " " + req.getDeliveryTime().toString(0)); } else { lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso99.setBounds(140, distancia, 330, 26); lrecurso99.setBorder(border); pan.add(lrecurso99); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; case 260: distancia = 290; break; default: distancia = 200; break; } } Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); }; eventos[1] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString(); SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy"); Date data_auxiliar; try { data_auxiliar = sdf_auxiliar.parse(val); Calendar cal = Calendar.getInstance(); cal.setTime(data_auxiliar); int dia = cal.get(Calendar.DAY_OF_MONTH); int mes = cal.get(Calendar.MONTH) + 1; int ano = cal.get(Calendar.YEAR); inicio = new TimeDate.Date(dia, mes, ano); fim = new TimeDate.Date(dia, mes, ano); } catch (ParseException ex) { data_auxiliar = new Date(); } jXDatePickerFim.setDate(data_auxiliar); jXDatePickerInicio.setDate(data_auxiliar); refreshTable(jComboBoxEstado.getSelectedIndex()); }; eventos[2] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString(); for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) { if (jComboBoxEstado.getItemAt(i).equals(val)) { jComboBoxEstado.setSelectedIndex(i); } } }; KeyStroke[] strokes = new KeyStroke[opcoes.length]; strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK); strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK); strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK); Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes); pop.create(); mouseaction = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto), jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY()))); } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (jTable1.getSelectedRow() >= 0) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } } }; jTable1.addMouseListener(mouseaction); }