=================================
=================================
=================================
출처: http://techalpine.com/how-to-create-translucent-and-shaped-windows-in-java/
How to create Translucent and Shaped Windows in Java?
=================================
=================================
=================================
출처: https://m.blog.naver.com/PostView.nhn?blogId=sarah7_2000&logNo=220611615388&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Test extends JFrame implements MouseMotionListener, MouseListener
{
MyPanel panel;
Point ptFirst;
JButton btn;
public Test()
{
setUndecorated(true); //이걸 해줘야 타이틀 바가 사라진다.
setBackground(new Color(0, 0, 0, 0));//
panel = new MyPanel("bogo.png");
setContentPane(panel);
//getContentPane().setBackground(Color.BLACK);
//버튼 넣기
btn = new JButton("button");
btn.setBounds(200, 200, 100, 50);
panel.setLayout(null);
panel.add(btn);
setSize(512, 512);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addMouseMotionListener(this);
addMouseListener(this);
}
@Override
public void mouseDragged(MouseEvent e)
{
Point loc = e.getLocationOnScreen();
loc.x -= ptFirst.x;
loc.y -= ptFirst.y;
setLocation(loc);//프레임창 움직이기
}
@Override
public void mouseMoved(MouseEvent e)
{
}
@Override
public void mouseClicked(MouseEvent e)
{
}
@Override
public void mouseEntered(MouseEvent e)
{
}
@Override
public void mouseExited(MouseEvent e)
{
}
@Override
public void mousePressed(MouseEvent e)
{
ptFirst = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e)
{
}
public static void main(String args[])
{
new Test();
}
}
class MyPanel extends JPanel
{
Image image;
MyPanel(String img)
{
image = Toolkit.getDefaultToolkit().createImage(img);
setOpaque(false);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
if (image != null)
{
g.drawImage(image, 0, 0, this);
}
Graphics2D g2d = (Graphics2D) g.create();
// 50% transparent Alpha
//g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
// 100% transparent Alpha
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.0f));
g2d.setColor(getBackground());
g2d.fill(getBounds());
g2d.dispose();
}
}
=================================
=================================
=================================
출처: http://www.jaso.co.kr/index.php/2005/11/untitled24/
Swing을 이용하여 투명한 윈도우나 사각형이 아닌 여러가지 모양의 윈도우를 만들수 있는 방법이 ONJava.com에 올라와 있네요…
그래서 저도 한번 해봤습니다.
public class TransparentBackground extends JComponent implements
ComponentListener, WindowFocusListener, Runnable
{
private JFrame frame;
private Image background;
private long lastupdate = 0;
public boolean refreshRequested = true;
public TransparentBackground(JFrame frame)
{
this.frame = frame;
updateBackground();
frame.addComponentListener(this);
frame.addWindowFocusListener(this);
new Thread(this).start();
}
public void updateBackground()
{
try
{
Robot rbt = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
background = rbt.createScreenCapture(new Rectangle(0, 0, (int) dim
.getWidth(), (int) dim.getHeight()));
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void paintComponent(Graphics g)
{
Point pos = this.getLocationOnScreen();
Point offset = new Point(-pos.x, -pos.y);
g.drawImage(background, offset.x, offset.y, null);
}
public void componentShown(ComponentEvent evt)
{
repaint();
}
public void componentResized(ComponentEvent evt)
{
repaint();
}
public void componentMoved(ComponentEvent evt)
{
repaint();
}
public void componentHidden(ComponentEvent evt)
{
}
public void windowGainedFocus(WindowEvent evt)
{
refresh();
}
public void windowLostFocus(WindowEvent evt)
{
refresh();
}
public void refresh()
{
if (frame.isVisible())
{
repaint();
refreshRequested = true;
lastupdate = new Date().getTime();
}
}
public void run()
{
try
{
while (true)
{
Thread.sleep(250);
long now = new Date().getTime();
if (refreshRequested && ((now – lastupdate) > 1000))
{
if (frame.isVisible())
{
Point location = frame.getLocation();
frame.setVisible(false);
updateBackground();
frame.setVisible(true);
frame.setLocation(location);
refresh();
}
lastupdate = now;
refreshRequested = false;
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
원리는 updateBackground() 가 호출될 때 현재 영역의 Screen을 캡쳐한 다음 paintComponent() 메소드가 호출될 때 캡쳐한 이미지를 보여 주는 것입니다.
public class TransparentWindowExample
{
public static void main(String[] args)
{
JFrame frame = new JFrame(“배경이 투명한 윈도우”);
TransparentBackground bg = new TransparentBackground(frame);
bg.setLayout(new BorderLayout());
JButton button = new JButton(“버튼 Component”);
bg.add(“North”, button);
JLabel label = new JLabel(“이것은 새로 생성한 윈도우에서 만든겁니다”);
bg.add(“South”, label);
frame.getContentPane().add(“Center”, bg);
frame.pack();
frame.setSize(150, 100);
frame.setVisible(true);
}
}
문제는 투명도 % 조정이 안된다는 것입니다. ^^
다음은 똑같은 내용으로 이미지를 이용하여 윈도우를 만든 것입니다.
이미지 만들때 배경이 투명하게 만들어야 합니다.
public class TransparentWindowExample
{
public static void main(String[] args)
{
JFrame frame = new JFrame(“Transparent Window”);
frame.setUndecorated(true);
TransparentBackground bg = new TransparentBackground(frame);
bg.setLayout(new BorderLayout());JPanel panel = new JPanel() {
public void paintComponent(Graphics g)
{
g.setColor(Color.blue);
Image img = new
ImageIcon(“clock.png”).getImage();
g.drawImage(img, 0, 0, null);
}
};
panel.setOpaque(false);bg.add(“Center”, panel);
frame.getContentPane().add(“Center”, bg);
frame.pack();
frame.setSize(200, 200);
frame.setLocation(200, 200);
frame.setVisible(true);
}}
– 원본이미지
– 실행결과
=================================
=================================
=================================
출처: http://egloos.zum.com/tobby48/v/2923010
[Java] 프레임 이동, 투명, 모양 정의한 예제소스
급하게 해서 주석이 없는 .....
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Point;
import java.awt.Shape;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.geom.RoundRectangle2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MovePanel extends JFrame implements ComponentListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public JPanel jPanel1 = new JPanel(){
/* (non-Javadoc)
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
protected void paintComponent(Graphics g) {
if (g instanceof Graphics2D) {
Paint p = new GradientPaint(getWidth(), getHeight(), new Color(221, 221, 221, 50), 0.0f, 0.0f,
new Color(221, 221, 221, 150), true);
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(p);
g2d.fillRect(0, 0, getWidth(), getHeight());
} else {
super.paintComponent(g);
}
}
};
/* move by mouse pointer */
Point mainFrameLocation = new Point(0, 0);
Point mouseClickedLocation = new Point(0, 0);
public MovePanel() {
// jPanel1.setOpaque(true);
addMouseListener(new FrameMove_mouseAdapter(this));
addMouseMotionListener(new FrameMove_mouseMotionAdapter(this));
/* root frame */
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new Dimension(200, 200));
setUndecorated(true);
getContentPane().add(jPanel1, BorderLayout.CENTER);
setLocationRelativeTo(null);
addComponentListener(this);
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
MovePanel mainFrame = new MovePanel();
mainFrame.setVisible(true);
com.sun.awt.AWTUtilities.setWindowOpacity(mainFrame, 80.0f / 100.0f);
}
});
}
public void componentHidden(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentResized(ComponentEvent arg0) {
// TODO Auto-generated method stub
Shape shape = new RoundRectangle2D.Float(0, 0, getWidth(),
getHeight(), 20, 20);
com.sun.awt.AWTUtilities.setWindowShape(this, shape);
}
public void componentShown(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
}
/**
* @author tobby48 2009. 07. 22
*/
class FrameMove_mouseAdapter extends MouseAdapter {
private MovePanel frame;
FrameMove_mouseAdapter(MovePanel mainframe) {
this.frame = mainframe;
}
public void mousePressed(MouseEvent e) {
frame.mouseClickedLocation.x = e.getX();
frame.mouseClickedLocation.y = e.getY();
}
public void mouseReleased(MouseEvent e) {
}
}
/**
* @author tobby48 2009. 07. 22
*/
class FrameMove_mouseMotionAdapter extends MouseMotionAdapter {
private MovePanel frame;
FrameMove_mouseMotionAdapter(MovePanel mainframe) {
this.frame = mainframe;
}
public void mouseMove(MouseEvent e) {}
public void mouseDragged(MouseEvent e) {
frame.setLocation(e.getLocationOnScreen().x - frame.mouseClickedLocation.x,
e.getLocationOnScreen().y - frame.mouseClickedLocation.y);
}
}
출처: http://levin01.tistory.com/238
[펌] 자바 스윙으로 반투명창을 만들수 있을까?
질문:자바 스윙으로 반투명창을 만들수 있을까? | being20c/ 2004-02-18 15:59 |
음.. 예전에 자바로 작성된 프로그램중에 반투명으로 표시되는.. 그러니까 창이 뜨면 뒤에 배경까지 보이는 반투명으로된 프로그램을 본듯 한데.. 어떻게 하는 것인가요? JFrame이나 Frame의 LayerPane에 반투명을 설정하는 메소드가 있는 건가요? Document 뒤져봐도 찾을수 가 없군요.. 혹시 아시는분 답변좀.. |
|
답변:re: 자바 스윙으로 반투명창을 만들수 있을까? | imsangchin/ 2004-02-17 22:04 |
다음은, swing을 이용한, 투명 윈도우 만드는 소스 입니다.참고로, java에서는 JFrame, JWindow같은, 중량 컴포넌트에 대해서 투명도를 설정할수 있는 메소드를 제공하지는 않습니다.위소스는 편법으로, Robet클래스를 이용해서, 배경화면을 캡쳐해서, 현재 윈도우가 투명하게끔 보이게 만든 것입니다. 흠이라면, 약간 속도 처리가 느리다는거죠.일반적으로 반투명윈도우 는 주로 VC++로 만든 프로그램입니다. VC++에서는 윈도우를 반투명으로 만드는 API를 제공하거든요. import java.awt.*; import java.awt.event.*; import javax.swing.*;public class TransparentWnd extends JWindow implements FocusListener, MouseMotionListener, MouseListener { Image img, tim; Graphics tig; Point mp; Robot r; public TransparentWnd() { setBounds(170, 170, 100, 100); try { r = new Robot(); } catch (AWTException awe) { System.out.println("robot excepton occurred"); } capture(); addMouseMotionListener(this); addMouseListener(this); addFocusListener(this); setVisible(true); } public void mouseDragged(MouseEvent m) { if (mp == null) { return; } Point p = m.getPoint(); int x = getX() + p.x - mp.x; int y = getY() + p.y - mp.y; setLocation(x, y); paintP(getGraphics()); } public void mouseMoved(MouseEvent m) {} public void mouseClicked(MouseEvent m) {} public void mouseEntered(MouseEvent m) {} public void mouseExited(MouseEvent m) {} public void mouseReleased(MouseEvent m) { mp = null; } public void mousePressed(MouseEvent m) { mp = m.getPoint(); } public void focusGained(FocusEvent fe) { setSize(0, 0); capture(); setSize(100, 100); } public void focusLost (FocusEvent fe) {} public void capture() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); img = r.createScreenCapture(new Rectangle(0, 0, d.width, d.height)); } public void captureX() { Rectangle rect = getBounds(); setVisible(false); Thread.yield(); Image xmg = r.createScreenCapture(rect); img.getGraphics().drawImage(xmg, rect.x, rect.y, rect.width, rect.height, null); setVisible(true); } public void paint(Graphics g) { Rectangle rect = g.getClipBounds(); if (tim == null) { tim = createImage(getWidth(), getHeight()); tig = tim.getGraphics(); } if (!rect.getSize().equals(getSize())) { captureX(); } else { paintP(g); } } public void paintP(Graphics g) { tig.drawImage(img, 0, 0, getWidth(), getHeight(), getX(), getY(), getX() + getWidth(), getY() + getHeight(), null); tig.setColor(Color.orange); tig.fillOval(10, 20, 70, 80); tig.setColor(Color.green); tig.fillOval(21, 16, 20, 10); tig.fillOval(40, 02, 11, 21); g.drawImage(tim, 0, 0, null); } public void update(Graphics g) { this.paint(g); } public static void main(String[] args) { new TransparentWnd(); } } |
=================================
=================================
=================================
출처: https://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html
Determining a Platform's Capabilities
Not all platforms support all of these capabilities. An UnsupportedOperationException
exception is thrown when code attempts to invoke the setShape
or setOpacity
methods on a platform that does not support these capabilities. Therefore, it is best practice to first check that the platform supports the capability that you want to implement. The GraphicsDevice
class provides theisWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
method that you can use for this purpose. You pass one of three enum values, defined in GraphicsDevice.WindowTranslucency
, to this method:
TRANSLUCENT
– The underlying platform supports windows with uniform translucency, where each pixel has the same alpha value.PERPIXEL_TRANSLUCENT
– The underlying platform supports windows with per-pixel translucency. This capability is required to implement windows that fade away.PERPIXEL_TRANSPARENT
– The underlying platform supports shaped windows.
The GraphicsConfiguration
class also provides the isTranslucencyCapable
method to determine if PERPIXEL_TRANSLUCENT
translucency is supported by the given GraphicsConfiguration
object.
Version note: The translucent and shaped window API was first added to the Java SE 6 Update 10 release as a private API. This functionality was moved to the public AWT package in the JDK 7 release. This tutorial describes the API that is available in the JDK 7 release. See Java SE 6 Update 10 API for a mapping of the private API in the Java SE 6 Update 10 release to the public API in the JDK 7 release.
The following code shows how to check for all three capabilities:
import static java.awt.GraphicsDevice.WindowTranslucency.*; // Determine what the default GraphicsDevice can support. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); boolean isUniformTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT); boolean isPerPixelTranslucencySupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT); boolean isShapedWindowSupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
Note: None of these capabilities work on windows in full-screen mode. Invoking any of the relevant methods while in full-screen mode causes an
IllegalComponentStateException
exception to be thrown.How to Implement Uniform Translucency
You can create a window where each pixel has the same translucency by invoking the setOpacity(float)
method in the Window
class. The float
argument passed to this method represents the translucency of the window and should be a value between 0 and 1, inclusive. The smaller the number, the more transparent the window. There is also a corresponding getOpacity
method.
The
example creates a window that is 55 percent opaque (45 percent translucent). If the underlying platform does not support translucent windows, the example exits. The code relating to opacity is shown in bold.TranslucentWindowDemo.java
import java.awt.*; import javax.swing.*; import static java.awt.GraphicsDevice.WindowTranslucency.*; public class TranslucentWindowDemo extends JFrame { public TranslucentWindowDemo() { super("TranslucentWindow"); setLayout(new GridBagLayout()); setSize(300,200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add a sample button. add(new JButton("I am a Button")); } public static void main(String[] args) { // Determine if the GraphicsDevice supports translucency. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); //If translucent windows aren't supported, exit. if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) { System.err.println( "Translucency is not supported"); System.exit(0); } JFrame.setDefaultLookAndFeelDecorated(true); // Create the GUI on the event-dispatching thread SwingUtilities.invokeLater(new Runnable() { @Override public void run() { TranslucentWindowDemo tw = new TranslucentWindowDemo(); // Set the window to 55% opaque (45% translucent). tw.setOpacity(0.55f); // Display the window. tw.setVisible(true); } }); } }
Note that the button is also affected by the uniform translucency. Setting the opacity affects the whole window, including any components that the window contains.
How to Implement Per-Pixel Translucency
Creating a window that uses per-pixel translucency involves defining alpha values over the rectangular area that the window occupies. When a pixel's alpha value is zero, that pixel is fully transparent. When a pixel's alpha value is 255, that pixel is fully opaque. When a pixel's alpha value is 128, that pixel is 50 percent translucent, and so on. An easy way to create a smooth interpolation between alpha values is to use the GradientPaint
class. The included example uses this approach.
Invoking setBackground(new Color(0,0,0,0))
on the window causes the software to use the alpha values to render per-pixel translucency. In fact, invoking setBackground(new Color(0,0,0,alpha)
, where alpha
is less than 255, installs per-pixel transparency. So, if you invoke setBackground(new Color(0,0,0,128))
and do nothing else, the window is rendered with 50 percent translucency for each background pixel. However, if you are creating your own range of alpha values, you most likely will want an alpha value of 0.
While not prohibited by the public API, you will generally want to enable per-pixel translucency on undecorated windows. In most cases, using per-pixel translucency on decorated windows does not make sense. Doing so can disable the decorations, or cause other platform-dependent side effects.
To determine if a window is using per-pixel translucency, you can use the isOpaque
method.
An example follows. First, here are the steps required to implement the example:
- Invoke
setBackground(new Color(0,0,0,0))
on the window. - Create a
JPanel
instance that overrides thepaintComponent
method. - In the
paintComponent
method, create aGradientPaint
instance. - In the example, the top of the rectangle has an alpha value of 0 (the most transparent) and the bottom has an alpha value of 255 (the most opaque). The
GradientPaint
class smoothly interpolates the alpha values from the top to the bottom of the rectangle. - Set the
GradientPaint
instance as the panel's paint method.
Here is the code for the
example. If the underlying platform does not support per-pixel translucency, this example exits. The code specifically relating to creating the gradient window is shown in bold.GradientTranslucentWindowDemo.java
import java.awt.*; import javax.swing.*; import static java.awt.GraphicsDevice.WindowTranslucency.*; public class GradientTranslucentWindowDemo extends JFrame { public GradientTranslucentWindowDemo() { super("GradientTranslucentWindow"); setBackground(new Color(0,0,0,0)); setSize(new Dimension(300,200)); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { if (g instanceof Graphics2D) { final int R = 240; final int G = 240; final int B = 240; Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0), 0.0f, getHeight(), new Color(R, G, B, 255), true); Graphics2D g2d = (Graphics2D)g; g2d.setPaint(p); g2d.fillRect(0, 0, getWidth(), getHeight()); } } }; setContentPane(panel); setLayout(new GridBagLayout()); add(new JButton("I am a Button")); } public static void main(String[] args) { // Determine what the GraphicsDevice can support. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); boolean isPerPixelTranslucencySupported = gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT); //If translucent windows aren't supported, exit. if (!isPerPixelTranslucencySupported) { System.out.println( "Per-pixel translucency is not supported"); System.exit(0); } JFrame.setDefaultLookAndFeelDecorated(true); // Create the GUI on the event-dispatching thread SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GradientTranslucentWindowDemo gtw = new GradientTranslucentWindowDemo(); // Display the window. gtw.setVisible(true); } }); } }
Note that the button is not affected by the per-pixel translucency. Setting the per-pixel translucency affects the background pixels only. If you want a window that has a uniformly translucent effect on the background pixels only, you can invoke setBackground(new Color(0,0,0,alpha))
where alpha
specifies your desired translucency.
How to Implement a Shaped Window
You can create a shaped window by invoking the setShape(Shape)
method in the Window
class. The Shape
argument that is passed to the method determines how the window is clipped. When a shape is set on a window, the window decorations are not re-formed to the new shape, so setting a shape works best on undecorated windows.
The best practice for setting the window's shape is to invoke setShape
in the componentResized
method of the component event listener. This practice will ensure that the shape is correctly calculated for the actual size of the window. The following example uses this approach.
The
example creates an oval-shaped window with 70 percent opacity. If the underlying platform does not support shaped windows, the example exits. If the underlying platform does not support translucency, the example uses a standard opaque window. You could modify this example to create a shaped window that also uses per-pixel translucency.ShapedWindowDemo.java
The code relating to shaping the window is shown in bold.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.geom.Ellipse2D; import static java.awt.GraphicsDevice.WindowTranslucency.*; public class ShapedWindowDemo extends JFrame { public ShapedWindowDemo() { super("ShapedWindow"); setLayout(new GridBagLayout()); // It is best practice to set the window's shape in // the componentResized method. Then, if the window // changes size, the shape will be correctly recalculated. addComponentListener(new ComponentAdapter() { // Give the window an elliptical shape. // If the window is resized, the shape is recalculated here. @Override public void componentResized(ComponentEvent e) { setShape(new Ellipse2D.Double(0,0,getWidth(),getHeight())); } }); setUndecorated(true); setSize(300,200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(new JButton("I am a Button")); } public static void main(String[] args) { // Determine what the GraphicsDevice can support. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); final boolean isTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT); //If shaped windows aren't supported, exit. if (!gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) { System.err.println("Shaped windows are not supported"); System.exit(0); } //If translucent windows aren't supported, //create an opaque window. if (!isTranslucencySupported) { System.out.println( "Translucency is not supported, creating an opaque window"); } // Create the GUI on the event-dispatching thread SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ShapedWindowDemo sw = new ShapedWindowDemo(); // Set the window to 70% translucency, if supported. if (isTranslucencySupported) { sw.setOpacity(0.7f); } // Display the window. sw.setVisible(true); } }); } }
=================================
=================================
=================================
'JAVA > JAVA UI' 카테고리의 다른 글
자바 Setting the text field in editable JComboBox 커스텀 라벨, 에디터 (0) | 2020.09.15 |
---|---|
자바 JComboBox 콤보 리스트들의 텍스트 말줄임 ELLIPSIS 관련 (0) | 2020.09.15 |
Visual Editor, jigloo를 대체할 Swing/SWT 플러그인 WindowBuilder (0) | 2014.10.17 |
JAVA swing - JFileChooser 관련 (0) | 2012.05.18 |
JAVA 커서 컨트롤 (커서 모양 바꾸기) (0) | 2011.10.07 |
댓글 영역