0

I have two Packages with java Class

  • PKStrings
  • PkJforms

public class classWork {
    public String[] titleMenu={
        "A","B","C","D"
    };

    public int intOption;
}

I have JFrame with menu

  • A click go jframe A,

    B click go jframe B,

    C click go jframe C,

    D click go jframe D

And other frame in same package JFram01, contains JLabel.

How to recognize if you click on "A" and show that position label?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    *"A click go jframe A, B click go jframe B, C click go jframe C, D click go jframe D"* Arrrgh! See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) For 'lots of views' this might best be done using a `CardLayout`. – Andrew Thompson Mar 17 '13 at 05:20
  • 1
    See [this answer](http://stackoverflow.com/a/15308365/418556) for how to achieve this using a `CardLayout` (and a `JOptionPane` to select cards). – Andrew Thompson Mar 17 '13 at 05:57

2 Answers2

0
I dont understand your need. "A click A go jframe A" doesnot make sense.
if you want to go to another jFrame when clicking a label
Try this

    private void yourlabelMouseClicked(java.awt.event.MouseEvent evt) {
          //  either you can hide the current jFrame by setting 
            jFrame.setVisible(false);
            newjFrame.setVisible(True);
                    or
            make these jFrames in 2 different classes that make simple invocations
        }
Viswanath Lekshmanan
  • 9,945
  • 1
  • 40
  • 64
0

From what i understand u can use a public variable in your package and store value in it using the on click event on A, B, C .....

then access that info from the jfaram you want

e.g

public String pos ="";

A onclick event(){
   pos="A";
}


finally

if(pos.compareto("A")==0){
   jlabel.settext("A");
}
LynAs
  • 6,407
  • 14
  • 48
  • 83
  • Check my Practice http://www.mediafire.com/?pjf7w6x9l6b62g8 in the class Classwork containts tittle pages if i click in jbutton "add" the title set "add". –  Mar 17 '13 at 05:16
  • set title menu on operacionesframe.java from Array String titleMenu example "Suma" when click Jbutton Sumas(menuFrame.java). –  Mar 17 '13 at 05:32
  • import pkWorking.classWork; String[] newMenu = new classWork().titleMenu; – LynAs Mar 17 '13 at 05:37