en:gui-usage
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende ÜberarbeitungNächste ÜberarbeitungBeide Seiten der Revision | ||
en:gui-usage [2014/12/30 22:31] – [JSpinner] roehner | en:gui-usage [2015/01/01 22:48] – [JMenu] roehner | ||
---|---|---|---|
Zeile 117: | Zeile 117: | ||
---- | ---- | ||
+ | |||
+ | ==== JComboBox ==== | ||
+ | {{: | ||
+ | |||
+ | A JComboBox component is a combination of an editable inputline and and a drop down list. | ||
+ | At runtime the user can select an item from th drop down list or input text. | ||
+ | |||
+ | |||
+ | With the object-inspector you can enter strings into the //Items// attribute for the drop down list of the JComboBox. To enable input in the inputline you set the // | ||
+ | |||
+ | The data of a JCombobBox are managed in a // | ||
+ | |||
+ | Examples | ||
+ | |||
+ | Access through ComboBoxModel: | ||
+ | <code java> | ||
+ | myComboBoxModel.addElement(" | ||
+ | myComboBoxModel.removeElementAt(0); | ||
+ | String s = (String) myComboBoxModel.getElementAt(3);</ | ||
+ | |||
+ | The ComboBoxModel knows all elements, but an element is selected in the ComboBox, not in the ComboBoxModel. | ||
+ | |||
+ | Access through ComboBox: | ||
+ | <code java> | ||
+ | String s = (String) myComboBox.getSelectedItem();</ | ||
+ | |||
+ | To react automatically on an input in the inputline or selection from the drop down list you set the // | ||
+ | |||
+ | ---- | ||
+ | |||
==== JSpinner ==== | ==== JSpinner ==== | ||
Zeile 147: | Zeile 177: | ||
you get the JScrollBar-value and do the scrolling according to it. | you get the JScrollBar-value and do the scrolling according to it. | ||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== JScrollPane ==== | ||
+ | {{: | ||
+ | |||
+ | A JScrollPane-component provides a horizontal and a vertical JScrollBar-component for a twodimensional scrolling. | ||
+ | |||
+ | The Java-Editor adds to JTextArea, JList, JTable, JTree, JEditorPane und JTextPane-components automatically a JScrollPane-component. | ||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== JPanel ==== | ||
+ | {{: | ||
+ | |||
+ | JPanel-components are used for structuring of graphical user interfaces. Each JPanel-component is a container which can hold other gui-components. With the object-inspector you can set a border to a JPanel-component. | ||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== Canvas ==== | ||
+ | {{: | ||
+ | |||
+ | A Canvas-component provides a drawing-area. | ||
+ | |||
+ | To draw on the drawing-area you can get a graphic-context from the Canvas-component. This graphic-context is used as a paint-box with many drawing-possibilities. | ||
+ | |||
+ | You get the graphics-context from your Canvas-component in this way: | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | With the graphics-context you are able to draw e. g. a rectangle: | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | If you minimize your Java-Application with a Canvas-component und show it up again, the content of the Canvas-Component is lost. To avoid this, you have to create a subclass from Canvas and do the drawing in the // | ||
+ | |||
+ | |||
+ | The turtle which belongs to the Java-Editor is an example of a Canvas-subclass.\\ | ||
+ | ---- | ||
+ | |||
+ | ==== Turtle ==== | ||
+ | {{: | ||
+ | |||
+ | The Turtle-component provides a drawing-area, | ||
+ | |||
+ | As a didactic reduction the turtle has a // | ||
+ | |||
+ | Example: | ||
+ | {{: | ||
+ | |||
+ | The Turtle and it's documentation must be installed inside des Java-Editor configuration. | ||
+ | |||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== JMenuBar ==== | ||
+ | {{: | ||
+ | |||
+ | With a JMenuBar-component you can create a menu bar. The configuration is done via the menus (JMenu-components) | ||
+ | to be displayed in the menu bar. | ||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== JMenu ==== | ||
+ | {{: | ||
+ | |||
+ | With a JMenu-component you create a menu for a menu bar. In the object-inspector you specify the desired menu bar at the //MenuBar// attribute, the menu commands (e. g. New, Open, Save, Print, Exit) at the // | ||
+ | |||
\\ | \\ | ||
---- | ---- |
en/gui-usage.txt · Zuletzt geändert: 2022/09/02 10:20 von 127.0.0.1