0

I am working on a barcode application which has in its main GUI a tabbed pane that contains many panels where one of this panels is for the cashier, the problem is that when the cashier panel is displayed i need to always set focus on the textfield where the barcode must be inserted. requestFocusInWindow() or requestFocus() does not work since I am in the same jframe and in the same jTabbedPane but i am choosing panels inside this tabbedpane what i need is when i move to a specific panel which is "cashier panel" is always to set focus on a certain textfield thanks.

Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69
Hsein
  • 11
  • 6

2 Answers2

1
private void MainTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {

        if(CashierPanel.isShowing()){
            Barcode_txt.requestFocus();
        }       
    } 
Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
Hsein
  • 11
  • 6
0

This may also work, when you specifying barcodeText's properties i.e. Height,Width etc set also focusable true as

barcodeText.setFocusable(true);
Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69