, - , , .. .
, , RAD-. RAD Rapid Application Development - .
NetBeans , - (OOD Object-Oriented Design).
NetBeans RAD- (GUI). Java, , , . .
, , , Java.
-, , . , - , . .
-, - , , , . : , , .
.
NetBeans 5.0 GUI-, NetBeans 5.5 . , . JavaApplicationGUI_example.
zip-, (, C:\Documents and Settings\User). NetBeans, , , . File/Open Project, , <Shift>+<Ctrl>+O. JavaApplicationGUI_example ( , ), Open Project Folder.
, Open as Main Project, .
|
|
:
/*
* GUI_application.java
*
* Created on 22 2006 ., 13:41
*/
package java_gui_example;
/**
*
* @author
*/
public class GUI_application extends javax.swing.JFrame {
/**
* Creates new form GUI_application
*/
public GUI_application() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
+Generated Code
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt)
{
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GUI_application().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem aboutMenuItem;
private javax.swing.JMenuItem contentsMenuItem;
private javax.swing.JMenuItem copyMenuItem;
private javax.swing.JMenuItem cutMenuItem;
private javax.swing.JMenuItem deleteMenuItem;
private javax.swing.JMenu editMenu;
private javax.swing.JMenuItem exitMenuItem;
private javax.swing.JMenu fileMenu;
private javax.swing.JMenu helpMenu;
private javax.swing.JMenuBar menuBar;
private javax.swing.JMenuItem openMenuItem;
private javax.swing.JMenuItem pasteMenuItem;
private javax.swing.JMenuItem saveAsMenuItem;
private javax.swing.JMenuItem saveMenuItem;
// End of variables declaration
}
. java_gui_example, , . GUI_application , :
public class GUI_application extends javax.swing.JFrame
, GUI_application, JFrame, swing, javax. extends (- -).
GUI_application() , initComponents(), +Generated Code.
, , . , .
(private)
private void exitMenuItemActionPerformed
.
public static void main(String[] args)
. Java- . . , , , .
. .
. .
|
|
, . , , Exit . .
exitMenuItemActionPerformed. , . Exit, exitMenuItemActionPerformed.
System.exit(0);
main . , , .
Design () . ( Source ) , .
.
. , , Palette () Properties () .
, - . , . . , .
, . , JButton ( Java Button Java). JButton . , . , . , , . Properties.
, , .
, . , , . jButton1, jButton2, . , .
. -, , . -, Properties, Text <Enter> . -, label. , Properties Text label, , . .
OK .
. .
|
|
( , , ) . . : , . , , . <Enter> , <Escape>.
, . , .
, Properties. . .
checkbox . , false, true.
, . .
background | |
componentPopupMenu | , . |
font | , . |
foreground | , . |
icon | , . |
text | () . |
toolTipText | , . |
border | . |
borderPainted | . |
contentAreaFilled | ( , ). |
defaultCapable | : <Enter> ( ). |
enabled | . . . |
: , toolTipText. , , .
, , (event handler) . , , Events/Action/actionPerformed.
|
|
Events , Action , actionPerformed .
, :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
, (Design), Navigator . .
jButton1ActionPerformed , :
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
, :
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
, .
- , . :
javax.swing.JOptionPane.showMessageDialog(null," ");
javax.swing , javax.swing .
. , Java - .:
- ,
, , , .
, - ( , ), , initComponents (Users Interface, UI):
import javax.swing.*;
import java.awt.*;
...
public GUI_application() {
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){};
initComponents();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
setLocation(new Point((screenSize.width-frameSize.width)/2,
(screenSize.height-frameSize.width)/2)
);
}
- Windows XP
, initComponents(), .
- Motiff, Solaris.
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
- Motiff
.
, , , , . ( NetBeans):
. . , .
, - . , . NetBeans , . , , . . NetBeans .
|
|
, , NetBeans.
- . Projects , Copy Project. , . _1, _2, . , . , - .
Projects, . , . , Close Project.
? , . , . , , . , . !
, , . , , , , , . : ! , , . , , - . , . , . , , .