Ingles 2do parcial

208 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
208
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ingles 2do parcial

  1. 1. TECHNICAL UNIVERSITY OF MANABI FACULTY OF COMPUTER ENGLISH PROJECT TOPIC: PARTIAL 2ND PROJECT ENGLISH NAME: HARRY OSTAIZA 3”C” TEACHER: DANY JARRE PERIOD:SEPTEMBER 2012-FEBRUAARY 2013
  2. 2. INTRODUCTION TO SWINGSwing is one of the major improvements that have experienced the JDK in version 1.2with respect to version 1.1, and represents the new generation of AWT. It is also one ofthe API of Basics Classes Java (JFC), which is the result of a collaborative effortbetween Sun large, Netscape, IBM and other companies. Swing what gives power itsimportance is offered to develop graphical user interfaces (GUI) for appletsAnd applications. The quantity and quality of checks Swing GUI offering is unrivaledin any other toolkit controls GUI .the source Swing GUI that presents can find onInternet Basics Classes Netscape (IFC). Swing components beyond the IFC, to theextent that there is no significant similarity between the components of IFC Swing.Swing also offers the possibility of quickly and easily changes the look and feel (L & F)of a single component or component group. This possibility, known with aspect and feelPluggable (PL & F), is a hallmark of Swing.Abstract Windows Toolkit (AWT) is the original toolkitJava. Its main advantages are that comes with each version of Java technology,including Java applications in old browsers, and is very stable.AWT is a very simple set of tools with few components with layout managers, andevents. This is because Sun Microsystems decided to use the lowest commondenominator (LCD) for AWT approach.The content of AWT:ObjectCheckboxGroupComponentButtonCanvasCheckBoxChoiceContainerPanelAppletScrollPaneWindowDialogFrameLabelListTextComponentTextArea
  3. 3. TextFieldMenuComponentMenuItemCheckboxMenuItemMenuPopupMenuLayoutManagerFlowLayoutGridLayoutLayoutManager2BorderLayoutCardLayoutGridBagLayoutEventObjectAWTEventActionEventAdjustmentEventComponentEventContainerEventFocusEventInputEventKeyEventMouseEventMouseWheelEventPaintEventWindowEventHierarchyEventInputMethodEventInvocationEventItemEventTextEvent
  4. 4. SWINGJava Swing, also known as part of the Java Foundation Classes (JFC), was an attempt tosolve most of the shortcomings of AWT. In Swing, Sun created a beautifully designed,flexible and powerful set of tools.Unfortunately, this means that Swing takes time to learn, and is sometimes too complexfor common situations.Swing is built on AWT parts. All parts are also part of SwingAWT. Swing uses the AWT event model and support classes, such as colors, imagesand graphics. Swing components, layout managers, and events are summarized below.ObjectComponentContainerJComponentAbstractButtonJButtonJMenuItemJCheckBonMenuItemJMenuJRadioButonMenuItemJToggleButtonJCheckBoxJRadioButtonBoxFillerJColorChooserJComboBoxJDesktopIconJFileChooserJInternalFrameJLabelJLayeredPaneJDesktopPaneJListJMenuBarJOptionPaneJPanelJPopupMenuJProgressBarJRootPaneJScrollBarJScrollPane
  5. 5. JSeparatorJSliderJSplitPaneJTabbedPaneJTableJTableHeaderJTextComponentJEditorPaneFrameEditorPaneJTextPaneJTextAreaJtextFieldJPasswordFieldJToolBarJToolTipJTreeJViewportScrollableTabViewpotPanelAppletJAppletWindowDialogJDialogFrameJFrameJWindow*LayoutmanagerCenterLayoutLayoutManager2BoxLayoutOverlayLayoutSpringLayoutEventObjectAWTEventAncestorEventComponentEventInputEventKeyEventMenuKeyEventMouseEventMenuDragMouseEventInternalFrameEvent
  6. 6. BUILD A WINDOWImport javax.swing.*;public class Trigo extends JFrame{}The first line simply import the package where the class is defined JFrame. A JFrame isthe class that represents the type "Window". In other words a "JFrame" is a Windowsoperating system. As our class inherits (extends) the class JFrame, Wheat will thereforealso a JFrame is a window.To check this add to our class a "main" method, now being as follows:import javax.swing.*;public class Trigo extends JFrame{public static void main(String[] arg){Trigo miAplicacion = new Trigo();miAplicacion.setBounds(10,10,200,200);miAplicacion.pack(); miAplicacion.setVisible(true); } }All messages sent to the object "myapp" are methods inherited from "JFrame". The firstmethod "setBounds" sets the initial position of the window on the screen and itsdimensions. The second, "pack", at this time it was not really necessary because thewindow is empty, but we wanted to include it to avoid having to modify the main later.This method optimizes the arrangement of the elements within the window. And the lastmessage is simply to order the sale is made visible. After compiling and running thecode you see something like the screen shown in Figure 1.
  7. 7. THE BORDERLAYOUT MANAGERThe steps to set the BorderLayout manager are different from those used for theFlowLayout manager. 1. Create buttons (Button class objects) and the layout manager (BorderLayout class object) Button btnOeste = new Button(); BorderLayout borderLayout1 = new BorderLayout(); 2. Set its properties in init btnOeste.setFont(new Font("Dialog", 1, 16)); btn1.setLabel("Oeste");Add the controls to the applet (or panel) using add, in the second argument indicatingthe position you occupy each panel control by static BorderLayout class.this.add (btnOeste, BorderLayout.WEST); FLOWLAYOUT MANAGERControls are objects of the Button class, and the layout manager is an object of the classFlowLayout. Once initialized data members in member function init set their propertiesand add the applet using the add function, once established by the layout managersetLayout. The steps are as follows1. Create buttons (Button class objects) and design manager (class object FlowLayout) Button btn1 = new Button (); FlowLayout1 = new FlowLayout FlowLayout ();2. Set its properties in init
  8. 8. btn1.setFont (new Font ("Dialog", 1, 16)); btn1.setLabel ("1"); flowLayout1.setHgap (20);3. Set the applets layout manager (or Blank) by setLayout this.setLayout (flowLayout1);4. Add the controls to the applet (or panel) by add this.add (btn1, null);What has been said for a voucher for any panel applet as an applet is simply aspecialized panel. GRIDLAYOUTThe steps to set the GridLayout manager are identical to those we have used fordetermining lel FlowLayout manager. This manager controls available in a matrix formas shown in Fig. We have eight buttons arranged in two rows and four columns. JPANELa JPanel object is a so-called "containers". This is because they serve to contain otherobjects. In this way, they act as "boxes" where are you getting them to handle things andso as a group. For example, if you group a series of buttons inside a JPanel and want todisable them all at once, you can disable the JPanel that contains all the contents and sois disabled. Or if you want to move them all at once, etc..
  9. 9. The containers are very useful as they help to simplify things and structure them.Dialogs (JOptionPane) are "tools" very useful when entering data and displayinformation; say useful because these do not need to create objects of typeBufferedReader and "pull" more code to use correct data entered as I explained brieflyin elanterior post. Among the JOptionPane entontraremos: showConfirmDialog,showInputDialog, showMessageDialog and showOptionDialog. The most used are thefirst three.SHOWMESSAGEDIALOGThis dialog box is ideal for displaying information of any kind, this replaces theSystem.out.print () The syntax is:1 JOptionPane.showMessageDialog (null, "Hello world!");- As noted in the previous line, which goes inside the "..." is the message we want toshow, for these messages can also be used to display messages concatenation andvariables at once.- What you see when you run the application is:SHOWINPUTDIALOGThis dialog box is ideal for data entry, you have to keep in mind that all that is receivedis taken as a string, but this is no problem to work with other data types, in which caseyou need to convert the string receives the type of data you need (int, float, double,etc.). The syntax is the following:
  10. 10. String x = JOptionPane.showInputDialog ("Enter a number:");JOptionPane.showMessageDialog (null, "The number entered is:" + x);- In line 1 create a variable of type String which call "ax" in this variable I store the datathat is entered with showInputDialog, like the showMessageDialog what goes into the"..." is the message that showed the user.- On line 2 show the data I got right through the variable x.- When running the application will see the following:SHOWCONFIRMDIALOGThis dialog box is of type integer, so you have to create a variable of type int to handlethis options dialog offers the above are yes, no, and cancel, the syntax is:int x = JOptionPane.showConfirmDialog (null, "You are in java?");if (x == JOptionPane.YES_OPTION) JOptionPane.showMessageDialog (null, "You have chosen SI."); else if (x == JOptionPane.NO_OPTION) JOptionPane.showMessageDialog (null, "You have chosen NOT.");
  11. 11. - On line 1 shows that create an integer variable, the null that comes before the messageis necessary, as this is taken when the user presses the Esc key or press Cancel, themessage to display is used as in the previous dialog boxes.- On lines 2 and 4 are used to make conditional respective shares according to theoption that the user has given.- In lines 3 and 5 are shown for the respective message option that the user has given.If we select if we will see the following dialog box:If instead you select will not see the following dialog box:

×