hi

I have to create a help menu in my project for that i had made html pagesand my problem is I cannot connect that html pages from help menuitem. pls helpme and guide me for that.

thanks for ur response
shashikant.v

Recommended Answers

All 4 Replies

You can extend JFrame to have a JTextPane with scrollbars. Then use JTextPane's setPage() method to point to the html file.
Below code snippet will provide you the clues,

JTextPane tp = new JTextPane();
  JScrollPane js = new JScrollPane();
  js.getViewport().add(tp);
  JFrame jf = new JFrame();
  jf.getContentPane().add(js);
  jf.pack();
  jf.setSize(400,500);
  jf.setVisible(true); 
  
  try {
    	File f = new File("test.html");
	URL url = f.toURL();
    tp.setPage(url);
    } 
  catch (Exception e) {
    e.printStackTrace();
    }

It is compliant to HTML 3.2 only.

Or you can also use internal browsers like Lobo

Or if you are using jdk6 than you also you the Desktop APIs to launch browser

Hello shashikant.v,

If you what you need is to open the html page from your help menu app, you can use the Desktop API in SE 6... like this:

Desktop desktop = null;
		URI uri = null;
		
		if (Desktop.isDesktopSupported()){
			desktop = Desktop.getDesktop();
		}
		if (desktop.isSupported(Desktop.Action.BROWSE)){
			try {
				uri = new URI("http://www.daniweb.com/");
				desktop.browse(uri);
			} catch (URISyntaxException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}

please help me ^_^
I want using thread in this program
but I don't know ..??

____________________________________________________

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//------------------------------------------------------------------------------------------------
public class MyApp extends JFrame {
// Data
static boolean stopped = true; // Is the counting stopped? (True or False) --> shared variable
static JTextField number;
//------------------------------------------------------------------------------------------------
// Constructor
public MyApp()
{
// set the GUI
super( "CAP 332 - Assignment 6: Learning Java Threads" );
// create the 2 buttons
// 1) The start button
JButton startButton = new JButton("Start");
startButton.addActionListener(new StartButtonHandler());
startButton.setToolTipText("Click here to start counting.");
// 2) The stop button
JButton stopButton = new JButton("Stop");
stopButton.addActionListener(new StopButtonHandler());
stopButton.setToolTipText("Click here to stop counting.");
// create the text field
number = new JTextField(20);
number.setEditable(false);
number.setText("0");
// create the panels
JPanel row1Panel = new JPanel();
JPanel row2Panel = new JPanel();
// create the first row
row1Panel.add(number);
// create the second row
row2Panel.setLayout(new GridLayout(1,2)); // Grid layout with 1 row and 2 columns for the 2
buttons
row2Panel.add(startButton);
row2Panel.add(stopButton);
// create a split panel to include the 2 row panels
JSplitPane allPanel = new JSplitPane( JSplitPane.VERTICAL_SPLIT, row1Panel, row2Panel );
allPanel.setOneTouchExpandable( false );
allPanel.setDividerLocation( 50 );
// add this panel to the content pane
getContentPane().add(allPanel);
setSize(500,150);
setVisible( true );
}// end constructor
//------------------------------------------------------------------------------------------------
// main method
public static void main (String[] args)
{
MyApp app = new MyApp ();
app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}// end main
//------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// PRIVATE CLASSES
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
private class StartButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e)
{
stopped = false;
long counter = 1;
while (! stopped)
{
number.setText(""+counter);
counter ++;
}// end while
}// end method
}// end class StartButtonHandler
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
private class StopButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e)
{
stopped = true;
}// end method
}// end class StopButtonHandler
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
} // end class
commented: Don't spam this on other peoples' threads. -2

Hi SORelena,

Please post your problem in your own thread if you want to get any answers ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.