绘制玻璃按钮

发布于 2024-11-09 00:49:04 字数 375 浏览 0 评论 0原文

我将在 java me 中绘制某种玻璃按钮(针对使用 MIDP 2.0 的设备)。 一个例子: 在此处输入图像描述

实际上我需要在 Java ME 中实现渐变和斜面浮雕效果,您有什么意见或“指导方针”如何实施?

编辑:现在我知道如何绘制渐变背景,但这还不够。 在Java ME中可以绘制这样的玻璃按钮吗? 我使用过 C#,我可以在那里绘制这些类型的玻璃按钮,但我正在努力研究如何在 Java ME 中模拟类似这些按钮的东西,或者至少是接近它们的东西,请注意,我正在寻找一个好的指导和帮助前进。

我需要提供更多信息吗?如果是这样,请告诉我。 提前致谢。

I'm going to draw some sort of glassy buttons in java me (targeting devices with MIDP 2.0).
An Example:
enter image description here

Actually I need to impelement Gradient and Bevel-Emboss effects in Java ME, do you have any opinion or "guideline" on how to implement this?

EDIT: Now I know how to draw gradient background, but That is not sufficient.
Is it possible to draw such glassy button in Java ME?
I've worked with C# and I can draw these kinds of glassy buttons there, but I'm struggling on how to simulate something like these buttons in Java ME or at least something near to them, Note that I'm looking for a good guidance and help to move forward.

Do I need to provide more information? If so, please let me know.
Thanks In advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不羁少年 2024-11-16 00:49:04

您可以使用 alpha 渐变涂料来做到这一点。这是一个例子:

Graphics2D g = (Graphics2D)screen.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setFont(new Font("Serif", Font.BOLD, 30));
Color c1 = new Color(0,0,0,0);
Color c2 = new Color(0,0,0,100);
GradientPaint gradient = new GradientPaint(10,8,c1,10,40,c2,true);

g.setColor(Color.GREEN);
g.fillRect(0, 0, screen.width, screen.height);
g.setColor(Color.BLACK);
g.setPaint(gradient);
g.fillRoundRect(100, 100, 200, 50, 25, 25);
g.setPaint(Color.BLACK);
g.drawRoundRect(100, 100, 200, 50, 25, 25);
g.drawString("Hello World!", 118, 135);

它看起来像这样:

Button with green background

You can do it by using an alpha gradient paint. Heres an example:

Graphics2D g = (Graphics2D)screen.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setFont(new Font("Serif", Font.BOLD, 30));
Color c1 = new Color(0,0,0,0);
Color c2 = new Color(0,0,0,100);
GradientPaint gradient = new GradientPaint(10,8,c1,10,40,c2,true);

g.setColor(Color.GREEN);
g.fillRect(0, 0, screen.width, screen.height);
g.setColor(Color.BLACK);
g.setPaint(gradient);
g.fillRoundRect(100, 100, 200, 50, 25, 25);
g.setPaint(Color.BLACK);
g.drawRoundRect(100, 100, 200, 50, 25, 25);
g.drawString("Hello World!", 118, 135);

it will look like this:

Button with green background

橙味迷妹 2024-11-16 00:49:04

您可以使用 LWUIT 框架来开发 java-me (MIDP 2.0) 应用程序。它是用于 java-me 应用程序的良好 GUI 框架。在这里您可以使用 ResourceEdit 手动创建主题。有关详细信息,请参阅此讨论LWUIT 博客 也。

You can use LWUIT framework for developing java-me (MIDP 2.0) applications. Its good GUI framework for java-me application. Here you can create the theme manually using ResourceEdit. For more info see this discussion and LWUIT blog also.

梦醒时光 2024-11-16 00:49:04

哟我不能这样做,因为它对 UI 没有这样的影响,

获取具有类似 grient 效果的图像并使用

btn.getStyle().setBgTransparency(100) // from 0-255

注释使其透明:您必须使用已经是半透明的图像,如果不是 setBgTransparency 将无法正常工作

我不能推荐您使用画布

我建议您使用 LWUIT

它有更多您需要的效果广告,就像

btnBuzz.getStyle().setBorder(Border.createBevelLowered());

它也有不同的布局

yoy can not do so in me because it dont have such reach effect on UI

get image that have effect like that gredient and make it transparent using

btn.getStyle().setBgTransparency(100) // from 0-255

note: you must use images that is already semi transparent , if not than setBgTransparency would not work properly

I can not recommend you to use canvas

i recommend you to use use LWUIT

it have many more effects ads you required ,like

btnBuzz.getStyle().setBorder(Border.createBevelLowered());

it have different layout as well

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文