html in java

Pagina: 1
Acties:

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
Ik ben onlangs begonnen met java programmeren in jbuilder 6.

ik heb zelf een programma gemaakt.
nu komt het probleem:

met dit programma moet een bewerking uitgevoerd worden en als de bewerking goed is moet er een html bestand geopend worden. als de bewerking niet goed is moet hij niet geopend worden.

hoe laat ik een java programma een html bestand in een nieuw venster openen. Ik heb een een boek van java maar daar staat het niet in en de help funktie in java werkt niet.
kan iemand mij zeggen hoe ik dit voor elkaar krijg of een weet iemand een site waar ik dit kan opzoeken.

The one, the only, the original ICW


  • PrinsEdje80
  • Registratie: Oktober 2001
  • Laatst online: 01-01 15:26

PrinsEdje80

Holographic, not grated...

window.open... Of is dit javascript?

Used to be Down Under... Foto gallery


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

In een Applet of in een Application?

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
het is een applet

The one, the only, the original ICW


  • Donderwolk
  • Registratie: Januari 2002
  • Laatst online: 11-06 11:16
Volgens mij bestaat er een klasse die html code weer kan geven. (zoals in een browser) Dit is volgens mij een Swing component. Zoek daar eens naar?

Pwnd


Verwijderd

import netscape.javascript.*

JSObject.getWindow().eval("window.open('document.html','new_win', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=560,height=340')")

of

getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
Dit werkt ook onder internet explorer of is dit alleen voor netscape.
Verwijderd schreef op 01 november 2002 @ 11:23:
import netscape.javascript.*

JSObject.getWindow().eval("window.open('document.html','new_win', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=560,height=340')")

The one, the only, the original ICW


  • NDF82
  • Registratie: Januari 2002
  • Laatst online: 26-08 21:49

NDF82

Doomed Space Marine

Moet je is naar de swingdemo kijken, volgens mij zoek je een JEditorPane.

Pentium 233MHz MMX + Diamond Monster 3D 3DFX Voodoo II


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");
deze idd!

offtopic:
He jij Aikido-er? welke band/dan?

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
ik heb nu dit:

package untitled1;

import netscape.javascript.*;

public class Applet1 extends Applet {
public void init(){
getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");
}}

maar dan krijg ik de fout:
"Applet1.java": Error #: 300 : class URL not found in class untitled1.Applet1 at line 18, column 37.

The one, the only, the original ICW


  • Donderwolk
  • Registratie: Januari 2002
  • Laatst online: 11-06 11:16
even importen

java.net.*

(Het is inderdaad java.net.* en niet java.util.*)

Pwnd


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

import java.net.*;
edit:
Volgens mijn zit hij echt in net en niet in Util maar ik zal het ff checken


In de java.net package zie hier:
http://java.sun.com/j2se/1.4.1/docs/api/java/net/URL.html

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
ik blijf de foutmelding houden.

The one, the only, the original ICW


  • Donderwolk
  • Registratie: Januari 2002
  • Laatst online: 11-06 11:16
Heb je hier ook iets aan?

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Fig. 21.1: SiteSelector.java
// This program uses a button to load a document from a URL.
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.applet.AppletContext;

public class SiteSelector extends JApplet {
   private Hashtable sites;
   private Vector siteNames;

   public void init()
   {
      sites = new Hashtable();
      siteNames = new Vector();

      getSitesFromHTMLParameters();

      Container c = getContentPane();
      c.add( new JLabel( "Choose a site to browse" ),
             BorderLayout.NORTH );

      final JList siteChooser = new JList( siteNames );
      siteChooser.addListSelectionListener(
         new ListSelectionListener() {
            public void valueChanged( ListSelectionEvent e )
            {
               Object o = siteChooser.getSelectedValue();
               URL newDocument = (URL) sites.get( o );
               AppletContext browser = getAppletContext();
               browser.showDocument( newDocument );
            }
         }
      );
      c.add( new JScrollPane( siteChooser ),
             BorderLayout.CENTER );
   }

   private void getSitesFromHTMLParameters()
   {
      // look for applet parameters in the HTML document
      // and add sites to Hashtable
      String title, location;
      URL url;
      int counter = 0;

      while ( true ) {
         title = getParameter( "title" + counter );

         if ( title != null ) {
            location = getParameter( "location" + counter );
            
            try {
               url = new URL( location );
               sites.put( title, url );
               siteNames.addElement( title );
            }
            catch ( MalformedURLException e ) {
               e.printStackTrace();
            }
         }
         else
            break;

         ++counter;  
      }
   }
}

/**************************************************************************
 * (C) Copyright 1999 by Deitel & Associates, Inc. and Prentice Hall.     *
 * All Rights Reserved.                                                   *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/

Pwnd


  • wasigh
  • Registratie: Januari 2001
  • Niet online

wasigh

wasigh.blogspot.com

Geef je code eens ?

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
wasigh schreef op 01 november 2002 @ 11:36:
import java.net.*;
edit:
Volgens mijn zit hij echt in net en niet in Util maar ik zal het ff checken


In de java.net package zie hier:
http://java.sun.com/j2se/1.4.1/docs/api/java/net/URL.html
heb nu dit package untitled1;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;

public class Applet1 extends Applet {
public void init(){
getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");
}}

maar dan krijg ik de foutmelding:

"Applet1.java": Error #: 360 : unreported exception: java.net.MalformedURLException; must be caught or declared to be thrown at line 19, column 37.

The one, the only, the original ICW


  • Donderwolk
  • Registratie: Januari 2002
  • Laatst online: 11-06 11:16
try{

}
catch( Exception e ){}

er omheen zetten

Dus:
code:
1
2
3
4
5
6
7
8
9
10
public class Applet1 extends Applet {

public void init(){
  try{
     getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");
  }
  catch (Exception e){}
}

}

Pwnd


  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
Donderwolk schreef op 01 november 2002 @ 11:42:
try{

}
catch( Exception e ){}

er omheen zetten

Dus:
code:
1
2
3
4
5
6
7
8
9
10
public class Applet1 extends Applet {

public void init(){
  try{
     getAppletContext().showDocument(new URL("http://www.java.sun.com"), "_blank");
  }
  catch (Exception e){}
}

}
deze geeft geen foutmelding en ik krijg ook het uitvoer scherm te zien maar er wordt geen browser geopend.

sorry als ik de applet start vanuit het html bestand dan doet hij het.

The one, the only, the original ICW


  • Postman
  • Registratie: Februari 2000
  • Laatst online: 15-08 20:11
En als je hem onder IE draait (dus niet via de applet browser van JBuilder, maar starten via de html pagina) :?

  • ICW
  • Registratie: Februari 2002
  • Laatst online: 05-07 08:26
ja hij doet het.
thnx

The one, the only, the original ICW

Pagina: 1