Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop J2ME File browser Mobile Program by NetBeans

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how NetBeans develops the mobile program of J2ME file browser. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Before you start developing the J2ME file browser, you need to install the following software on your computer:

NetBeans IDE 6.5 with Mobility package installed (download)

Java Standard Development Kit (JDK) version 6. 0 (download).

The text begins:

Let's open Netbeans ide6.5.

Create a FileBrowserExample project

1. Select File = > New Project (Ctrl-Shift-N). In the categories list, select the Java ME option. In the projects list, select the Mobile Application option and click the next button.

two。 Enter FileBrowserExample in the Project name field. Change the Project location to any directory on your system.

3. Uncheck the create Hello MIDlet check box. Click the next button.

4. Leave the Java ME Wireless Kit as the selected target platform. Click the next button.

5. Click the finish button.

The project folder contains all source code and project metadata, such as project Ant scripts. The application itself will be displayed in the flow Design window of the visual Mobile designer.

Add software packages and visual MIDlet to the FileBrowserExample project

1. In the Project window, right-click to select the FileBrowserExample project, "New" = "Java package"

two。 Enter filebrowserexample in the package name field. Click the finish button.

3. In the Project window, select the Java package that filebrowserexample just created, "New" = "Visual MIDlet..."

4. Enter FileBrowserExample in the MIDlet name and MIDP Class name fields. Click the finish button.

Add components to FileBrowserExample to switch the visual MIDlet to the flow designer window.

1. Drag and drop the following components from the components Panel into the flow designer:

Startup screen

Text box

File browser

two。 Click Startup screen, and in the Properties window, change the value of the property text from null to file browser Example.

3. As shown below:

Figure 1

Add commands to FileBrowserExample

1. Open the flow designer window.

two。 Select the exit Command option from the commands section of the component Panel. Drag and drop it into the flow designer window (fileBrowser component).

3. Select the back command from the commands area of the component panel, and drag and drop it into the text box component.

Connection component

In the flow design window, click start Point on Mobile Devices and drag it to the spalshScreen component. In the same way

Connect the components shown in figure 1 together, I have encountered a problem here, how to connect?! I have been groping for a long time, ah, it is very simple, in the component window there is such a component "last screen operation"

Select him, drag it to the started command of Mobile device, then there will be an arrow prompt, then click splashScreen, and so on, you can connect other components.

1. Insert the preoperation into the source code

Switch to the Source window.

two。 Insert the following code at the end of the source code. This method is responsible for reading the selected file:

/ * Read file * / private void readFile () {try {FileConnection textFile = fileBrowser.getSelectedFile (); getTextBox (). SetString ("); InputStream fis = textFile.openInputStream (); byte [] b = new byte [1024]; int length = fis.read (b, 0, 1024); fis.close (); if (length > 0) {textBox.setString (new String (b, 0, length));}} catch (IOException ex) {ex.printStackTrace ();}}

3. Find the commandAction method in the source code: put readFile ()

Insert it into the pre-operation section of FileBrowser.SELECT_FILE_COMMAND, it's a little confusing, don't worry, just add it here:

4. See that readFile ()?

Run the project

1. Press run Master Project or select run > run Master Project.

The effect is as follows

Start debugging

Wait for the picture

The above is the editor for you to share NetBeans how to develop J2ME file browser mobile program, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report