更改 Jframe 形状

Change Jframe Shape(更改 Jframe 形状)

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

问题描述

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

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)

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

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 外观

Android 屏幕上的一切都是矩形.小部件是矩形.启动器图标为 96 x 96 像素正方形.启动器图标下的文本使它们成为一个矩形.

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.

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

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.

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

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.

首先,创建一个普通的 JFrame.

First, you create an ordinary JFrame.

其次,您通过扩展 JPanel 并覆盖 paintComponent 方法来创建可绘制的 JPanel.您将在此 JPanel 上绘制背景图像,然后绘制启动器图标.启动器图标是从 PNG 文件创建的 BufferedImage,因此它们可以具有透明区域.

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.

drawable JPanel 会监听鼠标点击.这样可以移动启动器图标,也可以执行启动器图标.

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.

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

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.

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

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.

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

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 形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:更改 Jframe 形状

基础教程推荐