Building a Java text editor
This step is for JBuilder Professional and Enterprise only. Foundation users skip this step and go to Step 15.
The DBTextDataBinder
component adds a right-click menu to Swing text components for performing simple editing tasks such as cutting, copying, or pasting clipboard data. DBTextDataBinder
also has built-in actions to load and save files into a JTextArea
, but they don't allow you to retrieve the file name loaded or saved, which you display in your status bar. For the purposes of this tutorial, we are going to add a DBTextDataBinder
, bind it to jTextArea1
, and suppress the file Open and Save actions.
DBTextDataBinder
component
Data Access
folder in the tree as dBTextDataBinder1
.
dBTextDataBinder1
in the component tree, and then click its jTextComponent
property in the Inspector.
jTextArea1
from the drop-down list.
This binds dBTextDataBinder1
to jTextArea1
by placing the following line of code in the jbInit()
method.
dBTextDataBinder1.setJTextComponent(jTextArea1);
enableFileLoading
property for dBTextDataBinder1
and set its value to false
using the drop-down arrow. Do the same thing for the enableFileSaving
property.
DBTextDataBinder
public static Action classes, but you would have to provide the icons and write the code manually.
button = productsToolBar.add(DBTextDataBinder.UNDO_ACTION); button.setText(""); button.setPreferredSize(buttonSize);
For an example of how to do this, see the TextPane sample in the JBuilder samples folder: jbuilder/samples/dbswing/TextPane
For more information on the DBTextDataBinder
component,
TextEditFrame
component in the structure pane with TextEditFrame.java
open in the editor.
dBTextDataBinder1
component. The code is highlighted in the editor.
DBTextDataBinder
source code file opens in the editor. Click the Doc tab to view the documentation.
Close the "Text Editor" application before continuing to the next step.