Search Results

Search found 5 results on 1 pages for 'nivas'.

Page 1/1 | 1 

  • Background Image in JTextPane

    - by Nivas
    How do I set a background image to a JTextPane - some sort of a watermark. I tried this option - creating a child class of JTextPane and use the paint method to draw the image. But then the text is displayed "below" the image than above. Is there any "standard" or "well known" way to do this? (BTW, I tried (something silly?) making the content type "text/html", and setting the image as the background image of a <div> but it did not help.)

    Read the article

  • How to draw multiple rectangles using c#

    - by Nivas
    I have drawn and saved the Rectangle on the image i loaded in the picture box. How i like to draw multiple rectangles for that i tried array in the rectangle but it gives error ("Object reference not set to an instance of an object." (Null reference Exception was unhandled). private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (mybitmap == null) { mybitmap = new Bitmap(sz.Width, sz.Height); } rect[count] = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (stayToolStripMenuItem.Checked == true) { switch (e.Button) { case MouseButtons.Left: { rect[count] = new Rectangle(rect[count].Left, rect[count].Top, e.X - rect[count].Left, e.Y - rect[count].Top); pictureBox1.Invalidate(); count++: break; } } } } private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (stayToolStripMenuItem.Checked == true) { button1.Visible = true; button2.Visible = true; if (mybitmap == null) { return; } using (g = Graphics.FromImage(mybitmap)) { using (Pen pen = new Pen(Color.Red, 2)) { //g.Clear(Color.Transparent); e.Graphics.DrawRectangle(pen, rect); label1.Top = rect[count].Top; label1[count].Left = rect[count].Left; label1.Width = rect[count].Width; label1.Height = rect[count].Height; if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawRectangle(pen, rect[count]); } } } } } How can i do this.....

    Read the article

  • List files with two dots in their names using java regular expressions

    - by Nivas
    I was trying to match files in a directory that had two dots in their name, something like theme.default.properties I thought the pattern .\\..\\.. should be the required pattern [. matches any character and \. matches a dot] but it matches both oneTwo.txt and theme.default.properties I tried the following: [resources/themes has two files oneTwo.txt and theme.default.properties] 1. public static void loadThemes() { File themeDirectory = new File("resources/themes"); if(themeDirectory.exists()) { File[] themeFiles = themeDirectory.listFiles(); for(File themeFile : themeFiles) { if(themeFile.getName().matches(".\\..\\..")); { System.out.println(themeFile.getName()); } } } } This prints nothing and the following File[] themeFiles = themeDirectory.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.matches(".\\..\\.."); } }); for (File file : themeFiles) { System.out.println(file.getName()); } prints both oneTwo.txt theme.default.properties I am unable to find why these two give different results and which pattern I should be using to match two dots... Can someone help?

    Read the article

  • saved image in the picturebox shows no preview

    - by Nivas
    Hi iam new to C# and have loaded the image in the picture box using menustrip and have displayed some text using picturebox_Paint and label. now i tried to save the image (with image and text) using save event from the menustrip. in the saved location the file shows as no preview avaliable and when i tried to open the file it shows out of memory. can any one say where iam going worng.... my coades private void openToolStripMenuItem_Click(object sender, EventArgs e) { string file = ""; OpenFD.FileName = ""; OpenFD.Title = "open image"; OpenFD.InitialDirectory = "C"; OpenFD.Filter = "JPEG|.jpg|Bmp|.bmp|All Files|..*"; if (OpenFD.ShowDialog() == DialogResult.OK) { file = OpenFD.FileName; pictureBox1.Image = Image.FromFile(file); sz = pictureBox1.Size; a=sz.Width; b= sz.Height; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: { rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top); this.Invalidate(); y = flag.e; Application.DoEvents(); break; } } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { rect = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Pen pen = new Pen(Color.Red, 2)) e.Graphics.DrawRectangle(pen, rect); //e.Graphics.DrawString(label1.Text, label1.Font, new // SolidBrush(label1.ForeColor), label1.Left - pictureBox1.Left, label1.Top - pictureBox1.Top); if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), label1.Bounds); } else if (label1.TextAlign == ContentAlignment.TopCenter) { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = ((float)this.Width + label1.Left) / 2 - size.Width / 2; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } else { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = (float)label1.Width - size.Width + label1.Left; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } label1.Top = rect.Top; label1.Left = rect.Left; label1.Width = rect.Width; label1.Height = rect.Height; } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog SaveFD1 = new SaveFileDialog(); //string Sd_file = ""; SaveFD1.FileName = ""; SaveFD1.InitialDirectory = "C"; SaveFD1.Title = "save file Name"; SaveFD1.Filter= "JPG|.jpg|Bmp|.bmp"; if (SaveFD1.ShowDialog() != DialogResult.Cancel) { System.IO.Stream filename = (System.IO.FileStream)SaveFD1.OpenFile(); if (SaveFD1.Filter == "JPG") pictureBox1.Image.Save(SaveFD1.FileName); //pictureBox1.Image.Save (filename, System.Drawing.Imaging.ImageFormat.Jpeg); else if (SaveFD1.Filter == "Bmp") { //pictureBox1.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp); } filename.Close(); } }

    Read the article

  • How to draw mutiple rectangles using c#

    - by Nivas
    I have drawn and saved the Rectangle on the image i loaded in the picture box. How i like to draw multiple rectangles for that i tried array in the rectangle but it gives error ("Object reference not set to an instance of an object." (Null reference Exception was unhandled). enter code here private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (mybitmap == null) { mybitmap = new Bitmap(sz.Width, sz.Height); } rect = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (stayToolStripMenuItem.Checked == true) { switch (e.Button) { case MouseButtons.Left: { rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top); pictureBox1.Invalidate(); break; } } } } private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (stayToolStripMenuItem.Checked == true) { button1.Visible = true; button2.Visible = true; if (mybitmap == null) { return; } using (g = Graphics.FromImage(mybitmap)) { using (Pen pen = new Pen(Color.Red, 2)) { //g.Clear(Color.Transparent); e.Graphics.DrawRectangle(pen, rect); label1.Top = rect.Top; label1.Left = rect.Left; label1.Width = rect.Width; label1.Height = rect.Height; if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawRectangle(pen, rect); } } } } } How can i do this.....

    Read the article

1