Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JavaScript with JEditorPane?

843806Jun 29 2009 — edited Jun 29 2009
I am messing around with some URL stuff at the moment and I was trying to mimic a web browser,
I may not succeed but its worth doing,

I am stuck on getting JavaScript to work, is it possible to get JavaScript showing up.

Also I am having a problem with links not working properly but this maybe because its JavaScript links and not <a href=" links

I have to go for a while but i'll be back to read the answers.

Here's my program.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;


public class WebGUI extends JFrame
{
  public static String myURL = null;
  public static JEditorPane area;
  public static JButton button;
  public static JPanel panel;
  public static JTextField field;
  public static JScrollPane scrollPane;
  boolean urlChanged = false;

  public void setUpGUI()
  {
    area = new JEditorPane();
    button = new JButton("Go");
    panel = new JPanel();
    field = new JTextField(20);
    scrollPane = new JScrollPane(area);
    
    panel.add(field);
    panel.add(button);
    
    button.addActionListener(new Action());
    field.addActionListener(new Action());

    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    
    area.setContentType("text/html");
    
    this.getContentPane().add(BorderLayout.NORTH,panel);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(800,500);
    this.setVisible(true);
    
    while(true)
    {
      try
      {
        Thread.sleep(12);
      }
      catch (InterruptedException e)
      {
        System.out.println("It should work");
      }
      
      if (myURL != null && urlChanged) // Updates URL
      {      
        urlChanged = false;
      
        try
        {
          area = new JEditorPane(myURL);
          scrollPane = new JScrollPane(area);
          this.getContentPane().add(BorderLayout.CENTER,area);
        }
        catch (IOException e)
        {
          System.out.println("URL invalid");
        }
      }
    }
  }
  public class Action implements ActionListener
  {
    public void actionPerformed(ActionEvent e) // Gets URL from JTextField and makes it valid when not given the http:// or http://www.
    {
      urlChanged = true;
      
      if(field.getText().charAt(0) == 'h' && field.getText().charAt(1) == 't' && field.getText().charAt(2) == 't' && field.getText().charAt(3) == 'p' && field.getText().charAt(4) == ':' && field.getText().charAt(5) == '/' && field.getText().charAt(6) == '/')
      {
        myURL = field.getText();
      }
      else if(field.getText().charAt(0) == 'w' && field.getText().charAt(1) == 'w' && field.getText().charAt(2) == 'w' && field.getText().charAt(3) == '.')
      {
        myURL = "http://" + field.getText();
      }
      else
      {
        myURL = "http://www." + field.getText();
      }
    }
  }
  
  public static void main(String[] args) throws Exception
  {
    WebGUI webGUI = new WebGUI();
    webGUI.setUpGUI();
  }

}

Comments

alan.pae
AFAIK no version of Solaris, even nevada build 91 uses ZFS for the root file system.

You could use OpenSolaris 200805 which does this but there are some other subtle differences between OpenSolaris and Solaris.

alan
807557
If you are running Solaris 10 U5, you can only have mirroring using svm, plus the root file system must be UFS.
However, you can make a slice in a zfs partition an mirror that (I wouldn't recommend using svm to mirror on
top of ZFS).

Opensolaris 2008.05 does zfs boot, and Nevada could do zfs boot since Build72 ( http://sol10frominnerspace.blogspot.com/2007/09/setup-zfs-boot-for-build-72.html ) - though bits and pieces were
not working o rmissing (like swap in a zvol). The big roll in was on Build94 ( http://www.opensolaris.org/os/community/on/flag-days/91-95/ )
so if you get the latest, your chances of running into any issues are lower.

-r
807557
oh excellent!

thanks guys, i'll get to and give OpenSolaris a spin, was the only thing holding me back making the move.

all the best,


John.
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 27 2009
Added on Jun 29 2009
2 comments
136 views