473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

JButton in c#

I've been asked to give my .NET app the same look and feel to another app written using Java/Swing.

My main issue is to do with button/icons. The JButton used by the other app has an icon with a transparent background - this may a consequence of using GIF as the source format.

Now I just want to knock-up some simple icons for my app using VS2005 image editor and add them to the buttons. Cannot see how to add transparent pixels.
<gripe>
The icon editor has a transparent colour but the image editor doesn't! Guess this is to do with the file format but if the Bitmap class has a MakeTransparent method, why doesn't the editor?
</gripe>
Some buttons have state so I need an imagelist.
How do I create an Imagelist using VS2005? (Not programmatically)
Sep 12 '07 #1
9 1965
kenobewan
4,871 Expert 4TB
There is no such thing as a transparent pixel, a color appears transparent when its opacity is set below 100%. I have never used VS2005 image editor, but I guarantee you wont end up with the effect unless you start with a transparent background - no colors - and can adjust the opacity of subsequent layers.

Btw - does anyone know the speed of dark? ;).
Sep 12 '07 #2
Plater
7,872 Expert 4TB
Generally speaking a "transparent pixel" just means that for that particular pixel, nothing is done to it when your picture is drawn.
If it was already "red" it stays red, "blue" stays blue and so on.
You could make (234,254,244) be your "invisible" color just by not drawing it.
Sep 12 '07 #3
Ok guys we've gone overboard on my use of the phrase "transparent pixel". You know what I'm after - I need the image to blend nicely with the button its sitting on, just like icons do on the toolbar,menus etc..
Sep 12 '07 #4
Plater
7,872 Expert 4TB
My buttons have:
BackColor
BackgroundImage
BackgroundImageLayout
Image
ImageAlign
ImageIndex
ImageKey
ImageList
FlatSyle
FlatAppearance
TextImageRelation

Seems like you should be able to accomplish your goals with those properties
Sep 12 '07 #5
kenobewan
4,871 Expert 4TB
Generally speaking a "transparent pixel" just means that for that particular pixel, nothing is done to it when your picture is drawn.
If it was already "red" it stays red, "blue" stays blue and so on.
You could make (234,254,244) be your "invisible" color just by not drawing it.
Sorry, a pixel is a unit of measurement. Whether it is transparent or not depends on whether anything translucent is covering it, another layer. That's why your transparent pixel is not transparent at all, it is empty. What is transparent are the layers above it.

Ok - if white noise isn't silent how much does nothing weigh? :)
Sep 13 '07 #6
Well I've tried:
Expand|Select|Wrap|Line Numbers
  1.         private void MainForm_Load(object eventSender, System.EventArgs eventArgs)
  2.         {
  3.  
  4.             foreach (Bitmap bmp in MyButton.ImageList.Images)
  5.             {
  6.                 bmp.MakeTransparent(bmp.GetPixel(1, 1));
  7.             }
  8.  
But this had no effect. Further suggestions?
Sep 19 '07 #7
Plater
7,872 Expert 4TB
Ok so you are assigning that color in the (1,1) location be the transparent color.
That's only for that EXACT RGB value (so if you have fancy color blending then it won't work)

And are you assigning those images as the background image?

You basicly want buttons that are customly shaped in the shape of your images right?
Sep 19 '07 #8
Ok so I have finally found the key property.
It's ImageList.TransparentColor.
Now, the default for is Transparent (!). I could change this to something else and fill my image with that where needed (which is how I know it works) but it would make more sense to use this Transparent. Any idea how to get it into the image editor in VS2005? Some experimentation shows the alpha channel is set to 0, how to do that in VS2005 image editor?
Sep 20 '07 #9
Plater
7,872 Expert 4TB
Add image to project.
Open image.
Sep 20 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff T. | last post by:
Hi, I have a JMenuBar object that contains a JToolBar object which contains some JButton objects. After I let my applet sit for > 20 minutes, the graphics on those buttons would disappear. ...
3
by: Konrad Den Ende | last post by:
Is it possible to do at all? The software will be used on computers with western operative systems (so i guess, JVM will be english) but i'm asured that japanese will be enabled through IME so that...
4
by: porky008 | last post by:
I put in a next and previous button but it crashes when I run it. I also need it to loop around to the first or last if at the ends. Can some one help me with this? import java.awt.*; import...
0
by: Oswald Otte | last post by:
Hello How can I change the look of a disabled JButton? I have made a boardgame with a brown background and brown buttons. I have also put an imageicon on the buttons that has a colored image on...
6
by: vijaykumarsharma | last post by:
Hi all I am having a problem with JButton. JButton b=new JButton("save"); how can i get the name of the JButton b. Please give the anser for me
2
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
1
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
12
by: yeshello54 | last post by:
So I want to set the background color of a Jbutton. I know that the normal way to do such a thing is down the following way: JButton button = new JButton("xxxx"); button.setBackground(Color.RED);...
1
by: mlibot | last post by:
My JButton will be disabled when running my program... my JButton will be enabled if the value or parameter are equal to 3... for example: 1 value is path of the file i selected. 2 vaue is path of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.