Skip to main content

Transperancy in java.. competing with C#

1 reply [Last post]
bilal_el_uneis
Offline
Joined: 2006-12-10

this is a C# code i found that creates true transperancy. why doesnt java have one.. also this code is efficient on Cpu usage unlike those i saw written in java.

Discuss.

<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;</p>
<p>namespace TransparentForms<br />
{<br />
    ///<br />
    /// Summary description for Form2.<br />
    ///<br />
    public class Transparent : System.Windows.Forms.Form<br />
    {<br />
        internal System.Windows.Forms.GroupBox GroupBox1;<br />
        internal System.Windows.Forms.Button cmdApply;<br />
        internal System.Windows.Forms.NumericUpDown udOpacity;<br />
        internal System.Windows.Forms.Label Label1;<br />
        ///<br />
        /// Required designer variable.<br />
        ///<br />
        private System.ComponentModel.Container components = null;</p>
<p>        public Transparent()<br />
        {<br />
            //<br />
            // Required for Windows Form Designer support<br />
            //<br />
            InitializeComponent();</p>
<p>            //<br />
            // TODO: Add any constructor code after InitializeComponent call<br />
            //<br />
        }</p>
<p>        ///<br />
        /// Clean up any resources being used.<br />
        ///<br />
        protected override void Dispose( bool disposing )<br />
        {<br />
            if( disposing )<br />
            {<br />
                if(components != null)<br />
                {<br />
                    components.Dispose();<br />
                }<br />
            }<br />
            base.Dispose( disposing );<br />
        }</p>
<p>        #region Windows Form Designer generated code<br />
        ///<br />
        /// Required method for Designer support - do not modify<br />
        /// the contents of this method with the code editor.<br />
        ///<br />
        private void InitializeComponent()<br />
        {<br />
            this.GroupBox1 = new System.Windows.Forms.GroupBox();<br />
            this.cmdApply = new System.Windows.Forms.Button();<br />
            this.udOpacity = new System.Windows.Forms.NumericUpDown();<br />
            this.Label1 = new System.Windows.Forms.Label();<br />
            this.GroupBox1.SuspendLayout();<br />
            ((System.ComponentModel.ISupportInitialize)(this.udOpacity)).BeginInit();<br />
            this.SuspendLayout();<br />
            //<br />
            // GroupBox1<br />
            //<br />
            this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {<br />
                                                                                    this.cmdApply,<br />
                                                                                    this.udOpacity,<br />
                                                                                    this.Label1});<br />
            this.GroupBox1.Location = new System.Drawing.Point(12, 75);<br />
            this.GroupBox1.Name = "GroupBox1";<br />
            this.GroupBox1.Size = new System.Drawing.Size(268, 116);<br />
            this.GroupBox1.TabIndex = 4;<br />
            this.GroupBox1.TabStop = false;<br />
            //<br />
            // cmdApply<br />
            //<br />
            this.cmdApply.Location = new System.Drawing.Point(172, 64);<br />
            this.cmdApply.Name = "cmdApply";<br />
            this.cmdApply.Size = new System.Drawing.Size(80, 24);<br />
            this.cmdApply.TabIndex = 5;<br />
            this.cmdApply.Text = "Apply";<br />
            this.cmdApply.Click += new System.EventHandler(this.cmdApply_Click);<br />
            //<br />
            // udOpacity<br />
            //<br />
            this.udOpacity.Increment = new System.Decimal(new int[] {<br />
                                                                        5,<br />
                                                                        0,<br />
                                                                        0,<br />
                                                                        0});<br />
            this.udOpacity.Location = new System.Drawing.Point(88, 32);<br />
            this.udOpacity.Name = "udOpacity";<br />
            this.udOpacity.Size = new System.Drawing.Size(48, 21);<br />
            this.udOpacity.TabIndex = 4;<br />
            this.udOpacity.Value = new System.Decimal(new int[] {<br />
                                                                    50,<br />
                                                                    0,<br />
                                                                    0,<br />
                                                                    0});<br />
            //<br />
            // Label1<br />
            //<br />
            this.Label1.Location = new System.Drawing.Point(20, 36);<br />
            this.Label1.Name = "Label1";<br />
            this.Label1.Size = new System.Drawing.Size(56, 16);<br />
            this.Label1.TabIndex = 3;<br />
            this.Label1.Text = "Opacity:";<br />
            //<br />
            // Form2<br />
            //<br />
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);<br />
            this.ClientSize = new System.Drawing.Size(292, 266);<br />
            this.Controls.AddRange(new System.Windows.Forms.Control[] {<br />
                                                                          this.GroupBox1});<br />
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
            this.Name = "Form2";<br />
            this.Text = "A Transparent Form";<br />
            this.GroupBox1.ResumeLayout(false);<br />
            ((System.ComponentModel.ISupportInitialize)(this.udOpacity)).EndInit();<br />
            this.ResumeLayout(false);</p>
<p>        }<br />
        #endregion</p>
<p>        private void cmdApply_Click(object sender, System.EventArgs e)<br />
        {<br />
            this.Opacity = (double)udOpacity.Value / 100;<br />
        }</p>
<p>        [STAThread]<br />
        static void Main()<br />
        {<br />
            Application.Run(new Transparent());<br />
        }<br />
    }<br />
}<br />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tarbo
Offline
Joined: 2006-12-18

Java is not C#. Java is built with cross-platform compatibility; C# has the luxury of using the latest in Windows-specific gadgets. And the reality is that not that many platforms support transparency.

There's no need to compete with C#. You like C#? Use C#. You like Java? Use Java. In reality, though, you'll use whatever language the pointy-haired boss tells you to use.