How to fill a JPanel with a texture from a image.
Hello,
I have a xxx.jpg file. I'd like to use this image to set the background texture of a JPanel.
Can someone give me a piece of code to do that.
Many thanks in advance
Gege
Since I haven't had no response, I have investigated more and finally solved my problem. Maybe it may help other people to have the answer.
Here is the piece of code which works fine.
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import javax.imageio.*;
public class TestTexture extends JPanel
java.io.File filetexture = new java.io.File("mytexture.jpg");
public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
if (g2==null)
System.out.println("error");
return;
try
BufferedImage mImage = ImageIO.read(filetexture);
java.awt.geom.Rectangle2D tr = new java.awt.geom.Rectangle2D.Double(0, 0, mImage.getWidth(), mImage.getHeight());
TexturePaint tp = new TexturePaint(mImage, tr);
g2.setPaint(tp);
java.awt.geom.Rectangle2D r = (java.awt.geom.Rectangle2D)this.getBounds();
g2.fill(r);
catch (java.io.IOException ex) {}
}
Similar Messages
-
How to fill a symbol with color
How to fill a symbol with color?
Good day!
What do you mean by »symbol« in this case?
Is this on a Layer of its own or is it part of a photograph?
Could you please post a screenshot with the Layers Panel visible?
Regards,
Pfaffenbichler -
I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?
I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?
Chrome uses its own (incompatible) PDF viewer.
Download the PDF to your local disk, then fill it from there with Adobe Reader. Or use a browser that uses the Adobe PDF plugin. -
How to fill internal table with selection screen field.
Hi all,
i am new to sap . pls tell me how to fill internal table with selection screen field.Hi,
Please see the example below:-
I have used both select-options and parameter on the selection-screen.
Understand the same.
* type declaration
TYPES: BEGIN OF t_matnr,
matnr TYPE matnr,
END OF t_matnr,
BEGIN OF t_vbeln,
vbeln TYPE vbeln,
END OF t_vbeln.
* internal table declaration
DATA : it_mara TYPE STANDARD TABLE OF t_matnr,
it_vbeln TYPE STANDARD TABLE OF t_vbeln.
* workarea declaration
DATA : wa_mara TYPE t_matnr,
wa_vbeln TYPE t_vbeln.
* selection-screen field
SELECTION-SCREEN: BEGIN OF BLOCK b1.
PARAMETERS : p_matnr TYPE matnr.
SELECT-OPTIONS : s_vbeln FOR wa_vbeln-vbeln.
SELECTION-SCREEN: END OF BLOCK b1.
START-OF-SELECTION.
* I am adding parameter value to my internal table
wa_mara-matnr = p_matnr.
APPEND wa_mara TO it_mara.
* I am adding select-options value to an internal table
LOOP AT s_vbeln.
wa_vbeln-vbeln = s_vbeln-low.
APPEND wa_vbeln TO it_vbeln.
ENDLOOP.
Regards,
Ankur Parab -
How to send a mail with HTML body from Oracle
Hi Team,
Can somebody guide me how to send a mail with HTML body from oracle.
Here is the piece of code i am trying to send a mail.
procedure SEND_MAIL is
cursor c_1 is select * from table_name;
l_mail_id varchar2(40);
-- ls_mailhost VARCHAR2(64) := Mailhost;
ls_from VARCHAR2(64) := ‘[email protected]’
ls_subject VARCHAR2(200);
ls_to VARCHAR2(64);
l_mail_conn UTL_SMTP.connection;
ls_left_menu_name VARCHAR2(64);
ll_emp_num number(8);
begin
for i in c_1 loop
begin
l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
UTL_SMTP.HELO(l_mail_conn, 'IP');
UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
UTL_SMTP.RCPT(L_mail_conn, LS_TO);
UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
'To: ' ||ls_to || utl_tcp.crlf ||
'Subject: ' ||ls_subject|| utl_tcp.crlf);
UTL_SMTP.QUIT(l_mail_conn);
exception
when no_data_found then
null;
when others then
RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
end;
end loop;
end;
ThnxHi Nicolas!
Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
Hope this helps!
Regards
Geir -
How to edit a text with same font in a image in photoshop 7
how to edit a text with same font in a image in photoshop 7
Good day!
The question seems to provide insufficient information for a relevant answer.
Do you have the font?
Is the text a (Type) Layer of its own or part of the image?
Could you please post a screenshot with the Layers Panel visible?
Regards,
Pfaffenbichler -
How do I transfer Fish with attitude game from IPad 2 to Ipad Air
How do I transfer Fish with /attitude game from IPad 2 to Ipad Air
Assuming you own both iPads (and are using the same Apple ID on both), simply sync your iPad 2 using iTunes, then sync your iPad Air using the same iTunes on your computer.
-
How do i send emails with outlook express from firefox
how do i send emails with outlook express from firefox
You can add a button by using the [http://webdesigns.ms11.net/getmail.html Get Mail] add-on.
-
How to add a JPanel with label and border line
hi,
I want a Jpanel with label and border line like this.Inside it i need to have components.Is there a resuable component to bring this directly??
Any solution in this regards.???
Label-----------------------------------------------------------
| |
| |
| |
| |
| |
|________________________________________ |[url http://java.sun.com/docs/books/tutorial/uiswing/misc/border.html]How to Use Borders
-
How to fill internal table with no data in debugging mode
Hi all,
I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
Thanks,
BalajiHi,
In the debugging do the following..
Click the Table button..
Double click on the internal table name..
Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
Use the APPEND button to insert records to the internal table..
Thanks,
Naren -
In sm30, when save, how to fill the table with the system data in the table
Hi all, in SM30, we have user name and time fields, when we create record, after we click the SAVE button, it will automatically fill the fields with the system data, how can we realize it?
Hi ,
Do like this.
1. Go to SE11 -> give your table name and press on change button .
2.Go to Menu->Utilities-> Table Maintainance Generator , then it will take you another screen .
3.Assign Functin group if already have one , other wise create function group and assign
4.Go to Menu->Environment->Modification->Events , again it will take you to another screen
5.Click on new entries
->Now press F4 in T column . Select<u> "01" - Before saving the data in the database</u> and in form routinue give any name of the routinue like "SAVE_USER_DATA" and press enter then u can see an editor symbol in next column click on that it will take you ABAP editor there type this code .
ztable-username = sy-uname.
ztable-createtime = sy-uziet.
check and activate the code .
With this your job will be complete . Now while entering data just leave columns blank , they will insert corresponding username and time
Don't forget award points if it helps you.
Regards,
Raghav -
How to fill an array with random numbers
Can anybody tell me how I can fill an array with thousand random numbers between 0 and 10000?
import java.util.Random;
class random
static int[] bull(int size) {
int[] numbers = new int[size];
Random select = new Random();
for(int i=0;i<numbers.length;i++) {
harris:
for(;;) {
int trelos=select.nextInt(10000);
numbers=trelos;
for(int j=0;j<i;j++) {
if(trelos==numbers[j])
continue harris;
numbers[i]=trelos;
break;
return numbers;
/*This method fills an array with numbers and there is no possibility two numbers to be the
same*/
/*The following method is a simpler method,but it is possible two numbers to be the same*/
static int[] bull2(int size) {
int[] numbers = new int[size];
Random select = new Random();
for(int i=0;i<numbers.length;i++)
numbers[i]=select.nextInt(9);
return numbers;
public static void main(String[] args) {
int[] nikos = random.bull(10);
int[] nikos2 = random.bull2(10);
for(int i=0;i<nikos.length;i++)
System.out.println(nikos[i]);
for(int i=0;i<nikos2.length;i++)
System.out.println(nikos2[i]); -
How to fill combo box with list of all SQL server
Ok, I know how to find all SQL servers that I need, I have code for that task, and I have Array of all servers.
My problem is ...
I made setup project and do a huge work, and in the end this task appear!
I used ORCA tool to change TextBox (A) template in visual studio (2008 by the way), and I transform first TextBox to ComboBox.
Now, the little part that I'am missing is how to fill this combo box with a result of my function for listin SQL servers?
Can I somehow send combobox object to myMethod:
private void FillCombo(ComboBox cmb)
// do the job
or
instanceOfThisCombo.Items.Add(listOfSQLServers);
please help me to solve this... thanksc#Hi Valerij,
The ComboBox control in an MSI dialog uses the ComboBox table to populate the items in it. To get what you want, you need to update the ComboBox table in the MSI package with your application and run the MSI package. The following KB article describes how to dynamically populate a ListBox control in Windows Installer:
http://support.microsoft.com/kb/291329
This method introduced in the above KB article also applies to populating a ComboBox control in Windows Installer.
I don't think it's possible to run the application as a Custom Action from within the MSI package because the application will modify the content of the MSI package which is currently running. So you need to launch the MSI package from within your application after updating the ComboBox table. In short, when installing, just run your application which updates the ComboBox table and install the MSI package.
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu -
How to fill selection box with clientside data?
i want to make a html form that reads option values from the client.
Because there are too many data, it's not reasonable for me to design a page which connects to server each time to fill the selection boxes.Instead i want to check if data resides at the clientside, if so fill selection boxes with that data, if not download it for the first time and store it on the client for later local retrieval.In addition i must be able to update that data residing on the client when i want.Hi,
I can tell you some hints. Use cookies to store the information on to the client-side. You can read data from cookies using JavaScript. If you want to store huge amount of data on to the client-side, perhaps this would not be a better idea. In J2EE architecture we often use sessions to store values. You need to design your implementation in such a way that for the first time you fetch all the values from the database and put it in a session, and the next time onwards you can get the values from the session itself and thereby you can avoid going to database each and everytime. Write a Java class which has all the necessary get and set methods and store the object in the session. Using that object reference you can set and get the values from it. I hope this will help you.
Thanks -
How to fill bean area with values from database
i have a bean area in form which act as acombobox autocomplete , i want to fill it with dynamic values from database , any help will be appreciated.
http://forms.pjc.bean.over-blog.com/article-16369664.html "this is the example i'm working on"
Best Regards.An example with the EMP table:
DECLARE
cursor cur is select empno,ename from emp;
BEGIN
-- initialise the ComboBox twin values --
for c in cur loop
if c.empno is not null then
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN',c.empno||','||c.ename);
else
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN_NULL',c.empno||','||c.ename);
end if ;
end loop;
Set_Custom_Property('BL.BEAN',1,'ADD_TWIN','[END_DATA]');
Set_Custom_Property('BL.BEAN',1,'SET_ALIGNMENT','right');
END;Francois
Maybe you are looking for
-
A-GPS not working ??
Hi, as a 5800 newbie I seem to have got myself into a bit of a pickle :-( When I enable maps (or the camera wirh GPS enabled) it can take a bit of time for it to get a fix initially. I had previously disabled "Assisted GPS" in the interests of cost -
-
Pro Res v HDV v SD comparison test
Just incase anyone is interested, I have just completed a comparison test for checking the processing times for converting HDV footage into SD (ready for authoring). Having read up on the forum,the options of keeping things in native HDV , converting
-
GTK - GLIB installation 2.6 - 2.7
Hello... I don't know where to write or whome to ask ...maybe this is my last chance. I want to install gtk on solaris (2.7 and 2.6) but on both I got some error by glib-make. I mean - gtk needs glib - glib needs pkgconfig and pkgconfig (and all) nee
-
Hi, I'm trying to find out how to view an encrypted PDF programmatically in Flex. I would like to be able to do several things: 1) View an encrypted pdf on my local machine and do it by decrypting with the password through ActionScript. 2) Allow for
-
Keyboard and tracker not working
have just purchased a macbook air. After only a couple of hours my notebook keyboard and tracker are not working. the cursor is stuck on upper left hand side of the screen and its stuck on 'bluetooth setup assistant' looking for a wireless keyboard.