How to use an image as button?
I want to set an image as the background of a frame, and also want use four regions of the image as four buttons. How?
How about an image on the JFrame with four JButtons with some type of image (even if you copy a piece of you original image to place on the button)? I played around with this and its kind of neat. Easier from a gui perspective to see buttons than flat regions -
Have fun
//in a class that extends JFrame, create the image panel and add buttons with icons to it...
Container contentPane = getContentPane();
ImagePanel imagePanel = new ImagePanel(); //see below
contentPane.add(imagePanel);
JButton button = new JButton();
button.setIcon(new ImageIcon(WorldMap.class.getResource("someGIF.gif"))); //or other form of getting and setting an icon
button.setSize(65,45);
mcsButton.setLocation(405,175);
mcsButton.setContentAreaFilled(false); //important so the button looks like a raised part of the picture...not a grey box with an icon.
mcsButton.addMouseListener(new MouseAdapter()
public void mouseClicked(MouseEvent e)
//do something
imagePanel.setLayout(null);
imagePanel.add(mcsButton,null);
//code to put an image on a JPanel I received from this forum
class ImagePanel extends JPanel
private Image image;
public ImagePanel()
image = Toolkit.getDefaultToolkit().getImage("C:/WholeWorldViewJPG.jpg");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image, 0);
try
tracker.waitForID(0);
catch (InterruptedException e)
public void paintComponent(Graphics g)
super.paintComponent(g);
Dimension d = getSize();
int clientWidth = d.width;
int clientHeight = d.height;
int imageWidth = image.getWidth(this);
int imageHeight = image.getHeight(this);
g.drawImage(image, 0, 0, this);
for (int i = 0; i * imageWidth <= clientWidth; i++)
for (int j = 0; j * imageHeight <= clientHeight; j++)
if (i + j > 0)
g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);
}
Similar Messages
-
How to Use an Image to Customize the Static Button Widget
Can I just get someone to help me figure out how to use an image to customize the static button widget, please?
I have tried using several different types of images, but none of them seem to actually change the appearance of the button.
Thanks!
Laura
Captivate 5.5I tried to use the tools within the widget itself - it offers you the opportunity to use an image (see screenshot below).
I also opened it in Flash and tried to replace the images for one of the button styles there w/ my own, but in re-publishing the SWF from there I broke the widget. When I attempted to use the edited widget, there were no customization controls available after I inserted it (see screenshot two below). -
How to use Checkbox and radio buttons in BI Reporting
Hi BW Experts,
My Client has given a report in ABAP format and the report has to be develop in BI.It contains Check boxes and the radio buttons. I dont know how to use Checkboxes and radio buttons in Bex.For using this option, do we need to write a code in ABAP.Please help on this issue.
Thanks,
RamHi..
Catalog item characteristic
- Data element
- Characteristic type
Entry type
List of catalog characteristics
Designer
Format (character)
Standard characteristic
Alternative: Master characteristic
(used for automatic product
assignment)
Simple entry field
Alternatives:
Dropdown listbox or radio button
list -
How to use the cases in button action?
Hi Experts,
I want to get a prompt message if the field is empty.I got it but at the same time if the field is filled I want the other action to be performed that is to call a BAPI and give me output.How can I give two events for the same action.
How to use the cases in button action?
So, please guide me.Urgent need
Regards
NutanHi Nutan,
if I understand you, then you have a simple validation. Therefore you can use the validation functionality of VC for your components. An alternative could be by writing a new ABAP RFC function module like:
BAPI Input parameters as input and BAPI output parameters as output and an additional return code or string for a message:
IF I_FIELD IS INITIAL.
E_RETURN_CODE = "THE FIELD IS EMPTY."
ELSE.
CALL FUNCTION <YOUR_BAPI>
<BAPI PARAMETERS>
ENDIF.
I hope that helps.
Best Regards,
Marcel -
How to use an image as my form background in form central
how to use an image as my form background in form central pls help me....
Unfortunately this is not supported but you can submit a feature request on this form FormsCentral Ideas.
-
How To use window.print() into Button Attributes
hi,
I want to print a report using an print button.so i am using window.print() function into Button Attributes .But Print pop up screen not pop up . How To use window.print() into Button Attributes .
Thanks
Manojdear hari
"Set button target as URL and put following js as URL Target
javascript:window.print();"
Will this be useful to my another thread raised as follows.
In case, if i am able to generate report as txt (ascii) file instead of doc / pdf and is it possible to send the txt file using host command. I am uable to try since i do not know where to place host command on click &print.
yours
dr.s.raghunathan -
How to use the image manipulation palette to extract a part of an image
How to use the image manipulation palette to extract a part of an image?I have a parent image from which i need to extract a certain sub part.can somebody pls help me on how to use this particular tool?
ThanksUse the above snippet. You might need to convert the Image Type you are using with picture functions. The above snippet will give you good idea on how to achieve what you intend to.
-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow" -
How to add an image or button to an AdvancedDataGrid cell with wrapped text alongside
I have an advanced data grid with which i need to add either
images or buttons to individual cells alongside the text.
This i can do, but what i can't figure out is how to make the
text wrap.
Currently, I can make cell text wrap by using an itemRenderer
which extends Text. Or, I can add an image or button to a cell by
using an itemRenderer which extends HBox and contains an image or
button child. To this HBox i can add a Text or Label object also,
but i can't make the text wrap.
Does anyone have any ideas/suggestions/solutions????
Thanks
Mark"ms10" <[email protected]> wrote in message
news:g8jlb5$l6p$[email protected]..
>I have an advanced data grid with which i need to add
either images or
>buttons
> to individual cells alongside the text.
>
> This i can do, but what i can't figure out is how to
make the text wrap.
>
> Currently, I can make cell text wrap by using an
itemRenderer which
> extends
> Text. Or, I can add an image or button to a cell by
using an itemRenderer
> which
> extends HBox and contains an image or button child. To
this HBox i can add
> a
> Text or Label object also, but i can't make the text
wrap.
>
> Does anyone have any ideas/suggestions/solutions????
I'd look at the code for AdvancedDataGridGroupItemRenderer
and try to see
what keeps it from displaying an icon in the columns that are
not grouping
columns. I'd then extend it to change that and use an icon
function.
HTH;
Amy -
How to use drag n drop button in report display
hello friends
i'm displaying list report . i want one customer one time and with diff amounts .ok first of all i'm diplaying detail customer details , if i click on one customer i have to display that cust one time and i want to get details . just like drag and drop button how to use this in normal report .
please help me out .
thanks & regards.
lavanyaHi,
Check this link..
http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm
And also Check these Examples..
BCALV_TREE_01
BCALV_TREE_02
BCALV_TREE_03
BCALV_TREE_04
BCALV_TREE_05
BCALV_TREE_06
BCALV_TREE_DEMO
BCALV_TREE_DND
BCALV_TREE_DND_MULTIPLE
BCALV_TREE_EVENT_RECEIVER
BCALV_TREE_EVENT_RECEIVER01
BCALV_TREE_ITEMLAYOUT
BCALV_TREE_MOVE_NODE_TEST
BCALV_TREE_SIMPLE_DEMO
BCALV_TREE_VERIFY -
How to use the standrad Refresh button in ooalv Grid?
Hai Experts ,
i write editable oo alv program its works fine. when change the data
then click save button its saved correctly, but the problem is totals of row & column not refresh when i am click the
Refresh button . Please Help how to handle the standard Refresh button in ooalv .
Thanks
Adv....thank q u for ur reply,
when i edit the data in grid and save the data its saved successful,
but the problem is manually i calculating the totals at the end of the Row as well as at end of the columns,
when i edit the data in Grid that totals are not effected for that im using the Standard Refresh button ,
Plz help me. -
How To Use a Custom Close Button In Window Component
Hello,
I have a window component, with the default close button
turned off, and a new custom close button added to the movie clip
that is displayed inside the window component. How do I get a click
on the close button to close the window?
This is the code I currently have to create the window (and
the listeners to close the window using the default close button):basicalyyou have to use
myWindow.deletePopUp();
if my memory serves the content mc is loaded into a mc called
contentHolder, inside the window component, so
if you are referencing the window from the scope of your
loaded mc it will be
this._parent._parent.deletePopUp();
or if from the button's scope
this._parent._parent._parent.deletePopUp();
try traceing the parantage down til you hit the window. -
How could i put image in button bar
import events.ToolbarEvent;
import mx.events.FlexEvent;
import mx.events.ItemClickEvent;
import mx.events.SliderEvent;
import mx.core.*;
import spark.skins.spark.ImageSkin;
import ui.presenters.MainPresentationModel;
[Bindable]
public var fileButtons:Array = [{label:"Open"},{label:"Save"}];
[Bindable]
public var navButtons:Array =
{label:"Adjust",state:MainPresentationModel.ADJUST_STATE},
{label:"Touchup",state:MainPresentationModel.TOUCHUP_STATE},
{label:"Effects",state:MainPresentationModel.EFFECT_STATE}
[Bindable]
public var historyButtons:Array = [{label:"Undo"},{label:"Redo"}];
private function handleFileClick(e:ItemClickEvent):void
if (e.label == "Open")
dispatchEvent(new ToolbarEvent(ToolbarEvent.OPEN));
else if (e.label == "Save")
dispatchEvent(new ToolbarEvent(ToolbarEvent.SAVE));
private function handleNavClick(e:ItemClickEvent):void
callLater(handleNavigation,[e.item.state]);
private function handleNavigation(state:String):void
if (navBar.selectedIndex == -1)
dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW));
else
dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW,true,false,state));
private function handleHistoryClick(e:ItemClickEvent):void
if (e.label == "Undo")
dispatchEvent(new ToolbarEvent(ToolbarEvent.UNDO));
else if (e.label == "Redo")
dispatchEvent(new ToolbarEvent(ToolbarEvent.REDO));
private function handleZoomChange(e:SliderEvent):void
dispatchEvent(new ToolbarEvent(ToolbarEvent.ZOOM, true, false, null, e.value));
]]>
</mx:Script>
<mx:ButtonBar dataProvider="{fileButtons}" itemClick="handleFileClick(event)" />
<mx:ToggleButtonBar id="navBar" dataProvider="{navButtons}" toggleOnClick="true"
creationComplete="event.target.selectedIndex=-1" itemClick="handleNavClick(event)"/>
<mx:Button label="Show Source" click="dispatchEvent(new ToolbarEvent(ToolbarEvent.SRC))" />
<mx:Spacer width="100%" />
<mx:ButtonBar dataProvider="{historyButtons}" itemClick="handleHistoryClick(event)" />
<mx:HSlider value="1.0" minimum="0.1" maximum="3.0" snapInterval="0.1" liveDragging="true" change="handleZoomChange(event)" />
</mx:HBox>
using this code what shoud i do to add image on button barI would extend the button bar and in create children I will add the image.
-
On my Android, the program does not use the image provider. It tries to find folders with images, but fails. How can I use my Picasa images?
R.G.I created an idea for this feature request here:
http://forums.adobe.com/ideas/1090
Feel free to vote on the idea and add comments for clarification if needed. Thanks
-Dave -
How to use an Image as JPanel's background
I want to use an Image as my JPane background, how can I do that? anyone will be kind to provide some sample code?
Thank you, please help
EmilyDo you want to tile the image or scale?
The simplest way I can think of would be to extend JPanel and override paintComponent(Graphics g) to either tile the image or to scale it over the panel. -
How to use background image for a page that work in Netscape..???
Hi there
Is there anyway around to use background image for a portal page that works well with netscape.
As I have used that but in coming in Netscape.
thanks
Rakesh1) You post questions in the wrong forum. (As you title says this is a Swing question).
2) Not once in your last 10 postings have you ever bothered to reply to a posting to thank people for the help you have received.
I seriously doubt you well ever get answers in the future.
Maybe you are looking for
-
CSM-S "Configuration Sync is not supported by this card"
This is the message everytime I try to sync the cards. NETCSP01#hw-module contentSwitchingModule 5 standby config-sync Configuration Sync is not supported by this card NETCSP01# The are both installed into the same 6513. Here are the configs module C
-
Pulling photos out of finder for creating a slideshow
Is it possible to pull photos out of the Finder to create a slideshow?
-
Server configuration EPM system
Hi Experts, I want to install following Hyperion products on my distributed/mixed environments:- Oracle Hyperion Shared Services. Oracle Hyperion Planning. Oracle Hyperion Essbase. Oracle Hyperion Reporting and Analysis (Financial Reporting). Oracle
-
What's OOP's Jargons & Complexities
Here's a long essay on the topic. http://xahlee.org/Periodic_dosage_dir/t2/oop.html Xah [email protected] http://xahlee.org/PageTwo_dir/more.html
-
What do you do if you acccidently scratch off the code on the itunes card?
i was just scratching off the code label thing off my ituns gift card, and some numbers and half numbers were missing. Could i somehow still use the card?