codice:import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JLabel; import javax.swing.JButton; import CLIPSJNI.Environment; import CLIPSJNI.PrimitiveValue; import javax.swing.JTextPane; import java.awt.Font; import java.awt.event.MouseEvent; import java.util.StringTokenizer; import java.awt.Color; import javax.swing.SwingConstants; import javax.swing.JScrollPane; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Progetto extends JFrame { static Object ProfileData[] = new Object[30]; static Environment clips=new Environment(); static PrimitiveValue rv; static String a="?*send*"; private JPanel contentPane; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { clips.load("prova.clp"); clips.reset(); clips.run(); Progetto frame = new Progetto(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. * @throws Exception */ public Progetto() throws Exception { setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 30, 662, 671); contentPane = new JPanel(); contentPane.setBackground(Color.LIGHT_GRAY); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); rv=clips.eval(a); ProfileData=(Object[]) Progetto.codificaCodice(rv.stringValue()); System.out.println((String) Progetto.ProfileData[0]); JButton range2 = new JButton("18 - 30"); range2.setFont(new Font("Trebuchet MS", Font.PLAIN, 15)); range2.setForeground(Color.BLACK); range2.setBackground(Color.CYAN); range2.setBounds(311, 221, 89, 31); contentPane.add(range2); JButton range4 = new JButton("OVER 60"); range4.setFont(new Font("Trebuchet MS", Font.PLAIN, 15)); range4.setForeground(Color.BLACK); range4.setBackground(Color.CYAN); range4.setBounds(311, 279, 89, 31); contentPane.add(range4); JLabel lblTravel = new JLabel("Travel Recommender"); lblTravel.setForeground(new Color(204, 0, 0)); lblTravel.setFont(new Font("Trebuchet MS", Font.BOLD | Font.ITALIC, 30)); lblTravel.setHorizontalAlignment(SwingConstants.CENTER); lblTravel.setBounds(-29, 11, 636, 49); contentPane.add(lblTravel); JButton range1 = new JButton("0 - 18"); range1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { } }); range1.setForeground(Color.BLACK); range1.setFont(new Font("Trebuchet MS", Font.PLAIN, 15)); range1.setBackground(Color.CYAN); range1.setBounds(176, 221, 89, 31); contentPane.add(range1); JTextPane txtpnFsd = new JTextPane(); txtpnFsd.setToolTipText(""); contentPane.add(txtpnFsd); txtpnFsd.setForeground(Color.BLACK); txtpnFsd.setBackground(Color.LIGHT_GRAY); txtpnFsd.setFont(new Font("Trebuchet MS", Font.BOLD | Font.ITALIC, 15)); txtpnFsd.setEditable(false); txtpnFsd.setBounds(213, 134, 139, 76); txtpnFsd.setText((String) ProfileData[0]); JButton range3 = new JButton("30 - 60"); range3.setForeground(Color.BLACK); range3.setFont(new Font("Trebuchet MS", Font.PLAIN, 15)); range3.setBackground(Color.CYAN); range3.setBounds(176, 279, 89, 31); contentPane.add(range3); range1.addMouseListener(new java.awt.event.MouseAdapter(){ public void mouseClicked(MouseEvent e){ Progetto.clips.eval((String) Progetto.ProfileData[1]); //assert 0-18 Progetto.clips.run(); Progetto.rv=Progetto.clips.eval(a); try { Progetto.ProfileData=(Object[]) Progetto.codificaCodice(Progetto.rv.stringValue()); System.out.println((String) Progetto.ProfileData[0]); } catch (Exception e1) { e1.printStackTrace(); } Lavoro frame = null; try { frame= new Lavoro(); } catch (Exception e1) { e1.printStackTrace(); } frame.setVisible(true); dispose(); } }); range2.addMouseListener(new java.awt.event.MouseAdapter(){ public void mouseClicked(MouseEvent e){ Progetto.clips.eval((String) Progetto.ProfileData[2]); //assert 18-30 Progetto.clips.run(); Progetto.rv=Progetto.clips.eval(a); try { Progetto.ProfileData=(Object[]) Progetto.codificaCodice(Progetto.rv.stringValue()); System.out.println((String) Progetto.ProfileData[0]); } catch (Exception e1) { e1.printStackTrace(); } Lavoro frame = null; try { frame= new Lavoro(); } catch (Exception e1) { e1.printStackTrace(); } frame.setVisible(true); dispose(); } }); range3.addMouseListener(new java.awt.event.MouseAdapter(){ public void mouseClicked(MouseEvent e){ Progetto.clips.eval((String) Progetto.ProfileData[3]); //assert 30-60 Progetto.clips.run(); Progetto.rv=Progetto.clips.eval(a); try { Progetto.ProfileData=(Object[]) Progetto.codificaCodice(Progetto.rv.stringValue()); System.out.println((String) Progetto.ProfileData[0]); } catch (Exception e1) { e1.printStackTrace(); } Lavoro frame = null; try { frame= new Lavoro(); } catch (Exception e1) { e1.printStackTrace(); } frame.setVisible(true); dispose(); } }); range4.addMouseListener(new java.awt.event.MouseAdapter(){ public void mouseClicked(MouseEvent e){ Progetto.clips.eval((String) Progetto.ProfileData[4]); //assert magg 60 Progetto.clips.run(); Progetto.rv=Progetto.clips.eval(a); try { Progetto.ProfileData=(Object[]) Progetto.codificaCodice(Progetto.rv.stringValue()); System.out.println((String) Progetto.ProfileData[0]); } catch (Exception e1) { e1.printStackTrace(); } Lavoro frame = null; try { frame= new Lavoro(); } catch (Exception e1) { e1.printStackTrace(); } frame.setVisible(true); dispose(); } }); } public static Object codificaCodice(String message) { Object token = null; int count = 0; Object ProfileData[] = new Object[30]; for(StringTokenizer st = new StringTokenizer(message, "%"); st.hasMoreTokens(); count++) { token = st.nextToken(); ProfileData[count] = (String) token; } return ProfileData; } }