Drawing glass buttons

I am going to make some kind of glass buttons in java me (targeting devices with MIDP 2.0). Example: enter image description here

Actually I need to use the Gradient and Bevel-Emboss effects in Java ME, do you have any opinions or โ€œrecommendationsโ€ on how to implement this?

EDIT: Now I know how to draw a gradient background, but this is not enough. Is it possible to draw such a glass button in Java ME? I worked with C # and I can draw these types of glass buttons, but I'm struggling to mimic something like these buttons in Java ME or at least something next to them. Please note that I am looking for good guidance and help to move forward.

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

+4
source share
3 answers

You can do this using alpha gradient paint. Here is 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

+2
source

You can use LWUIT to develop java-me applications (MIDP 2.0). Its a good GUI structure for java-me application. Here you can create a theme manually using ResourceEdit. See this discussion and the LWUIT blog for more information.

+2
source

yoy cannot do this in me because it does not have such an effect on the user interface

get an image that acts like this gradient and make it transparent using

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

Note: you must use images that are already translucent unless setBgTransparency is set.

I can not recommend you use canvas

I recommend you use LWUIT

it has much more advertisements you need, for example

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

it also has a different layout

+1
source

All Articles