blob: 3e6b8bce856ddbef5fb4be5f5381577018a2108a [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>
Opening a Java editor
</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
</head>
<body>
<h1>
Opening a Java editor
</h1>
<p>
In this section, you will learn how to open an editor for Java files. You will also learn about some of the basic Java editor features.
</p>
<p>
<ol>
<li> Expand the package <em>junit.samples</em> and select the file <em>VectorTest.java</em>.&nbsp;
You can open <em>VectorTest.java</em> in the Java editor by double clicking on
it. In general you can open a Java editor for Java files, types, methods and fields by simply double
clicking on them. For example, to open the editor directly on the method <em>testClone</em>
defined in <em>VectorTest.java</em> double click on the method in the Package Explorer.</li>
<li> Notice the syntax highlighting.&nbsp; Different kinds of elements in the
java source are rendered in unique colors.&nbsp; Examples of java source
elements that are rendered differently are:
<ul>
<li> Regular comments </li>
<li> Javadoc comments </li>
<li> Keywords </li>
<li> Strings. </li>
</ul>
<p>
<img src="../images/qs-8.gif" width=528 height=459 alt="Syntax highlighting">
</p>
</li>
<li> Look at the Outline view. It displays an outline of the Java file including
the package declaration, import declarations, fields, types and methods. The
Outline view uses icons to annotate Java elements.&nbsp; For example, icons indicate whether a Java element is static, abstract,
or final.&nbsp; Different icons show you whether a method is overridden from a
base class (<img src="../images/org.eclipse.jdt.ui/ovr16/over_co.gif" width=7 height=8 alt="overridden">
) or
when it implements a method from an interface (<img src="../images/org.eclipse.jdt.ui/ovr16/implm_co.gif" width=7 height=8 alt="implements">
).
<p>
<img src="../images/qs-9.gif" width=218 height=329 alt="Outline view">
</p>
</li>
<li> Toggle the <strong>Hide Fields</strong>, <strong>Hide Static Members</strong>,
and <strong>Hide Non-Public Members</strong> buttons in the Outline view toolbar
to filter the view's display.
<p>
<img src="../images/qs-10.gif" width=220 height=92 alt="Outline view tool bar">
</p>
</li>
<li> You can edit source code by viewing the whole Java file, or you can narrow
the view to a single Java element. The toolbar includes a button, <strong>Show Source of Selected
Element Only</strong>, that will cause only the source code of the selected
outline element to be displayed in the Java editor.&nbsp; In the example
below, only the <em>setUp()</em> method is displayed.
<p>
<img src="../images/qs-11.gif" width=525 height=226 alt="Show selected element only tool bar button">
</p>
</li>
<li> Press the <strong>Show Source of Selected Element Only</strong> button
again to see the whole Java file again. In the Outline view, select different
elements and note that they are again displayed in a whole file view
in the editor. The Outline view selection now contains a range indicator
on the vertical ruler on the left border of the Java editor that indicates
the range of the selected element.
<p>
<img src="../images/qs-12.gif" width=485 height=218 alt="Range indicator">
</p>
</li>
</ol>
</p>
<p>
<img border="0" src="../images/ngrelc.gif" alt="Related concepts" width="159" height="27">
</p>
<p>
<a href="../tasks/tasks-6.htm">Java views</a><br>
<a href="../concepts/concepts-7.htm">Java editor</a><br>
</p>
<p>
<img src="../images/ngrelt.gif" alt="Related tasks" border="0" height="27" width="159">
</p>
<p>
<a href="../tasks/tasks-54.htm">Using the Java editor</a><br>
<a href="../tasks/tasks-2.htm">Showing and hiding elements</a><br>
<a href="../tasks/tasks-6.htm">Showing single elements or whole Java files</a><br>
<a href="../tasks/tasks-195.htm">Sorting elements in Java views</a><br>
</p>
<p>
<img src="../images/ngrelr.gif" width=159 height=27 alt="Related reference">
</p>
<p>
<a href="../reference/ref-view-outline.htm">Java Outline View</a><br>
<a href="../reference/ref-21.htm">Java Editor Preferences</a><br>
</p>
<p>
<a href="../hglegal2003.htm"><img src="../images/ngibmcpy2003.gif" width=324 height=14 alt="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." border="0"></a>
</p>
</body>
</html>