billouxs | voila ce que j'ai fais et ca ne marche pas
Code :
- package genie;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Desktop;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.GradientPaint;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GridLayout;
- import java.awt.MediaTracker;
- import java.awt.Menu;
- import java.awt.MenuBar;
- import java.awt.MenuItem;
- import java.awt.MenuShortcut;
- import java.awt.ScrollPane;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.image.BufferedImage;
- import java.awt.image.ImageObserver;
- import java.io.File;
- import java.io.IOException;
- import java.net.URISyntaxException;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.HashMap;
- import javax.imageio.ImageIO;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JEditorPane;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.JTextPane;
- import java.awt.Image;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.event.HyperlinkEvent;
- import javax.swing.event.HyperlinkListener;
- import javax.swing.text.BadLocationException;
- import javax.swing.text.SimpleAttributeSet;
- import javax.swing.text.html.HTML;
- import javax.swing.text.html.HTMLDocument;
- import javax.swing.text.html.HTMLFrameHyperlinkEvent;
- public class fds extends JFrame {
- /**
- *
- */
- /**
- *
- */
- private JPanel container = new JPanel();
- private JPanel containerRechercher = new JPanel ();
- private JPanel containerIndexer =new JPanel();
- private JPanel containerTexte = new JPanel ();
- private JPanel containerSite = new JPanel();
- private JPanel containerNiveau = new JPanel();
- private JPanel containerResultat= new JPanel();
- private JLabel url = new JLabel("url a saisir" );
- private JLabel niv =new JLabel ("niveau" );
- private JLabel search = new JLabel("mot clé a saisir" );
-
- private JTextField texte = new JTextField(25);
- private JTextField site = new JTextField(20);
- private JTextField niveau = new JTextField(2);
- private JButton indexer = new JButton("Indexer" );
- private JButton Rechercher = new JButton("Rechercher" );
- private JEditorPane resultat = new JEditorPane();
- protected JMenuBar menu;
- protected JMenu fichier;
- protected JMenuItem restaurer;
- protected JMenuItem quitter;
- protected JPanel image = new JPanel();
- public fds () {
- menu = new JMenuBar();
- fichier = new JMenu("Fichier" );
- restaurer = new JMenuItem("Reset " );
- quitter = new JMenuItem("Exit" );
- fichier.add(restaurer);
- fichier.add(quitter);
- menu.add(fichier);
- this.setJMenuBar(menu);
- this.setTitle(":: Moteur de recherche ::" );
- this.setSize(1000, 600);
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLocationRelativeTo(null);
- site.setEditable(true);
- niveau.setEditable(true);
- container.add(containerSite);
- container.add(containerNiveau);
- container.add(containerIndexer);
- containerSite.add(site);
- //containerSite.add(url);
- containerNiveau.add(niveau);
- //containerSite.add(niv);
- containerIndexer.add(indexer);
-
- resultat.setEditable(false);
- texte.setEditable(true);
- JPanel pan = new panneau();
- pan.setLayout(null);
- container.add(pan);
- this.setContentPane(container);
- this.setVisible(true);
- container.setLayout(new GridLayout(8,8));
-
-
- //containerTexte.add(search);
- containerTexte.add(texte);
-
- container.add(containerTexte);
- containerRechercher.add(Rechercher);
- container.add(containerRechercher);
- resultat.addHyperlinkListener(new HyperlinkListener() {
- public void hyperlinkUpdate(final HyperlinkEvent e) {
- if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
- try {
- Desktop.getDesktop().browse(e.getURL().toURI());
- } catch (IOException e1) {
- throw new RuntimeException(e1);
- } catch (URISyntaxException e1) {
- throw new RuntimeException(e1);
- }
- }
- }
- });
- indexer.addActionListener(new action());
- Rechercher.addActionListener(new action());
- container.add(resultat);
- JScrollPane textPanel = new JScrollPane (resultat);
- textPanel.setLocation(200, 400);
- container.add(textPanel);
- container.add(containerResultat);
-
- texte.addActionListener(new action());
- restaurer.addActionListener(new action());
- }
- public class action implements ActionListener {
-
- public void actionPerformed(ActionEvent e) {
- robot l=new robot();
- int i = Integer.valueOf(niveau.getText());
- if(e.getSource()==indexer){
- HashMap<String, ArrayList> st = new HashMap <String , ArrayList> ();
- try {
- st=l.indexer("http://"+site.getText(),i);
- System.out.println(st);
- } catch (IOException e1) {
- // TODO Bloc catch auto-généré
- e1.printStackTrace();
- } catch (BadLocationException e1) {
- // TODO Bloc catch auto-généré
- e1.printStackTrace();
-
- }
- }
-
- if (e.getSource() == Rechercher) {
-
- String str= null;
- HashMap<String, ArrayList> st = new HashMap <String , ArrayList> ();
- try {
- st=l.indexer("http://"+site.getText(),i);
- } catch (IOException e1) {
- // TODO Bloc catch auto-généré
- e1.printStackTrace();
- } catch (BadLocationException e1) {
- // TODO Bloc catch auto-généré
- e1.printStackTrace();
- }
- str=l.rechercher(texte.getText());
- System.out.println(texte.getText());
- System.out.println(str);
-
-
-
- resultat.setText(str);
- }
-
- if(e.getSource()==restaurer){
- site.setText("" );
- niveau.setText("" );
- texte.setText("" );
- resultat.setText("" );
- }
-
- }
- }
- class panneau extends JPanel
- {
- private ImageIcon Ifond;
-
- public panneau()
- {
- // Image de fond.
- Ifond = new ImageIcon ("/home/etu/5E29A2/doudoub/Bureau/lou.jpg" );
-
- }
-
- public void paintComponent (Graphics g)
- {
- super.paintComponent(g);
- g.drawImage (Ifond.getImage(), 1000, 400, this);
- //g.drawString ("Bienvenue chez Animal Guessing", 20, 20);
-
- Graphics2D g2d = (Graphics2D)g;
- //g.fillOval(400,80, 200, 111);
- GradientPaint gp = new GradientPaint(20, 20, Color.white, 95, 95, Color.white, true);
- g2d.setPaint(gp);
- //g2d.fillOval(400,80, 200, 111);
-
- //g.drawString ("Bienvenue chez Animal Guessing", 20, 20);
-
- }
-
- }
-
- public static void main(String[] args) {
- new fds ();
- }
- }
|
|