can't see the java code correctly....
can someone tell me what is the problem?
when using the tutorial I am trying to view the source of a given code ( in the tutorial) but the code is viewed with no LF and CR.
(I'm using windows xp).
for example:
in http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html
when viewing the code of the class ProgressBarDemo.java
a new window is opened and the code is viewed like this:
import java.awt.*; import java.awt.event.*; import javax.swing.*; /* * ProgressBarDemo.java is a 1.4 application that requires these files: * LongTask.java * SwingWorker.java */ public class ProgressBarDemo extends JPanel implements ActionListener { public final static int ONE_SECOND = 1000; private JProgressBar progressBar; private Timer timer; private JButton startButton; private LongTask task; private JTextArea taskOutput; private String newline = "\n"; public ProgressBarDemo() { super(new BorderLayout()); task = new LongTask(); //Create the demo's UI. startButton = new JButton("Start"); startButton.setActionCommand("start"); startButton.addActionListener(this); progressBar = new JProgressBar(0, task.getLengthOfTask()); progressBar.setValue(0); progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5,5,5,5)); taskOutput.setEditable(false); taskOutput.setCursor(null); //inherit the panel's cursor //see bug 4851758 JPanel panel = new JPanel(); panel.add(startButton); panel.add(progressBar); add(panel, BorderLayout.PAGE_START); add(new JScrollPane(taskOutput), BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); //Create a timer. timer = new Timer(ONE_SECOND, new ActionListener() { public void actionPerformed(ActionEvent evt) { progressBar.setValue(task.getCurrent()); String s = task.getMessage(); if (s != null) { taskOutput.append(s + newline); taskOutput.setCaretPosition( taskOutput.getDocument().getLength()); } if (task.isDone()) { Toolkit.getDefaultToolkit().beep(); timer.stop(); startButton.setEnabled(true); setCursor(null); //turn off the wait cursor progressBar.setValue(progressBar.getMinimum()); } } }); } /** * Called when the user presses the start button. */ public void actionPerformed(ActionEvent evt) { startButton.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); task.go(); timer.start(); } /** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread. */ private static void createAndShowGUI() { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("ProgressBarDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new ProgressBarDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } }
thanks
[3281 byte] By [
dunayna] at [2007-10-1 1:16:46]

The server appears to have been altered (some time ago, too, this has existed for some time) so that it's coding the file in a manner that's causing it to display as html.
Try clicking on the link, and then display the source of the window that results (the window that's displaying the code you pasted). In IE, the View menu has a Source entry that displays the formatted source code for me.
This comes from standard type associations: in this context (.java files) the editor used is NotePad, which does not takecare of CR/LF correctly. If you change the association to WordPad (for example), you will solve your problem.
Or even better, use UltraEdit. They have a small hack on their website to "replace" notepad with UltraEdit, so every time you view the html source in IE it will be opened in UltraEdit so you can view it with syntax highlighting and Linux/Windows/Mac text file support.
> This comes from standard type associations: in this context (.java files) the editor used is NotePad. If you change the association to WordPad (for example), you will solve your problem.
I have used:
Control Panel \ Folder Options \ File Types
to associate my personal editor with ".java" file extensions.
This works fine when using Windows Explorer and double clicking on a java file, my editor is started.
However, when I attempt to click on a link with a ".java" extension when using Internet Explorer, I still get the file loaded in Notepad. I only started having this problem when I bought a new computer with XP installed a couple of months ago.
Also, when I click on a ".pdf", ",csv", link the appropriate application (Adobe , Execl) is embedded into Internet Explorer to display the file. Before, a separate window with the the appropriate application was opened, which is the way I prefer.
Any suggestions on fixing either of the above problems would be appreciated.
the workaround is toright clicksave file asProgressBarDemo.javathen open that with your text editorit will display correctly.
> This comes from standard type associations: in this
> context (.java files) the editor used is NotePad,
> which does not take
> care of CR/LF correctly. If you change the
> association to WordPad (for example), you will solve
> your problem.
This is not the problem reported by the OP.
When he clicks on a link to download a .java source file in the Java Tutorial, the server is coding the download incorrectly - instead of getting a save window that allows him to save a .java file, Internet Explorer downloads and opens the source code as a .html file.
You used to be able to click on links to source code and download and save the file - this changed some time back to what I described.
The fault is with the server, not the file associations in the OP's computer.
> the workaround is to....
Thanks, but I'm trying to understand why a work around is needed. These features worked on my last computer when I was using Windows 98. I'm guessing they should still work in XP.
I managed to solve the problem of embedding Adobe Reader in Internet Explorer. This can be configured in Adobe Reader:
a) start Adobe Reader
b) Edit \ Preferences \ Options
c) uncheck "Display PDF in Broswer"
However, I still can't find any option like this in Excel, so when clicking on a ".csv" file it is still embedded in Internet Explorer.
Another option is to use a free IDE such as Netbeans or Eclipse. These display, compile, run,debug the code very easily. The code is also highlighted and has features such as code folding to make the code easier to read.
<i>However, I still can't find any option like this in Excel, so when clicking on a ".csv" file it is still embedded in Internet Explorer.</i>
are you using the same version of internet explorer which you used on Windows 98?
it might be, that they have changed the way IE behaves...
you should try out some other browsers as well... i'm currently using Mozilla Firefox, and it allows me to specify wheter i would like to download choosen file, or to open it with program that i fancy the most.
1. Open a Explorer window (Not MS Internet Explorer).
2. Go to the Tools->Folder Options Dialog.
3. Click on the "File Types" tab.
4. Find XLS extension and highlight it.
5. Click the "Advanced" Button.
6. Uncheck the "Browse in same window" check box.
7. Click "OK" button.
> 4. Find XLS extension and highlight it.
> 5. Click the "Advanced" Button.
> 6. Uncheck the "Browse in same window" check box.
Thank you. I was looking at the CSV extension. In this case the "Browse in same window" check box is disabled. I didn't think to look at the XLS extension.