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 21:12] – [JList] roehner | en:gui-usage [2015/01/02 12:40] – [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 135: | Zeile 165: | ||
Access through Spinner | Access through Spinner | ||
<code java>int Value = (int) mySpinner.getValue();</ | <code java>int Value = (int) mySpinner.getValue();</ | ||
+ | \\ | ||
+ | ---- | ||
+ | ==== JScrollBar ==== | ||
+ | {{: | ||
+ | |||
+ | With a JScrollBar-component text, pictures or anything else can be scrolled, i.e. viewed even if it does not fit into the space of a window. | ||
+ | |||
+ | For this you create with the object-inspector an adjustmentValueChanged-eventmethod, | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | 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 // | ||
+ | |||
+ | For each menu command the Java-Editor creates a corresponding event method. | ||
+ | |||
+ | \\ | ||
+ | ---- | ||
+ | |||
+ | ==== JPopupMenu ==== | ||
+ | {{: | ||
+ | |||
+ | With a JPopupMenu-component you create a popup menu. In the example a canvas component with yellow background reacts on a rightclick and shows the popup menu. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | In the object inspector you input at the attribute // | ||
+ | |||
+ | For each menu command the Java-Editor creates a corresponding event method. | ||
+ | |||
+ | \\ | ||
+ | ---- | ||
==== JTable ==== | ==== JTable ==== | ||
{{: | {{: |
en/gui-usage.txt · Zuletzt geändert: 2022/09/02 10:20 von 127.0.0.1