Results 1 to 4 of 4
Thread: How was this made?
- 12-04-2012, 04:00 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 43
- Rep Power
- 0
- 12-04-2012, 04:01 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 12-04-2012, 04:03 PM #3
Member
- Join Date
- Nov 2012
- Posts
- 43
- Rep Power
- 0
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?
- 12-05-2012, 10:02 PM #4
Member
- Join Date
- Dec 2011
- Posts
- 25
- Rep Power
- 0
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
-
Is GUI usually made using WYSIWYG editors?
By kkid in forum New To JavaReplies: 4Last Post: 10-17-2012, 08:47 PM -
Generic List I've made holding Objects I've made must be cast?
By Lowest0ne in forum New To JavaReplies: 7Last Post: 10-14-2012, 06:05 AM -
A game made by me.
By utsav1995 in forum Reviews / AdvertisingReplies: 0Last Post: 05-30-2012, 07:41 PM -
Use a dll made in .net (C#) COM Visible within JAVA
By ealopez26 in forum Advanced JavaReplies: 6Last Post: 09-16-2011, 04:46 AM -
No class made
By ChuckLS in forum New To JavaReplies: 1Last Post: 04-28-2009, 04:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks