문제

I'm developing a java application and I create a dynamic JMenu by hand (depending on the input data). I add the same action for each menu item of the menu. The problem is that depending on the menu item called I would like to take a different action each time. Is there a simple way of doing this (Something like setData(Object data) for each JMenuItem or am I forced to derive from JMenuItem)?

Thanks in advance,

Iulian

도움이 되었습니까?

해결책

최신 버전의 GeneraCodicicetagcode는 1999 년에 날짜가 있으며 매우 오래되었습니다. cgi-lib.pl 라이브러리를 사용하여 서버에 이미 설치되도록 거의 설치되며 유지됩니다.최신 (가장 최근에 2012 년 8 월 16 일)

프로그램은 다음과 같아야합니다.

#!/usr/bin/perl -- 

use strict;
use warnings;

use CGI ':standard';

print header;

print <<END;
<html>
  <head><title>Hello world!</title></head>
  <body>
    <p>Hello world!</p>
  </body>
</html>
END
.

또한 명령 줄에서 프로그램을 실행하여 컴파일하고 생성하는 출력을 확인할 수 있습니다.일단 작업을 수행하면 서버로 이동할 수 있습니다

다른 팁

According to initial question and remarks, I would suggest Julian to replace its JMenuItem built with a string and an associated action with a JMenuItem built with only an action, providing both the text and the associated behaviour. This action could reference others elements from application to provide its requireds behaviour.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top