Ik heb dus een invoer scherm bovenin met verschillende cards van een cardlayout, hiermee switch ik tussen de cards.via een menu in een adnere classe.
Onderin heb ik een toetsenbord nagemaakt. Sinds de applicatie gaat draaien op een touchscreen heb je geen muis of keyboard. Maar ze meoten wel dingen kunne invoeren via de toetsenbord die ik on screen gemaakt hebt.
Nu is het zo dat ik wil weten welk object der geselecteerd is (oa Jtextfield Jcombobox ondere texfield etc etc) want dan kan ik dat vertellen aan mijn keyboard classe zodat die weet naar welke onbject de a of de r moet versturen die de gebruiker intikt op het scherm.
Hier is een gedeelte code van de cardlayout waarin ik dus wil zien welke object geselecteerd is:
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| public CenterMenu(FocusListener listener) {
cl.addFocusListener(listener);
fontButton = new Font("ARIAL", Font.BOLD, 24);
fontLabel = new Font("ARIAL", Font.PLAIN, 18);
fontText = new Font("ARIAL", Font.PLAIN, 18);
fontText = new Font("ARIAL", Font.BOLD, 15);
this.setLayout(xYLayout1);
cl = new JPanel();
cl.setLayout(cardLayout);
xYLayout1.setHeight(550);
xYLayout1.setWidth(750);
try {
requestFocus();
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
iTreinNummer = 0;
pMenu = new JPanel(xYLayout1);
pMenu.setBackground(Color.yellow);
bRoute = new JButton("Route");
bRoute.setFont(fontButton);
bRoute.addActionListener(this);
tRoute = new JTextPane();
tRoute.setText("Via dit Menu Item Kunt u Rit Informatie invoeren en/of wijzigen.");
tRoute.setFont(fontText);
tRoute.setBackground(Color.yellow);
tRoute.setForeground(Color.blue); |
etc etc invoer van de objecten ...
Java:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| public void actionPerformed(ActionEvent e) {
iTreinNummer = 0;
if (e.getSource() == bRoute) {
cardLayout.show(cl, "kaart1");
iTreinNummer = 1;
}
}
public void SetCard(String kaart) {
cardLayout.show(cl, kaart);
if (kaart == "kaart1") {
iTreinNummer = 1;
}
}
public void SetText(String text) {
if(iTreinNummer == 1) {
if(text == "DEL") {
Document document = tTreinNummer.getDocument();
try {
document.remove(document.getLength() - 1, 1);
} catch (BadLocationException ex) {
}
}
else if(text == "Clear") {
tTreinNummer.setText("");
}
else {
tTreinNummer.setText(tTreinNummer.getText() + text);
}
}
}
public void focusGained(FocusEvent e) {
System.out.println("focus gained");
}
public void focusLost(FocusEvent e) {
System.out.println("focus gained");
} |
ik heb al wat geprobeert met de foculistener maar hij vind de listener niet als ik het wil added.
alvast bedankt voor de hulp