2

In c# you could change the form shape to be as some picture shape that you draw.. I wonder if there is the same option to do this on jFrame in java? (I'm using netbeans)

and for example this is the picture I want to be used as the jFrame shapeenter image description here

so inside the "phone screen" I want to add some buttons.. is it possible?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Elior
  • 3,178
  • 6
  • 37
  • 67
  • 1
    in Java6 is possible to create that, [in Java7 (undecorated, not tested shaped window)seems like as bug](http://stackoverflow.com/questions/16219111/cant-transparent-and-undecorated-jframe-in-jdk7-when-enabling-nimbus), required to test code examples from Oracle tutorial [How to Create Translucent and Shaped Windows](http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html) – mKorbel May 01 '13 at 10:59
  • 1
    Everything in your Samsung phone picture is a rectangle. Even the icons are rectangles. The icons just have some transparent areas, which you can accomplish with PNG files. – Gilbert Le Blanc May 01 '13 at 13:08
  • @GilbertLeBlanc I think you're right.. so can I set the Image to be the jFrame background and jFrame to be transparent with no borders.. and it will work as I want? – Elior May 01 '13 at 13:14
  • 1
    Almost. Set your JFrame with the background picture and normal borders and buttons. Create a drawable JPanel. Make sure the BufferedImages you draw on the JPanel have transparent areas. I'm assuming you're making a desktop Swing application, and not an actual Android app. – Gilbert Le Blanc May 01 '13 at 13:18
  • 1
    By the way, the screen resolution of a Samsung Galaxy S3 is 1,280 x 720 pixels. The screen resolution of my 22" Samsung monitor is 1,680 X 1,050 pixels. You're going to have to turn the "phone" on its side and use your entire display to get the sharpness of the text on the S3. – Gilbert Le Blanc May 01 '13 at 13:33
  • @GilbertLeBlanc Yes I'm making a Swing application.. thanks for the advice! – Elior May 01 '13 at 13:39

2 Answers2

3

See How to Create Translucent and Shaped Windows for details & especially How to Implement a Shaped Window.

Shaped Window

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
2

Android Look and Feel

Everything on an Android screen is a rectangle. Widgets are rectangles. Launcher icons are 96 x 96 pixel squares. The text under a launcher icon makes them a rectangle.

The screen resolution of a Samsung Galaxy S3 is 1,280 x 720 pixels. The screen resolution of my 22" Samsung monitor is 1,680 X 1,050 pixels. You're going to have to turn the "phone" on its side and use your entire display to get the sharpness of the text on the S3.

This would be a great look and feel for a dashboard application. Your users are probably already accustomed to the smart phone appearance. Obviously, the gestures in your Swing application would have to use a mouse.

GUI Design

First, you create an ordinary JFrame.

Second, you create a drawable JPanel by extending JPanel and overriding the paintComponent method. You would paint the background image on this JPanel, then paint the launcher icons. The launcher icons are BufferedImages created from PNG files, so they can have transparent areas.

The drawable JPanel would listen for mouse clicks. This is so the launcher icons can be moved, and also so the launcher icons can be executed.

The Java application launched would replace the drawable JPanel with it's own JPanel. You would have to follow the Android developer guidelines in developing these JPanels, so your users feel like they're in an Android look and feel. Each application JPanel would have to be 1,280 x 720 pixels.

Your GUI model would hold all of the launcher icons, as well as the positions of these icons for each user. A relational database could hold all of this information so each user would have his or her own display.

Apps / Widgets

I hadn't worked out all the details in my mind, but there would have to be an Apps / Widgets drawable JPanel that shows all of the launcher icons and widgets. The user can drag the launcher icons from the Apps JPanel to the main drawable JPanel.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111