blob: ebb1bc49856e984a42310d4e1797c387d8739bf6 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<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">
<title>
Opening a Java editor
</title>
</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>, expand the file in the Package Explorer and double click on the method.</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.png" 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 (<img src="../images/org.eclipse.jdt.ui/ovr16/static_co.png" alt="S" >),
abstract (<img src="../images/org.eclipse.jdt.ui/ovr16/abstract_co.png" alt="A" >),
or final (<img src="../images/org.eclipse.jdt.ui/ovr16/final_co.png" alt="F" >).&nbsp; Different icons show you whether a method overrides a method from a
base class (<img src="../images/org.eclipse.jdt.ui/ovr16/over_co.png" alt="overridden">
) or
when it implements a method from an interface (<img src="../images/org.eclipse.jdt.ui/ovr16/implm_co.png" alt="implements">
).
<p>
<img src="../images/qs-9.png" 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.
Before going to the next step make sure that <STRONG>Hide Non-Public
Members</STRONG>
button is not pressed.<p>
<img src="../images/qs-10.png" 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.png" 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.png" alt="Range indicator">
</p>
</li>
</ol>
</p>
<p>
<img border="0" src="../images/ngrelc.png" alt="Related concepts" >
</p>
<p>
<a href="../concepts/concepts-6.htm">Java views</a><br>
<a href="../concepts/concepts-7.htm">Java editor</a><br>
</p>
<p>
<img src="../images/ngrelt.png" alt="Related tasks" border="0" >
</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.png" 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>
</body>
</html>