Results 1 to 4 of 4
  1. #1
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: How was this made?

    Well, not looking at the YT vid, but simply going by the title...in Swing?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

    Default Re: How was this made?

    I don't understand how they can change the JFrame to look like that. And how do they add the mask for the text?

  4. #4
    Potato is offline Member
    Join Date
    Dec 2011
    Posts
    25
    Rep Power
    0

    Default Re: How was this made?

    Here's a demo. You can read more about doing cool things with frames here: How to Create Translucent and Shaped Windows (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

    Java Code:
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Polygon;
    import java.awt.Rectangle;
    import java.awt.event.ComponentAdapter;
    import java.awt.event.ComponentEvent;
    
    import javax.swing.JFrame;
    
    
    public class ShapedWindow extends JFrame {
    
    	private static final long serialVersionUID = 1L;
    
    	public static void main(String[] args) {
    		new ShapedWindow().start();
    	}
    
    	private final Canvas canvas;
    
    	public ShapedWindow() {
    		super("Custom Shaped Window");
    
    		final Polygon shape = new Polygon(); // Your window will be the shape of this polygon: Note that the size is also determined by the points you use. These are pixels.
    		shape.addPoint(0, 0);
    		shape.addPoint(100, 0);
    		shape.addPoint(50, 50);
    		shape.addPoint(10, 200);
    
    		addComponentListener(new ComponentAdapter() {
    
    			@Override
    			public void componentResized(ComponentEvent e) { // If your window is resized, it should still retain it's shape
    				setShape(shape);
    			}
    
    		});
    
    		setIgnoreRepaint(true);
    		setLocationRelativeTo(null);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setUndecorated(true);
    		Rectangle size = shape.getBounds();
    		setSize(size.width, size.height); // Automatically size JFrame
    		canvas = new Canvas();
    		canvas.setSize(getSize());
    		canvas.setIgnoreRepaint(true);
    		add(canvas);
    	}
    
    	public void start() {
    		setVisible(true);
    
    		Graphics g = canvas.getGraphics();
    		g.setColor(Color.black);
    		g.fillRect(0, 0, getWidth(), getHeight());
    		g.setColor(Color.red);
    		g.fillRect(0, 0, getWidth() / 2, getHeight() / 2);
    		g.dispose();
    	}
    
    }
    Last edited by Potato; 12-05-2012 at 10:05 PM.

Similar Threads

  1. Is GUI usually made using WYSIWYG editors?
    By kkid in forum New To Java
    Replies: 4
    Last Post: 10-17-2012, 08:47 PM
  2. Replies: 7
    Last Post: 10-14-2012, 06:05 AM
  3. A game made by me.
    By utsav1995 in forum Reviews / Advertising
    Replies: 0
    Last Post: 05-30-2012, 07:41 PM
  4. Use a dll made in .net (C#) COM Visible within JAVA
    By ealopez26 in forum Advanced Java
    Replies: 6
    Last Post: 09-16-2011, 04:46 AM
  5. No class made
    By ChuckLS in forum New To Java
    Replies: 1
    Last Post: 04-28-2009, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •