How to override setText for custom JButton
Hi
From the Swings Hack book, I have the code for a custom JButton.
I would like to setText for this button so that the text is set over the image on the button.
Would someone know how I can do this?
import java.awt.*;
import javax.swing.*;
public class ImageButton extends JButton {
public ImageButton(String img) {
this(new ImageIcon(img));
public ImageButton(ImageIcon icon) {
setIcon(icon);
setMargin(new Insets(0,0,0,0));
setIconTextGap(0);
setBorderPainted(false);
setBorder(null);
setText(null);
setSize(icon.getImage().getWidth(null),
icon.getImage().getHeight(null));
}Thanks!
Something like this should do it...
import java.awt.*;
import javax.swing.*;
public class ImageButton extends JButton {
private static final long serialVersionUID = 1L;
public ImageButton(ImageIcon icon, String text) {
setIcon(icon);
setMargin(new Insets(0, 0, 0, 0));
setIconTextGap(0);
setBorderPainted(false);
setBorder(null);
setText(text);
setSize(icon.getImage().getWidth(null), icon.getImage().getHeight(null));
}Or just add a public setText() method accepting a String...
Similar Messages
-
Overriding paint for customizing JButton??? Shouldn't be paintComponent?
Hi
Shouldn't we always override paintComponent to customize the painting of a component?
Why MetalScrollButton in javax.swing.plaf.Metal overrides paint instead of paintComponent?
Should I override paint if I want to write my own LnF?
Thanks.As is said in the online doc about paint(), "This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint method should just override paintComponent."
That means you can override paint(), , but in this case you'll have to draw the border yourself... and if you have a composite custom component (a panel containing labels, for example), you will have to call the label's paintComponent() methods by yourself...
Hope this helped,
Regards -
How to create IDOC for customer defined table
hi,
How to create IDOC for customer defined table Records and how to send this IDOC to target system.
what message type will be used and on receiving system how to post these records.
thankx.
pillac.Hi,
You need to create a custom message type and custom IDOC type for this with whatever fields you want send. You need to create segments (WE30), IDOC type (WE30), Message types (WE81) and assign the message type to the IDOC type (WE82).
You will have trigger the IDOC using a Report or something after doing the partner profile settings.
Similary in the target system also, you will have do all the settings.
Take a look the links to find out what settings needs to be done.
http://help.sap.com//saphelp_470/helpdata/EN/0b/2a611c507d11d18ee90000e8366fc2/frameset.htm
http://www.sappro.com/downloads/OneClientDistribution.pdf
Regards,
Ravi
Note : Please mark the helpful answers and close the thread if the issue is resolved. -
How to create iView for customized master head war ?
Hi,
I deployed customized masterhead war file. But i cant see deployed war in portal application location.
Anyone help me for customizing and masterhead page and how to create iView for customized master head...Hi,
1. You can see the deployed application under the "Portal Applications"
2. If you want to create an iView out of it. right click on the application -> copy. than press right click in the folder you want the iView will be created and paste ad pcd object.
Hope I helped you.
Ronny. -
How to Create Correspondance for Customer Statement
Hi Gurus,
my client is asking for customer statement.How to create correspondance for that.i dont want to use standard one.initially i tried with standard one,but it is giving the heading as open items instead of customer statement.
what should i do.Kindly help me
Thanks
PrathimaPrathima,
While we all agree that SAP's in-app help could do with a lot of improvement, however there's no shortage in terms of volume and coverage. Have you cared to perhaps look at [SAP Online Help|http://help.sap.com]?
Here's a little something to get you started. Have a look [here|http://help.sap.com/saphelp_erp60_sp/helpdata/en/01/a9cf0d455711d182b40000e829fbfe/frameset.htm] and [here|http://help.sap.com/saphelp_erp60_sp/helpdata/en/01/a9cf0d455711d182b40000e829fbfe/frameset.htm].
Under IMG, the path is Financial Accounting --> Financial Accounting Global Settings --> Correspondence.
This should be enough to get you started to forage on your own.
Happy Learning!
Regards
Gulshan -
Need Advice on How To / Recommended App. for Custom "Word of the Day" Screensaver
I really like the “Word of the Day” screensaver that comes with OS X 10.8 Mountain Lion. I would like to either 1.) customize this screensaver with my own dictionary OR 2.) identify an app that I could purchase / download which would allow me to create my own custom “Word of the Day” screensaver.
Does anyone have advice on how I can create a custom “Word of the Day” screensaver using my own dictionary?
Any advise would be greatly appreciated!Thank you!
If you have time for just a couple more questions. The ultimate goal is have my new flash files in a version (as3) so they can be used as android, html5 and iOs products.
So would the steps be these?
Install cs6
Open SWF files that were created in as2
(I am assuming by doing this, all the assets will end up in the library which is currently not happening when I import the swf files into Flash CC)
So now I have the old swf files open in a version of flash that works in as2.
I understand that as2 is not fully convertible to as3. But assuming I want to use the assets (graphics and audio) to recreate the animations in as3 can I then save the as2 file as as3 so it would then work with AIR?
Thanks again? -
How to upload data for custom infotype
Hi Friends
Can we use HR_INFOTYPE_OPERATIONS FM for custom infotype too or is there other way or other Standard FM to upload data for custom infotype starting with 9000..etc.
Points will be there for sure.
Thanks
Meeta & RoopaThanks for quick response.
my qns is can we use Standard FM like HR_INFOTYPE_OPERATIONS for custom infotype too ?
in my requirment input will come from portal form and in background Java Wd is going to use these FM but i have this big doubt can we use these standard FM for uploading data in custom infotype as well or else is there any other way.. but for sure we can't use BDC and LSMW in this requirement .
Thanks Meeta & Roopa -
How to See logs for custom programs from without the logviewer in NWA
Hello Experts,
The JavaAS developers want to see the logs for their custom programs from without the logviewer in NWA.
Do you have any experience or know of any reference materials to instruct them on where to write their logs, and how to configure NWA to see them?
Thanks
Jibin.Hello Jibin,
Your developers should familiarize themselves with the Logging Framework of the J2EE Engine.
Here is the guide:
http://help.sap.com/saphelp_nw04/helpdata/EN/a2/15ab41d60bcb46e10000000a155106/frameset.htm
If they use the Logging Framework you would be able to access the logs through NWA.
Regards,
Ventsi Tsachev
Technology Development Support (J2EE Engine)
SAP Labs, Palo Alto, Ca (USA) -
How to improve performance for Custom Extractor in BI..
HI all,
I am new to BI and started working on BI for couple of weeks.. I created a Custom Extractor(Data View) in the Source system and when i pull data takes lot of time.. Can any one respond to this, suggesting how to improve the performance of my custom Extractor.. Please do the needfull..
Thanks and Regards,
Venugopal..Dear Venugopal,
use transaction ST05 to check if your SQL statements are optimal and that you do not have redundant database calls. You should use as much as possible "bulking", which means to fetch the required data with one request to database and not with multiple requests to database.
Use transaction SE30 to check if you are wasting time in loops and if yes, optimize the algorithm.
Best Regards,
Sylvia -
Override doDML for custom type
Hi,
I'm overriding the doDML method of my entity class. Instead of inserting directly into a certain table I redirect the insert handling to a special PL/SQL package method. This works fine, until I want to use a custom as one of the columns of the table / one of the arguments of the package method.
E.g. the custom type looks like this:
CREATE OR REPLACE TYPE mylist AS TABLE OF VARCHAR2(10);I use this type for a nested table column in a certain table. The PL/SQL does some pre-/post-processing and inserts a new record in the table my entity object is based on. When I create the entity using the Entity wizard it correctly detects the column as of SQL type mylist and Java type oracle.jbo.domain.Array with elements of type String.
Anyway, the prepared statement I create looks something like the following:
String stmt = "BEGIN mypkg.insert(:1, :2); END;";
PreparedStatement p = e.getDBTransaction().createPreparedStatement(stmt, 2);
if (getId() != null) p.setInt(1, getId().intValue());
else p.setNull(1, Types.INTEGER);I want to set the 2nd parameter (which is of the mylist type) in a similar way. But I don't know which SQL type I should choose from. If I choose Types.ARRAY I get an invalid type error, the same goes for Types.OBJECT, and Types.BLOB. And which set... method should I call on the prepared statement? And what should I pass to this method? The Array object of the results of the getData() method of the Array object?
Regards,
PeterTypes.ARRAY should be the right sql-type
The value should be an oracle.sql.ARRAY instance.
To prepare and return one of this type you
first need to prepare the Array domain for DML by calling arrayDomain.prepareForDML(jdbcconn) (passing in the jdbc connection object) and then call arrayDomain.getData()to use in your setObject() call. -
How to get data for custom feilds for standard datasource
i have extracted CRM standard datasource 0CRM_OPPT_I.
In RSA6 i slected feilds which i want to trnasfer to B Iand i also added some custom feilds.
and then i went to RSA5 and i activated datasource.then i went to RSA3and i extracted.
In rSA3 selection screen all the custom feilds are selcted.
after extraction if i go to LIST,only some of the custom feilds data is displaying remaining feilds displayed as blank data
please tel me how to get data
Thanks in advance
HPHi Hari,
Sorry for late reply.
Once you have done the proper mapping by using the transaction BWA1
you need to write the BADI code which can be accesible from the following path:
Go to transaction SPRO
SAP Implementation guide ->Integration with other mySAP components ->Data transfer to the Business Information Warehouse->
Settings for the application specific datasources (CRM) ->
Settings for BW adapter->Execute Badi :BW adapter :Enhancement of datasources in messaging flow.
Select you the datasource enhancement implementation it will open the BADI Implementation..
go To interface tab and double click on the method..it takes you to the ABAP screen where you need to write the logic to populate the custom fields..
Please feel free to mail back if you have any quries.
All the Best..
Thanks
SK -
How to override action for backspace
Hi all,
I have a a Jtextfield in which backspace should not work.
I am not able to achieve this with the statements
// dateText is my textfield
dateText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE,0),
"noAction");
dateText.getActionMap().put("noAction",
doNothing);
Action doNothing = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//do nothing
pls tell me where the problem is??
I haven't added key listener to my textfield...
pls solve this..Hello,
I'm not sure how to prevent deleting with an action, but overriding PlainDocument's remove-Method is another solution:
for example:import javax.swing.*;
import javax.swing.text.*;
public class Test extends JFrame
public static void main(String[] args){new Test();}
private JTextField tf=new JTextField(10);
Test()
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(300,300,300,300);
JPanel mainPanel=new JPanel();
tf.setDocument(new PlainDocument(){
public void remove(int offs, int len){
//Do nothing
mainPanel.add(tf);
setContentPane(mainPanel);
setVisible(true);
}regards,
Tim -
How to register mouselistener for custom class?
i m trying to create a custom class (extending java.awt.Rectangle)which responds to mouse gestures.
i m using it as an object on my drawpad which responds to mouse behavior
like rollover.
the rollover color change is achieved using canvas' graphics object triggerd by my cutom class
i m not able to register a mouseevent for the custom class.
can someone help me in achieving this?
thanks in advance
z_idaneSomething like this? Don't think I'd be likely to extend Rectangle, myself, but anyway...
public class HotSpot extends Rectangle implements MouseMotionListener
private boolean hover = false;
// add constructors to taste
public void mouseMoved(MouseEvent e)
if (this.hover != (contains(e.getX(), e.getY())
this.hover = ! this.hover;
if (this.hover)
// "mouse enter" code here
else
// "mouse exit" code here
public void mouseDragged(MouseEvent e)
}Obviously you'd need something like this elsewhere,
myDrawingPad.addMouseMotionListener(new HotSpot(...)); -
How to detect duplicate for custom object 1
Hi expert,
are there any fields in custom object can detect duplicates If These Fields Match?
we thought it should be "Name" but it's not.
Thanks, sab.Sab, field validation is not going to check for uniqueness of the custom object name. However, you could use field validation to add a value to the custom object name which could make it unique (such as name + rowID or name + created timestamp).
-
How to block javascript for custom sites?
Sometimes I need to disallow javascript for some sites only. I can do this in Opera. Is this posible in FireFox?
For example, I don't like the javascript at google.com when I'm searching for images because the images (thumbnails) are increasing size on mouse over. Can I disable javascript for google.com only?There is not a built-in way of doing this, but you can add that capability by using the [https://addons.mozilla.org/firefox/addon/4922/ YesScript] add-on.
Maybe you are looking for
-
i have ordered an i-pad and cancelled it the other day. I have used my indian debit for that order. So money got debited immediately. Apple has sent an email saying that it is successfully cancelled. But money is not yet credited into my account. ple
-
My iPod Classic 80Gb won't sync with iTunes after "Restoring" to factory settings
My iPod Classic is probably about 8 years old, or maybe a little more and has never before given serious problems. Until I recently "restored" the device, the hard drive had about 40Gb of music and podcasts stored on it but no photos or videos. The d
-
I'm following the odi-12c-getting-started-guide-2032250. But after I imported the demo environment, I couldn't find the parameters_FILES datastore. and under the Sales Administrator datastore, I couldn't find the trg_Customer table that I already cre
-
Bluetooth paired and connected, but not showing up in device list
I have a iphone 4s and a plantronics discovery 975. It was working fine, I don't recall doing any updates... But now, it's showing paired and connected, but when I make a call, it's not connecting and doesn't sho up in the the device options - only
-
Movie freezes on my new iWeb site
Just tried to publish my movie (1G) (new user) to my new iWeb site (new user)... It takes forever to load (is the file too big?) and then when finally loaded it freezes with ever other photo or so and will not play smoothly. It's been frustrating and