/ Forside / Teknologi / Udvikling / Java / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Java
#NavnPoint
molokyle 3688
Klaudi 855
strarup 740
Forvirret 660
gøgeungen 500
Teil 373
Stouenberg 360
vnc 360
pmbruun 341
10  mccracken 320
Enter skal aktiver knap
Fra : *Tweak*


Dato : 10-10-02 12:25

Hvordan laver man en knap som default, dvs aktiveres af Enter.

Hvilken key event ?

Hvis jeg bruger setMnemonic vil den have at jeg skal bruge alt+enter.

mvh
Tweak



 
 
Mikkel Bundgaard (10-10-2002)
Kommentar
Fra : Mikkel Bundgaard


Dato : 10-10-02 17:06

On Thu, 10 Oct 2002 13:25:26 +0200, *Tweak* wrote:

> Hvordan laver man en knap som default, dvs aktiveres af Enter.
>
> Hvilken key event ?
>
> Hvis jeg bruger setMnemonic vil den have at jeg skal bruge alt+enter.
>
> mvh
> Tweak
Uden at gøre mig klog på UI i Java vil jeg mene, at du skal kigge på
metoden setDefaultButton fra JRootPane

Klippet fra
(http://java.sun.com/j2se/1.4/docs/api/javax/swing/JRootPane.html#setDefaultButton(javax.swing.JButton))

public void setDefaultButton(JButton defaultButton)

Sets the defaultButton property, which determines the current
default button for this JRootPane. The default button is the
button which will be activated when a UI-defined activation event
(typically the Enter key) occurs in the root pane regardless of
whether or not the button has keyboard focus (unless there is
another component within the root pane which consumes the activation
event, such as a JTextPane). For default activation to work, the
button must be an enabled descendent of the root pane when
activation occurs. To remove a default button from this root pane,
set this property to null.

Håber du kan bruge det til noget
--
Mikkel Bundgaard
Student at IT University of Copenhagen
http://officehelp.gone.dk
Codito, Ergo Sum

*Tweak* (14-10-2002)
Kommentar
Fra : *Tweak*


Dato : 14-10-02 08:14

> Uden at gøre mig klog på UI i Java vil jeg mene, at du skal kigge på
> metoden setDefaultButton fra JRootPane
>
> Klippet fra
>
(http://java.sun.com/j2se/1.4/docs/api/javax/swing/JRootPane.html#setDefault
Button(javax.swing.JButton))
>
> public void setDefaultButton(JButton defaultButton)
>
> Sets the defaultButton property, which determines the current
> default button for this JRootPane. The default button is the
> button which will be activated when a UI-defined activation event
> (typically the Enter key) occurs in the root pane regardless of
> whether or not the button has keyboard focus (unless there is
> another component within the root pane which consumes the activation
> event, such as a JTextPane). For default activation to work, the
> button must be an enabled descendent of the root pane when
> activation occurs. To remove a default button from this root pane,
> set this property to null.
>
> Håber du kan bruge det til noget


Det kunne det, tak skal du have.....



Søg
Reklame
Statistik
Spørgsmål : 177500
Tips : 31968
Nyheder : 719565
Indlæg : 6408518
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste