SetUndecorated(true);
SetBackground(new Color(255, 255, 255, 125);
SetUndecorated
源碼中的註解:
This method can only be called while the frame is not displayable. To make this frame decorated, it must be opaque and have the default shape, otherwise the IllegalComponentStateException will be thrown
即,讓窗口有默認裝飾(decorated),則窗口必須不透明。So,窗口想透明,則必須去掉默認裝飾,即第一句代碼
第二句代碼,new Color 的第 4 個參數代表透明度 a = [0, 255]
註解中還提示, setUndecorated 需要在窗口可視(setVisiable)之前調用,因爲,若讓窗口有默認裝飾,另個一條件是窗口有默認形狀