Thursday, September 6, 2007

Cubase 5 κατεβάστε

Windows, Windows Internal Internal Frames: JInternalFrame, JDesktopPane


To Nai and Eve


Back to review some basics about windows in java. Three types of sales are more used in Java Swing as far as respect.
The JFrames ordinary. What are those sales that are created in the taskbar if you use Windows.

JDialog windows that are usually modal, in which to respond before continuing with the other windows. Examples of dialogues, those windows where we are prompted to insert the location where you want to save a file.
JInternalFrame
: This is a particular class of windows. Which are embedded in a parent window, which acts as a desktop. Currently most desktop applications, follow this format. These windows can be minimized and expanded within the parent window.
In this short tutorial we will see the JInternalFrame.

Creating a JInternalFrame

Step 1: Create the Parent Frame

The first step you should do when working with InternalFrames is to create the window containing the internalFrames. This window is the father of all others is that the life cycle of all internal windows was tied to it.
The parent window will be an ordinary frame.


FramePadre public class extends JFrame implements ActionListener {
JDesktopPane desktop = new Desktop ();// Working JDesktopPane
JMenuBar bar = new JMenuBar (); / /
menu bar JMenu menu = new JMenu ("File");
itemInterna = new JMenuItem JMenuItem ("Internal Frame ");
itemSalir = new JMenuItem JMenuItem (" Exit ");
public FramePadre () {
this.setDefaultCloseOperation (JFrame.DO_NOTHING_ON_CLOSE)

... ...}}

As shown extends JFrame and implements ActionListener interface to capture events from a menu bar to enter them. In this tutorial will not develop and create a menu bar, then my policy is to address each item separately, later I realize, but if you show you the code to accomplish it.
Furthermore we can see how we declare a variable rate JDesktopPane desktop, this will allow us to assign a work surface that delimits the internalFrames.
Within the constructor of the class can call a method that we created to manage the creation of the graphical user interface, or directly put the following code.

Toolkit.getDefaultToolkit Dimension size = (). GetScreenSize ();// this.getContentPane
display (). SetLayout (null);
this.setBounds (0.0, tamaño.width, tamaño.height -30);
this.setTitle ("Sample Desktop");
this.itemInterna.addActionListener (this) / / to capture the event in item
this.itemSalir.addActionListener (this) / / idem
previous menu . add (this.itemInterna) / / the menu item we add
menu.add (this.itemSalir) / / idem
this.barra.add previous (menu) / / to add the menu bar will
this.setJMenuBar (bar) / / the frame we add the bar.
escritorio.setBackground (new Color (251,255,235 ));// a p colorcito
this.setContentPane desktop (desktop) / / add the desktop to the frame

Once done with this, we only create the method remains capture that the user click on each item of the menu. Thus we declare the method actionPerformed, imposed by the ActionListener interface, and indicated that to make each user events.

public void actionPerformed (ActionEvent e) {
if (e.getSource () == this.itemSalir) {
this.salir ();}

if (e.getSource () == this.itemInterna) { FrameInterno
inner = new FrameInterno ("Internal Frame Example");
escritorio.add (internal) / / add the frame to the desktop try {

interno.setSelected (true) / / say we start Focused
} catch ( PropertyVetoException e) {}}
}

As we see in the event that the user clicks on the menu is instantiated itemInterna a internalFrame and then adds it to the desktop. Finally we say that is initialized focused and caught the exception.

Step 2 Create an Internal Frame

To create our internal frame, we must create a class that inherits from javax.swing.JInternalFrame:


FrameInterno public class extends JInternalFrame implements ActionListener {
... / / Swing components , buttons, label etc. public
FrameInterno (String title) {
super (title,
true, / / \u200b\u200bresize
true, / / \u200b\u200bclose
true, / / \u200b\u200bmaximize
true) / / try {

minimize interfazGrafica () ;
this.setVisible (true);

} catch (Exception e) {}}


}
As we can define the buttons that will hold the frame in the upper right corner. This we define passing as arguments to the super class Boolean values \u200b\u200bif we allow that.

interfazGrafica Then in method (), write the entire interface could be:


private void interfazGrafica () throws Exception {
this.getContentPane (). SetLayout (null);
this.setSize (new Dimension ( 311, 347));
btn_cerrar.setText ("Close");
btn_cerrar.setBounds (new Rectangle (180, 270, 110, 30));
jLabel1.setText ("This is an internal frame");
jLabel1 . setBounds (new Rectangle (30, 65, 255, 35));
jLabel1.setFont (new Font ("Dialog", 1, 20));
jLabel1.setForeground (Color.blue)
this.btn_cerrar.addActionListener (this);
this.getContentPane (). add (jLabel1, null);
this.getContentPane (). add (btn_cerrar, null);}

And finally we need to make visible the frame with setVisible
Finally we define the method which requires us

interface ActionListener public void actionPerformed (ActionEvent e) {
if (e.getSource () == this.btn_cerrar) {
this.setVisible (false);
}}

With this we have a basic frame from which we can begin to play and add components such as buttons and label or anything else that comes to mind.
not stop watching it is good that when minimizing a internalFrame! Greetings

Monday, September 3, 2007

Vollyball Slogans Water

Alerts Confirmation and Java: JOptioPane, showMessageDialog, showConfirmDialog, showInputDialog, showOptionDialog

JOptionPane class is a class that inherits from JComponent. This class will allow us to create alerts or dialogs simple to apply, or display, user information.
The methods reviewed in this small tutorial will be:

  1. JOptionPane.showMessageDialog (...)
  2. JOptionPane.showConfirmDialog (....)
  3. JOptionPane.showInputDialog (...);
  4. JOptionPane.showOptionDialog (...);
Each

method has a distinctive but all they show us a window pop up that will allow us to capture user information.

  1. showMessageDialog

JOptionPane. showMessageDialog (componentePadre Component, Object message, String title, int tipoDeMensaje)

We used to display information, for example a warning that we ask the user. Let's see what are the main arguments of the method.
componentePadre : it is for example the Frame from which the call. If we want we can put in null, which is more or less the same.
Message: do we want to read the dialog.
Title: the title.
tipoDeMensaje : are constants that java will tell what kind of message we want to display. According to these icons will be shown in the dialog box. The options are

  • ERROR_MESSAGE
  • INFORMATION_MESSAGE
  • WARNING_MESSAGE
  • QUESTION_MESSAGE
  • PLAIN_MESSAGE

If we display a custom icon, we can add it to the final as an argument.
Example:

JOptionPane.showMessageDialog (null, "Access Denied", "Error",
JOptionPane.ERROR_MESSAGE)

  1. showConfirmDialog

This method serves to prompt the user for confirmation. For example, a departure confirmation system

Int response = JOptionPane. showMessageDialog (componentePadre Component, Object message, String title, int tipoDeOpcion)

Above is the short version of the method's arguments. The long version includes the type of message and the icon, if we want to customize.
The arguments are identical to the previous method. Except for the type of option, which is another constant and values \u200b\u200bcan be:

  • DEFAULT_OPTION
  • YES_NO_OPTION
  • YES_NO_CANCEL_OPTION
  • OK_CANCEL_OPTION

As we see the method returns an integer that will allow us to grasp what is the option chosen by the user. The values \u200b\u200bwill 0 to If , 1 to No, 2 to Cancel and -1 for closing window . So we ask what is the return value and take the action we want. Example

int i = JOptionPane.showConfirmDialog (this, "Really Quit Swing Hello?", "Confirm Exit", JOptionPane.YES_NO_OPTION)
if (i = = 0) {
System.exit (0);
}

  1. showInputDialog

This method gives us a window where you can insert a String. For example when we want the user to insert his name. The short version of the method is

JOptionPane.showInputDialog String response = (Object message)

This method returns a String so that it can use later. The long version of the arguments of the method is similar to previous ones.
Example:

JOptionPane.showInputDialog String name = ("Insert your Name");
this.lbl_nombre.setText (name);

We can also create a dialog box containing a combo with the default options you want to give to the user. Ahem
:

Object [] valoresPocibles = {"Pedro", "John", "Carlos"};
JOptionPane.showInputDialog Object head = (null,
"Select which is his immediate boss, "" Select Boss "
JOptionPane. QUESTION_MESSAGE, null,
valoresPocibles,
valoresPocibles [0]);
this.lbl_jefe.setText ((String) chief);

The array of possible values \u200b\u200bin a combo shows which will be the leaders who can show you. The last argument of the shows which will be selected by default

showOptionDialog

With this method we can create dialog boxes with custom buttons. Is good to give a personal touch to the dialog boxes
The method has the form: Int

JOptionPane.showOptionDialog res = ( componentePadre Component, Object message, String title, int tipoDeOpcion, tipoMensaje int, Icon icon, Object [] keys, Object botonDefault )

Here all the rest varies with the array of buttons that we have, we must emphasize that we do not have to buttons, we just have to put the text which will be released in the.

Object [] keys = {"If you give will be good," "No? ... Boo"};
JOptionPane.showOptionDialog int i = (null, "You want to go dancing This Night "," Sita "
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, buttons, buttons [0]);
System.out.println (i);

Then we take the response as it did with the confirmDialog .
Well until next time, this is the most important messages or alerts.