Questions tagged [drawstring]

Graphics.DrawString is a method in the .Net Framework's System.Drawing namespace, by which code can draw text onto an image in .Net code. This is mainly used in ASP.Net, as TextRenderer.DrawText (from System.Windows.Forms) provides more reliable functionality in Windows Forms applications.

313 questions
0
votes
3 answers

How to use string format on a list item

I'm using drawstring to get a item from a list to be displayed, but now i would like it to be displayed as a 4 digit number instead of a single digit. So instead of it displaying 0 i would like it to display 0.000 . If anyone could help me with…
maam27
  • 444
  • 3
  • 21
0
votes
2 answers

Resize Rectangle based on text

I am working on a custom control where I am using Rectangle to show some data. Now, lets say the width and height of the rectangle is set to 100. If I have less amount of data, then its fine, I can make it draw using DrawString method. But,…
Mohit
  • 250
  • 1
  • 5
  • 16
0
votes
1 answer

How can I separate the letter in string when drawing

I want to draw a string that I take from a jtextarea, but I want to draw with 20px space to each letter, but I think I can't do this with drawstring and I can't draw a char per time with drawchars, so what can I do? I want to write a letter above…
0
votes
3 answers

Drawstring on a panel change when other panel move over

I draw a rectangle panel with every button click. After that add a line on the edge of the rectangle and text on the center. But when I drag a panel move over other panel. The panel string will change. Please advice. I can't upload an image. How can…
TK.C
  • 13
  • 4
0
votes
2 answers

JTextArea - drawString in line with existing text

The following code snippet paints a suggested auto complete string in a JTextArea: @Override public void paintComponent(Graphics g) { super.paintComponent(g); if (suggestion != null && isSuggesting()) { final String…
Elist
  • 5,313
  • 3
  • 35
  • 73
0
votes
0 answers

C# Giving PictureBox the Shape of a String

I want to make a PictureBox that containts a round picture and a string. The shape of the Box should not be rectangular, but adapted to the String and the round Picture. I need this for achieving "perfect" transparency, because apparently…
Salocin
  • 393
  • 6
  • 17
0
votes
2 answers

Text Alignment on OwnerDraw Tooltip in C# / .NET

I have a multiline text string (e.g. "Stuff\nMore Stuff\nYet More Stuff"), and I want to paint it, along with a bitmap into a tooltip. Since I am painting the bitmap, I need to set OwnerDraw to true, which I am doing. I am also handling the Popup…
Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
0
votes
0 answers

How to get drawStrings on new lines

So, I have this String(snippet below) which has a fair amount of information highscoreString += (i + 1) + ".\t\n" + scores.get(i).getName() + "\t\t\n" + scores.get(i).getScore() + "\n"; which is inside this method public String getHighscoreString()…
Sebastian A
  • 521
  • 1
  • 5
  • 9
0
votes
3 answers

Java Graphics2D DrawString

Hey guys I have a little issue here. I have a panel where I am drawing a string. This is a game so I keep redrawing the score in order to update it. However when I draw it again it is drawn on top of the previous score so it looked all garbled up. …
user69514
  • 26,935
  • 59
  • 154
  • 188
0
votes
0 answers

showOptionDialog selected option to drawString

I have a JLabel inside of a JPanel and when I input some message into the showOptionDialog and select the "OK" button, the JLabel should print out the message I entered. However, the codes I have doesn't even go into the paintComponent() method in…
jl90
  • 639
  • 2
  • 10
  • 24
0
votes
1 answer

drawString not drawing text on my game

I am new in this monogame stuff. Watched few tutorials and figured it out how to do some stuff. But here is a problem, when it comes to drawing string on game surface, it does not work. I downloaded a MonoGame sample from one page…
ZassX
  • 1,369
  • 2
  • 14
  • 35
0
votes
0 answers

Html5 detecting draw string length with javascript

Casually i would detect the width and height of a string by doing this.. canvas.getContext("2d").font="12px Arial"; canvas.getContext("2d").fillStyle = "red"; canvas.getContext("2d").fillText("StackOverflow",x,y); var width =…
0
votes
2 answers

How to draw string that displays Mouse X and Mouse Y?

String mouse = new String(getMouseX(), getMouseY()); public void paintFrame(Graphics g) { g.drawString("mouse", 100,100); } Basically, I'm trying to display the X and Y coordinates of the mouse on the screen when the program is…
jzacharia
  • 492
  • 1
  • 3
  • 14
0
votes
1 answer

Centering text from drawstring

Soo the user is given the choice to choose whether the text "Welcome to Java Programming" text should be italic, bold, or centered in the panel. These choices are check boxes. I'm not sure how to make it so that when the user picks center, it'll be…
Jake
  • 313
  • 1
  • 7
  • 16
0
votes
1 answer

java cannot be applied to given types

so i got this error: java cannot be applied to given types; required: java.lang.String,int,int; found:java.lang.String; reason: actual and formal argument lists differ in lenghhs when i typed this in one Actor (im using Greenfoot): public String…