更改Jframe形状 [英] Change Jframe Shape

查看:122
本文介绍了更改Jframe形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中,您可以将表单形状更改为您绘制的某些图片形状..
我想知道在java中的jFrame上是否有相同的选项可以执行此操作? (我正在使用netbeans)



例如这是我想用作jFrame形状的图片



所以在手机屏幕里面我想添加一些按钮..是吗可能?

解决方案

Android外观



Android屏幕上的所有内容均为一个矩形。小部件是矩形。启动器图标为96 x 96像素正方形。启动器图标下的文本使它们成为一个矩形。



三星Galaxy S3的屏幕分辨率为1,280 x 720像素。我的22英寸三星显示器的屏幕分辨率为1,680 X 1,050像素。你将不得不翻开手机并使用整个显示器来获得S3上文字的清晰度。



对于仪表板应用程序来说,这将是一个很好的外观和感觉。您的用户可能已经习惯了智能手机的外观。显然,Swing应用程序中的手势必须使用鼠标。



GUI设计



首先,您创建一个普通的JFrame。



其次,你通过扩展JPanel并覆盖paintComponent方法来创建一个可绘制的JPanel。你可以在这个JPanel上绘制背景图像,然后绘制启动器图标。启动器图标是从PNG文件创建的BufferedImages,所以它们是可以有透明区域。



可绘制的JPanel会监听鼠标点击。这样可以移动启动器图标,也可以执行启动器图标。 / p>

启动的Java应用程序将用它自己的JPanel替换可绘制的JPanel。在开发这些JPanel时,您必须遵循 Android开发人员指南,以便您的用户感觉像它们具有Android外观和感觉。每个应用程序JPanel必须是1,280 x 720像素。



您的GUI模型将保存所有启动器图标,以及每个用户的这些图标的位置。关系数据库可以保存所有这些信息,因此每个用户都有自己的显示。



应用程序/窗口小部件



我没有想出所有细节,但是必须有一个Apps / Widgets可绘制的JPanel,它显示了所有的启动器图标和小部件。用户可以将启动器图标从Apps JPanel拖动到主要的可绘制JPanel。


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 shape

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

解决方案

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.

这篇关于更改Jframe形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆