/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package feuille.welcome; /** * * @author The Wingate 2940 */ public class RSSPanel extends javax.swing.JPanel { /** * Creates new form RSSPanel */ public RSSPanel() { initComponents(); } public RSSPanel(String title, String desc, String link, String auth, String date) { initComponents(); lblTitle.setText(title); jTextPane1.setText(desc); lblLink.setText(link); lblAuthor.setText(auth); lblDate.setText(date); } public void setTitle(String title){ lblTitle.setText(title); } public void setDescription(String desc){ jTextPane1.setText(desc); } public void setLink(String link){ lblLink.setText(link); } public void setAuthor(String auth){ lblAuthor.setText(auth); } public void setDate(String date){ lblDate.setText(date); } /** <p>Launch the selected link and open a browser.<br /> * Lance le lien sélectionné et ou un navigateur.</p> */ private void launchLink(String link){ boolean hasResult = true; if(java.awt.Desktop.isDesktopSupported()){ java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if(desktop.isSupported(java.awt.Desktop.Action.BROWSE)){ try { try { desktop.browse(new java.net.URI(link)); } catch (java.io.IOException ex) {hasResult = false;} } catch (java.net.URISyntaxException ex) {hasResult = false;} }else{ hasResult = false; } }else{ hasResult = false; } if(hasResult==false){ java.util.Properties sys = System.getProperties(); String os = sys.getProperty("os.name").toLowerCase(); try { if(os.contains("windows")==true){ Process proc = Runtime.getRuntime().exec("cmd /c start "+link); }else{ Process proc = Runtime.getRuntime().exec("start "+link); } } catch (java.io.IOException e) { // unsupported } } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); jTextPane1 = new javax.swing.JTextPane(); lblTitle = new javax.swing.JLabel(); lblLink = new javax.swing.JLabel(); lblAuthor = new javax.swing.JLabel(); lblDate = new javax.swing.JLabel(); setPreferredSize(new java.awt.Dimension(600, 262)); jTextPane1.setEditable(false); jTextPane1.setBorder(null); jTextPane1.setContentType("text/html"); // NOI18N jScrollPane2.setViewportView(jTextPane1); lblTitle.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblTitle.setText("Titre"); lblLink.setForeground(new java.awt.Color(51, 51, 255)); lblLink.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblLink.setText("Lien"); lblLink.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblLinkMouseClicked(evt); } }); lblAuthor.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblAuthor.setText("Auteur"); lblDate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblDate.setText("Date"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblLink, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE) .addComponent(lblAuthor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(lblTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblLink) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblAuthor) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lblDate) .addContainerGap(33, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void lblLinkMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblLinkMouseClicked String s = lblLink.getText(); launchLink(s); }//GEN-LAST:event_lblLinkMouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextPane jTextPane1; private javax.swing.JLabel lblAuthor; private javax.swing.JLabel lblDate; private javax.swing.JLabel lblLink; private javax.swing.JLabel lblTitle; // End of variables declaration//GEN-END:variables }