반응형

JAVA에는 L&F(Look & Feel)이라는 것을 이용하여 GUI의 모양을 결정할 수 있다.

L&F를 사용하여 맥에서 window에서 실행되는 JAVA GUI처럼 MAC에서 실행되는 GUI를 바꿀 수 있다.


아래와 같은 코드를 프로그램에 넣으면 MAC에서 실행되는 자바 SWING 프로그램의 GUI를 windows 환경처럼 바꿀 수 있다.

try{

UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

}catch(Exception e){

e.printStackTrace();

}


위 사진은 MAC에서 실행한 예제이다.


위 사진은 L&F를 변경하여 MAC에서 실행한 예제이다.


내가 이 L&F를 사용하게 된 이유는 Mac에서 실행한 자바 프로그램에서 아직 원인은 모르지만 Button의 색을 바꿀때 바뀌지 않는 경우가 발생할 때가 있다.

하지만 windows에서는 같은 프로그램이지만 Button의 색이 잘 변경되어서 이 문제를 해결하기 위해 구글에서 검색하다보니 L&F라는 것을 알게되어 Button색을 바꿔줄 수 있게 되었다.


Sun's JRE에서 제공되는 L&F의 종류

Sun's JRE provides the following L&Fs:

  1. CrossPlatformLookAndFeel—this is the "Java L&F" (also called "Metal") that looks the same on all platforms. It is part of the Java API (javax.swing.plaf.metal) and is the default that will be used if you do nothing in your code to set a different L&F.

  2. SystemLookAndFeel—here, the application uses the L&F that is native to the system it is running on. The System L&F is determined at runtime, where the application asks the system to return the name of the appropriate L&F.

  3. Synth—the basis for creating your own look and feel with an XML file.

  4. Multiplexing— a way to have the UI methods delegate to a number of different look and feel implementations at the same time.

* 참고 사이트

https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

반응형

+ Recent posts