Salve a tutti,
ho un applet che se eseguita sull'ide, eclipse, si esegue tranquillamente, se poi provo a farla girare sul browser (firefox su macOs o chrome su windows seven) fa come se sta caricando l'applet java ma quando la carica mi da una pagina bianca senza nulla sopra.
Il codice html che utilizzo è questo:
L'applet invece, che si chiama Apriori.class e si trova nella stessa pagina del codice html è invece questa:codice:<html> <head> <title>Apriori</title> </head> <body> eee <applet code="Apriori.class" widht= 800 height= 800> </applet> </body> </html>
Secondo voi da cosa può dipendere? perchè mi sembra strano che su eclipse gira senza modfiicare mezza riga di codice e su broswer no. Forse ho sbagliato qualcosa nel file html?codice:import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.io.EOFException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.border.Border; public class Apriori extends JApplet { private ObjectOutputStream out; private ObjectInputStream in; private JRadioButton db; private JRadioButton file; private JTextField nameDataTxt; private JButton aprioriCostructioBt; private JTextField minSupTxt; private JTextField minConfTxt; private JTextArea rulesAreaTxt; private JTextArea msgAreaTxt; private JTextField fb; private InetAddress addr; public void init() { Container cp = getContentPane(); //Pannello cpAprioriMinig//////////////////////////////////////////////////////// JPanel cpAprioriMining = new JPanel(); Border borderTree = BorderFactory.createTitledBorder("Selecting Data Source"); cpAprioriMining.setBorder(borderTree); cpAprioriMining.setLayout(new BoxLayout(cpAprioriMining, BoxLayout.Y_AXIS)); ButtonGroup group = new ButtonGroup(); db = new JRadioButton("Learning rules from db"); file = new JRadioButton("Reading rules from file"); group.add(db); group.add(file); db.setSelected(true); cpAprioriMining.add(db); cpAprioriMining.add(file); // indirizzo riservato al localhost 127.0.0.1 //try principale per la chiusura del socket try { addr = InetAddress.getByName("127.0.0.1"); } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("addr = " + addr); Socket socket; try { socket = new Socket(addr, 8083); out = new ObjectOutputStream(socket.getOutputStream()); in = new ObjectInputStream(socket.getInputStream()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /////////////////////////////////////////////////////////////////////////////777 //pannello cpAprioriInput JPanel cpAprioriInput = new JPanel(); Border borderTree2 = BorderFactory.createTitledBorder("Input parameters"); cpAprioriInput.setBorder(borderTree); cpAprioriInput.setLayout(new FlowLayout()); JLabel data = new JLabel(" Data "); nameDataTxt = new JTextField("playtennis"); JLabel minSup = new JLabel(" min sup "); minSupTxt = new JTextField("0.2"); JLabel minConf = new JLabel(" min conf "); minConfTxt = new JTextField("0.5"); JLabel filebackup = new JLabel(" file_backup "); fb = new JTextField("prova"); cpAprioriInput.add(data); cpAprioriInput.add(nameDataTxt); cpAprioriInput.add(minSup); cpAprioriInput.add(minSupTxt); cpAprioriInput.add(minConf); cpAprioriInput.add(minConfTxt); cpAprioriInput.add(filebackup); cpAprioriInput.add(fb); /////////////////////////////////////////////////////////////////////////////777 //Creazione del pannello cpParameterSetting JPanel cpParameterSetting = new JPanel(); Border borderTree3 = BorderFactory.createTitledBorder("Apriori"); cpParameterSetting.setBorder(borderTree3); cpParameterSetting.add(cpAprioriMining); cpParameterSetting.add(cpAprioriInput); ////////////////////////////////////////////////////////////////////////// //creazione del pannello cpMiningCommand JPanel cpMiningCommand = new JPanel(); aprioriCostructioBt = new JButton("apriori"); aprioriCostructioBt.setAlignmentX(CENTER_ALIGNMENT); cpMiningCommand.add(aprioriCostructioBt); ////////////////////creazione del listner aprioriCostructioBt.addActionListener(new java.awt.event.ActionListener(){ public void actionPerformed(ActionEvent e) { try { startAprioriBt_mouseClicked(e); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch(ClassNotFoundException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } } }); //Creiamo cpRuleViewer JPanel cpRuleViewer = new JPanel(); cpRuleViewer.setLayout(new BoxLayout(cpRuleViewer, BoxLayout.Y_AXIS)); rulesAreaTxt = new JTextArea(" "); JScrollPane jsp=new JScrollPane(rulesAreaTxt); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); rulesAreaTxt.setEditable(false); msgAreaTxt = new JTextArea(" "); msgAreaTxt.setEditable(false); Border borderTree4 = BorderFactory.createTitledBorder("Patterns and Rules"); cpRuleViewer.setBorder(borderTree4); cpRuleViewer.add(jsp); cpRuleViewer.add(msgAreaTxt); //Aggiungiamo tutto a container principale cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); cp.add(cpParameterSetting); cp.add(cpMiningCommand); cp.add(cpRuleViewer); } private void startAprioriBt_mouseClicked(ActionEvent e) throws IOException, ClassNotFoundException { [..] }
Vi ringrazio in anticipo,
Neptune.


Rispondi quotando