473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Casting Font object into Element--- Need Help!!

18
Hi all

I really need a solution for the following::
-------------------------------------------------------------------------------------
Say i have a font object called 'myFont' as shown below;

Font myFont= domainAxis.getTickLabelFont();

I need to cast "myFont" object into a "Element" object as i shown below

Element newFont = (Element)myFont;

but this casting doesn't work; it is giving a Casting Exception; How can i cast a Font object in to an Element object?? Because i need to change attributes on that Element object and re-converted iy back to a Font object as below.
--------------------------------------------------------------------------------------
newFont.setAttribute("kerning", "no");
newFont.setAttribute("family","SansSerif");
newFont.setAttribute("name","SansSerif");
newFont.setAttribute("style","plain");
newFont.setAttribute("size","10");

domainAxis.setsetTickLabelFont((Font)newFont);

-------------------------------------------------------------------------------------

How to do the "Font " to "Element" Casting
Regards
Madumm
Jan 19 '07 #1
1 1199
r035198x
13,262 8TB
Hi all

I really need a solution for the following::
-------------------------------------------------------------------------------------
Say i have a font object called 'myFont' as shown below;

Font myFont= domainAxis.getTickLabelFont();

I need to cast "myFont" object into a "Element" object as i shown below

Element newFont = (Element)myFont;

but this casting doesn't work; it is giving a Casting Exception; How can i cast a Font object in to an Element object?? Because i need to change attributes on that Element object and re-converted iy back to a Font object as below.
--------------------------------------------------------------------------------------
newFont.setAttribute("kerning", "no");
newFont.setAttribute("family","SansSerif");
newFont.setAttribute("name","SansSerif");
newFont.setAttribute("style","plain");
newFont.setAttribute("size","10");

domainAxis.setsetTickLabelFont((Font)newFont);

-------------------------------------------------------------------------------------

How to do the "Font " to "Element" Casting
Regards
Madumm
Please do not double post. For a cast to work, the objects must be convertable.
i.e
Type2 b = new Type2();
Type1 a = (Type1) b;
For this to work, then class Type1 must extend Type2 directly or indirectly otherwise you get a class cast exception at runtime.
Jan 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philip K | last post by:
I was trying to use Soap serialisation to save some systems settings how ever it fails if the settings contain a Font object, works fine if the Font object is not in the object being serialised. ...
2
by: Karl Meissner | last post by:
I am having problem casting from object. I want to pass in an value type as an object and then store it as a particular type. The cast from object throws an exception if the types do not match. ...
1
by: Steven | last post by:
VB.NET Via the FontDialog I have retrieved a font. After saving the font (in an XML document) and retrieving it again, I have a string in the following "format"; How can I convert this...
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
2
by: Patti | last post by:
I am building an application using VB.NET 1.1 and I have an issue with Font properties in my Radio Button Lists and Check Box Lists. My issue is that the Font Names and Font Size for these...
1
by: madumm | last post by:
Hi all I really need a solution for the following:: ------------------------------------------------------------------------------------- Font newFont= domainAxis.getTickLabelFont(); Element...
8
by: Z1P2 | last post by:
Line 22 Char 1 says object expected in the following code. For the life of me I can't figure out what it is. I'm sure I'm just overlooking some stupid bit of formatting or something. ...
3
by: SM | last post by:
I'm using simpleXML in PHP and i Can't get this small piece of code to work? Need help I have an XML that looks like this: <?xml version="1.0" encoding="utf-8"?> <VIDEO> <item>...
1
by: Dansmith122 | last post by:
Hi I have been working on the java script for my website and I need help with the out put variables. I need to know how to add more variable for each row in my survey. I am very lost ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.