Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIS3931 - Intro to JAVA Lecture Notes Set 12 12-July-05 GUI Programming –Boxes, ToolBars, TextFields and glue.

Similar presentations


Presentation on theme: "CIS3931 - Intro to JAVA Lecture Notes Set 12 12-July-05 GUI Programming –Boxes, ToolBars, TextFields and glue."— Presentation transcript:

1 CIS3931 - Intro to JAVA Lecture Notes Set 12 12-July-05 GUI Programming –Boxes, ToolBars, TextFields and glue

2 JToolBar GUI Container (you can store other GUI components inside of it) Similar to a JMenuBar … but doesn’t have to be at the top of the screen (and can contain things other than menus) Good for creating menus, text lines, etc.

3 Creating a JToolBar //Create a toolbar (simple) JToolBar sampleToolBar = new JToolBar( ); //Create a toolbar (with name) JToolBar sampleToolBar = new JToolBar(“Sample Bar”); //Setting a layout for the toolbar sampleToolBar.setLayout(new BoxLayout(sampleToolBar, BoxLayout.Y_AXIS));

4 JTextField Editable horizontal line Can have an action listener associated with it Same as the URL line in Internet Explorer http://java.sun.com/j2se/1.5.0/docs/api/javax/swi ng/JTextField.htmlhttp://java.sun.com/j2se/1.5.0/docs/api/javax/swi ng/JTextField.html Extention of JTextComponent

5 Creating a JTextField - Constructors JTextFieldJTextField() Constructs a new TextField. JTextFieldJTextField(Document doc, String text, int columns) Constructs a new JTextField that uses the given text storage model and the given number of columns.DocumentString JTextFieldJTextField(int columns) Constructs a new empty TextField with the specified number of columns. JTextFieldJTextField(String text) Constructs a new TextField initialized with the specified text.String JTextFieldJTextField(String text, int columns) Constructs a new TextField initialized with the specified text and columns.String

6 Creating a JTextField //Create a JTextField JTextfield sampleTextField = new JTextField(“sample text”);

7 Box GUI Container Similar to a JToolBar, but more customizable Best used when you want to group certain components together

8 Creating a Box //Create a Box Box sampleBox = new Box(); //Create a Box and set the layout for it Box sampleBox = new Box(BoxLayout.Y_AXIS);

9 JLabel GUI text component Used to label a JTextField or other component //Create a JLabel JLabel sampleLabel = new JLabel(“Text”);

10 Glue Not a true “glue” (doesn’t stick something somewhere…) A “filler” for GUI components Used to create space between components –By default, most layouts push components up against each other… See today’s example code for usage

11 Examples … See advancedgui.java


Download ppt "CIS3931 - Intro to JAVA Lecture Notes Set 12 12-July-05 GUI Programming –Boxes, ToolBars, TextFields and glue."

Similar presentations


Ads by Google