Senin, 28 Januari 2013

Internationalizing a GUI Form

Internationalizing a GUI Form

The following tutorial takes you through some of the basic steps of internationalization in NetBeans IDE. We will set up internationalization for one form and later on design that form. Then we internationalize the whole project, which contains several forms in a few different packages. You can internationalize applications either by specifying automatic internationalization or by using a special wizard.

Internationalizing a GUI Form at Design Time

In this exercise we will open the demo Java application project, which contains a well-known find dialog created using the GUI Builder. Next, we will switch on automatic internationalization for Form FindDialog.java. In order to test our internationalized GUI form, we will add a new locale to the properties file and run the form in the non-default locale.

Opening the Example Project

  1. Download and unzip the InternationalizeDemo.zip project to any location on your computer.
  2. Choose File > Open Project (Ctrl-Shift-O), navigate to the InternationalizeDemo project that you extracted in the last step, and click Open. The project folder might be in a containing folder that is also called InternationalizeDemo.
  3. Expand Source Packages > Demo and double-click FindDialog.java. The sample form opens in the GUI Builder.
    Find Dialog
    To view a demonstration of how to create this GUI form, click View Demo.

Switch Automatic Internationalization On

  1. Select the root node in the Navigator Window (named Form FindDialog).
  2. In the Properties window, select the checkbox in the Automatic Internationalization property.
  3. Click Upgrade in the GUI Form Format Upgrade dialog box. If the checkbox is selected, the IDE creates the Bundle.properties file in the demo package as it is set in the Properties Bundle File property. If you need to have this file in a different location, you can click the ellipsis (...) button and choose a location or directly type the path in the property's text field.
  4. In the Projects window, double-click the Bundle.properties node in the Projects Window or right-click the node and choose Edit. The properties file is opened in the Source Editor. As you can see, all appropriate Keys and Values for Form FindDialog.java are generated. (The name of each key is derived from the form file name and the component Variable name. For example, the key FindDialog.jLabel1.text is generated for a component with the variable name jLabel1 placed in form file FindDialog. The value jLabel1 represents component's Text property in this example.
  5. Close the Bundle.properties file.

Handling Images in a Java GUI Application

Introduction

Handling images in an application is a common problem for many beginning Java programmers. The standard way to access images in a Java application is by using the getResource() method. This tutorial shows you how to use the IDE's GUI Builder to generate the code to include images (and other resources) in your application. In addition, you will learn how to customize the way the IDE generates image handling code.
The application that results from this tutorial will be a simple JFrame that contains one JLabel that displays a single image.

Creating the Application

  1. Choose File > New Project.
  2. In the New Project wizard, select Java > Java Application and click Next.
  3. For Project Name, type ImageDisplayApp.
  4. Clear the Create Main Class checkbox.
  5. Click Finish.

Creating the Application Form


Introduction to GUI Building

Exercise 1: Creating a Project

The first step is to create an IDE project for the application that we are going to develop. We will name our project NumberAddition.
  1. Choose File > New Project. Alternatively, you can click the New Project icon in the IDE toolbar.
  2. In the Categories pane, select the Java node. In the Projects pane, choose Java Application. Click Next.
  3. Type NumberAddition in the Project Name field and specify a path, for example, in your home directory, as the project location.
  4. (Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries for more information on this option.
  5. Deselect the Create Main Class checkbox if it is selected.
  6. Click Finish.

Exercise 2: Building the Front End

To proceed with building our interface, we need to create a Java container within which we will place the other required GUI components. In this step we'll create a container using the JFrame component. We will place the container in a new package, which will appear within the Source Packages node.

Create a JFrame container

  1. In the Projects window, right-click the NumberAddition node and choose New > Other.
  2. In the New File dialog box, choose the Swing GUI Forms category and the JFrame Form file type. Click Next.
  3. Enter NumberAdditionUI as the class name.
  4. Enter my.numberaddition as the package.
  5. Click Finish.
The IDE creates the NumberAdditionUI form and the NumberAdditionUI class within the NumberAddition application, and opens the NumberAdditionUI form in the GUI Builder. The my.NumberAddition package replaces the default package.

Developing General Java Applications

Project Setup

The application you create will contain two projects:
  • A Java Class Library project in which you will create a utility class.
  • A Java Application project with a main class that implements a method from the library project's utility class.
After you create the projects, you will add the library project to the classpath of the application project. Then you will code the application. The library project will contain a utility class with an acrostic method. The acrostic method takes an array of words as a parameter and then generates an acrostic based on those words. The MyApp project will contain a main class that calls the acrostic method and passes the words that are entered as arguments when the application is run.
Note: Strictly speaking, two projects are not needed for such a simple application. This tutorial uses two projects to demonstrate features that you might need for a more complex application.

Creating a Java Class Library Project

  1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Java. Under Projects, select Java Class Library. Click Next.
  2. Under Project Name, type MyLib. Change the Project Location to any directory on your computer. From now on, this tutorial refers to this directory as NetBeansProjects.
    Note: The path specified above should appear as follows in the Project Folder field of the wizard: /NetBeansProjects/MyLib/
  3. (Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries for more information on this option.
  4. Click Finish. The MyLib project opens in both the Projects window and the Files window.

Creating a Java Application Project

  1. Choose File > New Project. Under Categories, select Java. Under Projects, select Java Application. Click Next.
  2. Under Project Name, type MyApp. Make sure the Project Location is set to NetBeansProjects.
  3. (Optional) Check the Use Dedicated Folder for Storing Libraries checkbox.
  4. Enter acrostic.Main as the main class.
  5. Ensure that the Create Main Class checkbox is checked.
  6. Click Finish. The MyApp project is displayed in the Project window and Main.java opens in the Source Editor.

Configuring the Compilation Classpath

Since MyApp is going to depend on a class in MyLib, you have to add MyLib to the classpath of MyApp. Doing so also ensures that classes in the MyApp project can refer to classes in the MyLib project without causing compilation errors. In addition, this enables you to use code completion in the MyApp project to fill in code based on the MyLib project. In the IDE, the classpath is visually represented by the Libraries node.
To add the library's utility classes to the project classpath:
  1. In the Projects window, right-click the Libraries node for the MyApp project and choose Add Project as shown in the image below. Image showing the Add Project command that is offered when you right-click a project's node.
  2. Browse to NetBeansProjects/ and select the MyLib project folder. The Project JAR Files pane shows the JAR files that can be added to the project. Notice that a JAR file for MyLib is listed even though you have not actually built the JAR file yet. This JAR file will get built when you build and run the MyApp project.
  3. Click Add Project JAR Files.
  4. Expand the Libraries node. The MyLib project's JAR file is added to the MyApp project's classpath.

How can I get started developing Java programs with the Java Development Kit (JDK)?

Writing Java applets and applications needs development tools like JDK. The JDK includes the Java Runtime Environment, the Java compiler and the Java APIs. It's easy for both new and experienced programmers to get started.

Where can I get JDK download?
To download the latest version of the Java Development Kit (JDK), go to JDK downloads.
Developers can also refer to the Oracle Technology Network for Java Developers for everything you need to know about Java technology, including documentation and training.

What if I am new to Java?
If you are new and interested to get started developing Java programs, please refer to new to Java to find useful information for beginners.

How do I get Java certification?
Earning an Oracle Java technology certification provides a clear demonstration of the technical skills, professional dedication and motivation for which employers are willing to pay a premium. Recognized industry-wide, Oracle's Java technology training and certification options help ensure that you have the necessary skills to efficiently meet the challenges of your IT organization.
» Learn more about Java Certification
 
Java Developer Conferences
  • JavaOne is the premier Java developer conference where you can learn about the latest Java technologies, deepen your technical understanding, and ask questions directly to your fellow strategists and developers. Oracle runs annual JavaOne conferences, including the flagship JavaOne in San Francisco and regional conferences. Visit www.oracle.com/javaone for more information on upcoming events and locations.
  • Oracle Technology Network Developer Days are free, hands-on Java developer workshops conducted globally on a regular basis.
  • Oracle also sponsors a variety of third party Java technology conferences and events. Search the Oracle Events catalog for an upcoming event near you.

Computer Science vs Computer Engineering

What is computer science?

Computer science (CS) is the systematic study of algorithmic methods for representing and transforming information, including their theory, design, implementation, application, and efficiency. The discipline emerged in the 1950s from the development of computability theory and the invention of the stored-program electronic computer. The roots of computer science extend deeply into mathematics and engineering. Mathematics imparts analysis to the field; engineering imparts design. The main branches of computer science are the following:
  • Algorithms is the study of effective and efficient procedures of solving problems on a computer.
  • Theory of computation concerns the meaning and complexity of algorithms and the limits of what can be computed in principle.
  • Computer architecture concerns the structure and functionality of computers and their implementation in terms of electronic technologies.
  • Software systems is the study of the structure and implementation of large programs. It includes the study of programming languages and paradigms, programming environments, compilers, and operating systems.
  • Artificial intelligence concerns the computational understanding of what is commonly called intelligent behavior and the creation of artifacts that exhibit such behavior.
Other important topics in computer science include computer graphics, databases, networks and protocols, numerical methods, operating systems, parallel computing, simulation and modeling, and software engineering.

What is computer engineering?

Computer engineering (CEN) is the design and prototyping of computing devices and systems. While sharing much history and many areas of interest with computer science, computer engineering concentrates its effort on the ways in which computing ideas are mapped into working physical systems. Emerging equally from the disciplines of computer science and electrical engineering, computer engineering rests on the intellectual foundations of these disciplines, the basic physical sciences and mathematics. The main branches of computer engineering are the following:
  • Networks is concerned with design and implementation of distributed computing environments, from local area networks to the World Wide Web.
  • Multimedia computing is the blending of data from text, speech, music, still image, video and other sources into a coherent datastream, and its effective management, coding-decoding and display.
  • VLSI systems involves the tools, properties and design of micro-miniaturized electronic devices (Very Large Scale Integrated circuits).
  • Reliable computing and advanced architectures considers how fault-tolerance can be built into hardware and software, methods for parallel computing, optical computing, and testing.
Other important topics in computer engineering include display engineering, image and speech processing, pattern recognition, robotics, sensors and computer perception.

Should I pursue computer science or computer engineering?

Scientists and engineers are both interested in the nature of things, in understanding how ideas and objects in the world fit together. But in general, they seek to understand the nature of reality with different ends in mind: the scientist seeks this understanding as an end in itself, the engineer in order to build things. Thus CS is closer to the underlying theory of computation, with its roots in mathematics, and CEN is closer to the design of physical devices, with roots in physics and chemistry as well. Students with an urge to build things, to measure how things work in the laboratory, those attracted to physics and chemistry as well as mathematics, should seriously consider CEN. Students with an interest in the true nature of symbols, information and their manipulations, the forms and limits of algorithms and data structures, should consider CS. Of the three great divisions in computing, namely theory, software and hardware, to a first approximation theory goes with CS, hardware with CEN, and software with both, but mainly with CS. The more general the software, the closer to CS; the more hardware-specific, the closer to CEN. Thus a student interested in creating his own new general-purpose computer language would best be served by a CS degree program, while one interested in designing a software interface for a new high speed serial device by the CEN degree program. Students undecided between the CS and CEN programs are urged to discuss the matter in depth with academic advisors within the CSE department, the College of Arts and Sciences (which administers the CS programs), and the School of Engineering and Applied Sciences (which administers the CEN program).

What is Computer Science?


  • Computer science is a discipline that spans theory and practice. It requires thinking both in abstract terms and in concrete terms. The practical side of computing can be seen everywhere. Nowadays, practically everyone is a computer user, and many people are even computer programmers. Getting computers to do what you want them to do requires intensive hands-on experience. But computer science can be seen on a higher level, as a science of problem solving. Computer scientists must be adept at modeling and analyzing problems. They must also be able to design solutions and verify that they are correct. Problem solving requires precision, creativity, and careful reasoning. Computer science also has strong connections to other disciplines. Many problems in science, engineering, health care, business, and other areas can be solved effectively with computers, but finding a solution requires both computer science expertise and knowledge of the particular application domain. Thus, computer scientists often become proficient in other subjects.
    Finally, computer science has a wide range of specialties. These include computer architecture, software systems, graphics, artifical intelligence, computational science, and software engineering. Drawing from a common core of computer science knowledge, each specialty area focuses on particular challenges.
  • Computer Science is practiced by mathematicians, scientists and engineers. Mathematics, the origins of Computer Science, provides reason and logic. Science provides the methodology for learning and refinement. Engineering provides the techniques for building hardware and software. Finally, and most importantly, computer scientists are computer scientists because it is fun. (Not to mention lucrative career opportunities!)

  • Another definition from http://www.csab.org/comp_sci_profession.html Computer Science: The Profession
    Computer science is a discipline that involves the understanding and design of computers and computational processes. In its most general form it is concerned with the understanding of information transfer and transformation. Particular interest is placed on making processes efficient and endowing them with some form of intelligence. The discipline ranges from theoretical studies of algorithms to practical problems of implementation in terms of computational hardware and software.
    A central focus is on processes for handling and manipulating information. Thus, the discipline spans both advancing the fundamental understanding of algorithms and information processes in general as well as the practical design of efficient reliable software and hardware to meet given specifications. Computer science is a young discipline that is evolving rapidly from its beginnings in the 1940's. As such it includes theoretical studies, experimental methods, and engineering design all in one discipline. This differs radically from most physical sciences that separate the understanding and advancement of the science from the applications of the science in fields of engineering design and implementation. In computer science there is an inherent intermingling of the theoretical concepts of computability and algorithmic efficiency with the modern practical advancements in electronics that continue to stimulate advances in the discipline. It is this close interaction of the theoretical and design aspects of the field that binds them together into a single discipline.
    Because of the rapid evolution it is difficult to provide a complete list of computer science areas. Yet it is clear that some of the crucial areas are theory, algorithms and data structures, programming methodology and languages, and computer elements and architecture. Other areas include software engineering, artificial intelligence, computer networking and communication, database systems, parallel computation, distributed computation, computer-human interaction, computer graphics, operating systems, and numerical and symbolic computation.
    A professional computer scientist must have a firm foundation in the crucial areas of the field and will most likely have an in-depth knowledge in one or more of the other areas of the discipline, depending upon the person's particular area of practice. Thus, a well educated computer scientist should be able to apply the fundamental concepts and techniques of computation, algorithms, and computer design to a specific design problem. The work includes detailing of specifications, analysis of the problem, and provides a design that functions as desired, has satisfactory performance, is reliable and maintainable, and meets desired cost criteria. Clearly, the computer scientist must not only have sufficient training in the computer science areas to be able to accomplish such tasks, but must also have a firm understanding in areas of mathematics and science, as well as a broad education in liberal studies to provide a basis for understanding the societal implications of the work being performed.