How do I write an external class with global constants?

Hi you all !
First I want to explain what exactly I want to do:
I have an application that should run in different resolutions. The app runs fullscreen, and I don't use Layouts or something, just a single Frame with a Graphics Object.
Now to handle the different resolutions, I want to write an external class with some constants to use. The usage in my main Class should be something like this:
public
class blah
private Constants myConstants;
public blah()
if (highResolution)
myConstants = new hiResConstants();
else
myConstants = new loResConstants();
System.println(String.valueOf(myConstants.SCREEN_WIDTH);
}or somthing like that. The important fact is that I can choose the constants at runtime and that I am NOT forced to use methods to get the values, cause something like
System.println(String.valueOf(myConstants.getScreenWidth());sux if you have methods using 5 or more parameters.
Anybody out there who understood my problem and can help me??? PLEASE?
best regards,
Skippy

First, what's so much worse about
System.println(myConstants.getScreenWidth());
than
System.println(myConstants.ScreenWidth);
Is the extra five characters really that bad? (Note
you don't need the String.valueOf method call.)Well actually it was a wrong example I gave here, but it's not the call that makes me shake but the implementation:
public int screenWidth = 1024;vs.
public
int getScreenWidth()
return 1024;
}Here it makes a bigger difference, even when you think of managing about 100 or even more constants.
Second, why do you have methods that take five or more
parameters!?Well, maybe this example show up what I mean:
if (cursorIsInArea(100,100,200,200,areaId))
doSomeStuff();Ok, I could use Rectangles here, but if you think of the timing here (I draw 30 frames / sec and this check comes about every frame or the animation would be choppy) I refuse to create an Object everytime I make this call.
Btw: Is it worth thinking about the time of execution like I did in this example? OO is a neat thing, but is it that fast?
I don't think isCursorInArea(new Rectangle(100,100,200,200),areaId) is such a great idea, but I might be wrong.
It sounds like you're trying to compound a bad design
with an even worse design for no good reason!Well, I'm not that experienced Java programmer to judge about that, but I (and my profs at university too) found my codes well structured and designed so far.
Skippy
PS: the string.valueOf(123) call came from cut&paste:
system.out.println(string.valueOf(number1)+string.valueOf(number2));Try this without the function.... ;-)

Similar Messages

  • How do i use an external display with my macbook pro?

    How do I use an external display with a macbook pro?

    Just buy the proper adapter cord, such as MiniDisplay port to HDMI for example.  Plug it in and it will be automatically recognized.  Use System Preferences > Displays to set options.
    The display can Mirror your primary desktop or Extend the Desktop.
    Regards,
    Captfred

  • How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    No, nothing will prevent the computer from going to sleep when you close its display except third-party hacks that are designed to do exactly that. I strongly advise against using any of those, as they may interfere with successful entry into clamshell mode (and they carry other downside risks as well). Just wait until the computer is asleep (with its sleep light pulsing), then press any key on the keyboard. It sounds as though your setup is working as it's designed to do.

  • How do I view an external display with my macbook pro closed?

    How do I view an external display with my macbook pro closed?  I am using  a wireless keyboard and trackpad, and I would like to use a larger (Dell) monitor with my Macbook Pro closed.

    Here are the rules for Clamshell mode:
    http://support.apple.com/kb/HT3131

  • How do I format an external drive with mountain lion?

    How do I format an external drive with mountain lion?

    Applications > Utilities > Disk Utility
    select the external drive in the left pane
    partition and format in the right pane

  • How do you compile Flex-dependent classes with ASC?

    Hi,
    I've been trying unsuccessfully for most of the evening to compile a .as file that relies on mx.collections.ListCollectionView using asc. I figured I could just import the Flex framework SWCs from the command line with asc, but asc doesn't seem to respect SWCs - it only seems to respect .abc files.
    So, I've spent most of my time trying to compile the Flex framework into a single .abc file that I can import whenever I want to compile a class that relies on Flex. I figured I could make a base .as file with include statements for all of the Flex .as files (copying the approach I saw for files like builtin.as) and compile that, but all I seem to get are compiler errors - mostly "[Compiler] Error #1181: Forward reference to base class (base class name)."
    I have a feeling I'm doing this completely the wrong way. I'd very much appreciate any assistance that anybody can offer me.
    Thanks,
    - max

    <div class=Section1><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>I use MXMLC to compile my .as file projects.<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>Alex Harui<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>Flex SDK Developer<o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><a href="http://www.adobe.com/"><span style='color:blue'>Adobe<br />Systems Inc.</span></a><o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'>Blog: <a href="http://blogs.adobe.com/aharui"><span<br />style='color:blue'>http://blogs.adobe.com/aharui</span></a><o:p></o:p></span></p><br /><br /><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";<br />color:#1F497D'><o:p> </o:p></span></p><br /><br /><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><br /><br /><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span<br />style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Maxim Porges<br />[mailto:[email protected]] <br><br /><b>Sent:</b> Monday, February 09, 2009 9:22 PM<br><br /><b>To:</b> [email protected]<br><br /><b>Subject:</b> How do you compile Flex-dependent classes with ASC?<o:p></o:p></span></p><br /><br /></div><br /><br /><p class=MsoNormal><o:p> </o:p></p><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>A new discussion was started by<br />Maxim Porges in <br><br /><br><br /><b>Developers</b> --<br><br />  How do you compile Flex-dependent classes with ASC?<br><br /><br><br />Hi, <br><br /><br><br />I've been trying unsuccessfully for most of the evening to compile a .as file<br />that relies on mx.collections.ListCollectionView using asc. I figured I could<br />just import the Flex framework SWCs from the command line with asc, but asc<br />doesn't seem to respect SWCs - it only seems to respect .abc files. <br><br /><br><br />So, I've spent most of my time trying to compile the Flex framework into a<br />single .abc file that I can import whenever I want to compile a class that<br />relies on Flex. I figured I could make a base .as file with include statements<br />for all of the Flex .as files (copying the approach I saw for files like<br />builtin.as) and compile that, but all I seem to get are compiler errors -<br />mostly &quot;[Compiler] Error #1181: Forward reference to base class (base<br />class name).&quot; <br><br /><br><br />I have a feeling I'm doing this completely the wrong way. I'd very much<br />appreciate any assistance that anybody can offer me. <br><br /><br><br />Thanks, <br><br /><br><br />- max <o:p></o:p></p><br /><br /><div class=MsoNormal><br /><br /><hr size=2 width=200 style='width:150.0pt' align=left><br /><br /></div><br /><br /><p class=MsoNormal style='margin-bottom:12.0pt'>View/reply at <a<br />href="http://www.adobeforums.com/webx?13@@.59b7d5d2">How do you compile<br />Flex-dependent classes with ASC?</a><br><br />Replies by email are OK.<br><br />Use the <a<br />href="http://www.adobeforums.com/webx?280@@.59b7d5d2!folder=.3c060fa3">unsubscribe</a>< br />form to cancel your email subscription.<o:p></o:p></p><br /><br /></div>

  • How do I use an external mic with the iPad4?

    How do I connect an external mic to the new iPad4? Older models seem to have worked, but the lightning connector causes a lot of problems. I would like to use my Zoom H1 with my iPad4 and GarageBand. Any ideas? Thanks so much!

    Secrets of the iPad Camera Connection Kit
    http://howto.cnet.com/8301-11310_39-57401068-285/secrets-of-the-ipad-camera-conn ection-kit/
     Cheers, Tom

  • How do I format an external HD with Recovery Disk Assistant on?

    Hi,
    I have seen a couple of threads on this, but I'm still not "Compos Mentis" with how to format an external drive with the Recovery Disk Assistant on.
    I have a 320GB which has my recovery disk assistant on - "Don't ask!" - Anyway it goes without saying that I want it all back, but I'll be damned if I can get there. I have managed to view (after a lot of faffing) what I thought was the External Drive, but now realise that it's not...this is what I am now seeing - are these removable via partition (disk0s1 & Recovery HD) as I have been merrily trying to erase them in he belief that they were the external HD and as far as I can see nothing has changed...only my annoyance!
    Anyway in short, I need this
    A) view the external drive and
    B) Format it back to 320GB
    Can anyone spoon feed me a way out?
    Thanks

    I don't understand what you mean by, "how to format an external drive with the Recovery Disk Assistant on."
    You don't need to use the Recovery HD to format an external drive. Just use Disk Utility:
    Drive Preparation
    1. Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Security button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Steps 4-6 are optional but should be used on a drive that has never been formatted before, if the format type is not Mac OS Extended, if the partition scheme has been changed, or if a different operating system (not OS X) has been installed on the drive.

  • How to handle starting of external processes with Runtime.exec() properly

    hi people,
    you find a lot about starting external processes with the Runtime class in every forum.
    -> that the stdout of the started processes has to be redirected and read
    due to os buffer problems
    -> that calling batches is done by starting the interpreter and the batch as parameter (cmd.exe, /bin/sh,..)
    -> that the created process doesn't have an os environment
    -> ...
    but what if you don't know anything about the started process.
    what if you only want only to start an external process. if you don't want to wait til waitfor() returns and if you don't read the streams of the created processes, the os stdout buffer will overflow immediately an the started process will be blocked.
    you can read the stdout of the started process, but what if the process does print nothing to stdout, and your bufferreader.readLine() will block ?
    you can do this (read buffer, waitFor()) in an separate thread, but the thread lives til the started process will finish, so maybe you got dozens of senseless thread ?
    So, what is an effective and good way to start external programs/processes if you don't know about them.
    so i would be grateful for an answer
    regards
    Alen

    I realize that's a pat answer, but it's true. Spawing off another program without being able to predict its behavior is dangerous.
    But anyway, as I understand it creating a new process is relatively expensive. The cost of creating new threads to read the process's I/O and later garbage collecting those threads when the process dies, probably isn't much of an additional burden.

  • How do I use two external monitors with my laptop?

    I have a new Pavilion dm4-301 d cl Entertainment PC.   My OS is Windows 7.   I am used to using two external monitors with a docking station.   This new laptop does not have a docking station.  What do I need to get  to use two external monitors? 
    This question was solved.
    View Solution.

    Certainly not without a dock but even with, HP laptop docks pretty well limit you to one of the external monitor ports, even if there are two on the dock. We have used a device called an Atlona AT-HDPIX2 which is a usb to hdmi adapter. It provides a third monitor capability for a laptop....use the native external monitor port and the internal laptop display and then this device gives a third monitor which is full configurable from the Windows 7 display interface...clone, extend, etc. It allows full HD resolution and is responsive enough for even light gaming.  HP makes no true docking station for your laptop. 

  • Re:  Leone's post May 2014 about how to best use an external drive with Aperture

    I am trying to find Leone who had a great post May 2014 to Diane. I posted tho same message as a 'Reply' to the Leone/Diane posts but then was worried it would not show up since that was some time ago so I decided I should post it as new.  Apologies if it comes through twice.   I am having trouble as indicated below:
    I found this response to the question about Aperture and external hard drives from last May.  I bought a WD My Book 4TB and need to back up photos I have in Aperture (many!) to free up space.  I am a photographer and need to be able to plug the external drive in as needed, pull a photo out from the WD and back into Aperture to work on it if needed.
    I read your directions to Diane and have the external drive formatted Mac OS Extended (Journaled).  I read the two ways you suggest to move part or all of my library to an external drive and still be able to use it in Aperture with all the metadata saved, as I need to continue to work with the images.  I am not completely clear about the advantage of the 'referenced' method but decided to go with the Split Library because it sounded like the Referenced method would still keep originals (and take space) in Aperture.  I'm not sure about this, but that was what I chose.
    I have backed up my computer, formatted the drive then went to Aperture to begin.  I do the 'Export' and it shows the external drive it will go to but when I click 'OK', it says "EXPORT LIBRARY FAILED - Library could not be create because the file system of the destination volume is not supported."  I doubled checked to be sure the drive was Journaled which it was.  I did call WD and talk to them but they told me this was outside their area.
    Also, in Aperture, I have my photos in Projects by yymmdd.  Is it possible to transfer Projects into the ext. drive without having to break them out of the Projects?
    Any direction anyone might give would be greatly appreciated, Sandy

    Hi Sandy,
    I suggest taking a week or two to get to know Aperture better before proceeding.  Aperture can do many things, and can do what you want.  It's important to be specific about what you want, however.  From what you've said, it appears that you don't yet know.
    bybeeler wrote:
    [1] I found this response to the question about Aperture and external hard drives from last May.  I bought a WD My Book 4TB and need to back up photos I have in Aperture (many!) to free up space.
    [2] I am a photographer and need to be able to plug the external drive in as needed, pull a photo out from the WD and back into Aperture to work on it if needed.
    [1] A back-up is a copy of digital files stores on a separate device.  A back-up is recommended because drives fail, and humans make mistakes.  A back-up is not used to free up storage space.
    [2] Aperture can be set up in many equally-usable ways.  The program files reside (almost always) on your system drive.  The data files can be anywhere you want them, as long as they are on locally-mounted drive(s).  The main data file is your Library.  The best place for it is on the drive that has the fastest throughput to your logic board.  This is, in nearly 100% of machines, the system drive.  But Aperture functions well with Libraries of secondary drives — internal or external — with sufficient throughput.  USB-3 and Thunderbolt I (& II) provide sufficient throughput for using an Aperture Library on a secondary drive.
    Nearly all photographers will fill whatever storage space is available (making data is what photographers do).  The question is: what do you do when your Library no longer fits on your system drive?  (And remember, you should leave at least 10% (I recommend 20% for heavy users of Aperture) of your system drive free.)  The answer depends, primarily, on whether your computer is portable or fixed in location. 
    If fixed, just buy a more-than-large-enough secondary drive of USB-3 or faster throughput, mount it permanently, and move (using Finder) your Library to it.
    If your computer is portable (and you can't increase the on-board storage), you have to select the best from several confusing alternatives:
    • Put your Library on an external drive with throughput at least as fast as USB-3
    — Pros:  Easy to maintain and back-up.
    — Cons:  Must have drive with you in order to use your Library.
    • Leave your Library on your system drive, but relocate your Images' Originals to an external drive.
    — Pros:  You can work on your Library without having the external drive available.
    — Cons:  You can't export (except Previews), Print, or make adjustments until your external drive is mounted.  Significantly more difficult to administer, especially importing and backing-up.
    • Leave your Library and and _some_ of your Images' Originals on your system drive, and relocate most of your Image's Originals to an external drive.
    — Pros: You can do any work on those Images whose Originals are stored in the Library regardless of where the external drive is.
    — Cons: Yet another level more difficult to administer.
    If you are comfortable with the administrative overhead, the third set-up will be the most rewarding.  Keep all _current_ Images Originals inside your Library, and routinely relocate the Originals of Images no longer current to the external drive.
    In no case is it recommended that you at any time remove from your Library an Image (not the Original — the Image in Aperture) that you expect to ever use again.
    HTH,
    —Kirby.

  • How to display value from java class with output generated with toplink

    i hava a requirement of displaying (distance ie calculated in java class) with output generated by query.
    ie if output is like
    school name (distance)
    physical address
    here the school name and physical address are retrived from database.

    Hi,
    ValueHolders are used by the JSF internal framework. To work with an object (attributes) in a managed bean you don't need to make it returning a value holder.
    Create a POJO, provide accessor methods and register it as a managed bean. Access it from JSF with EL
    Frank

  • How can i write a XML file with oracle data ?

    How can i write a XML file using PL/SQL.
    Can i do as follows.
    1.Open a file using UTL_FILE.FOPEN(LC_DIR_LOC,'abc.xml','W')     ;
    2.write all the required tag and value using UTL.put_line
    that is enough. Is not, please guide me to write.
    gk

    Having Oracle 9i.
    One more doubt. In the speck, some constand values are there, When i write the same into file, How can i write ?.
    1. l_str := ' "E27" '
    or
    2. l_str := ' E27 '
    UTL_FILE.PUT_LINE(L_FILE_POI,l_str,TRUE);          
    1 case : in XML file : "E27"
    In 2 case : E27
    When we write a XML file through editors , we have to define the constant within quote . is it?      
    Which one can i use ? Or any other way is there ..
    Thanks and Regards
    gopi

  • How do I use an external microphone with iPhone Facetime?

    Model of iphone doesn't matter to me.  I have an Iphone 4S or Iphone 5 to use.  I am specifically trying to use a wireless microphone set with Facetime so I can get better audio quality at a distance.  Of course, I have a mount for my phone so it's pointed toward me.  Can anyone figure out how I can bypass the internal microphones and use and external?  I have already tried plugging into the jack on the phone, but no luck.
    If there is some sort of adapter to plug into the Lightning port or 30pin that might bypass the external mics when using Facetime then I can go with that too.
    Any help is appreciated!

    Hello lizarose,
    You might consider recording your video in the QuickTime Player application. The QuickTime Player application will allow you to control input sources for both your video and audio (allowing you to choose the Fast Track for audio and the iSight camera for video).
    Once in QuickTime Player, choose 'New Movie Recording' from the File menu. In the resulting window, on the controls bar (near the record button), there will be a small triangle. This triangle will produce a menu allowing you to choose your Fast Track as the desired microphone.
    Once the video is recorded and satisfactory, from the File menu, you can choose 'Export To,' then 'iMovie...' After the export process completes, open iMovie (close and re-open if necessary), and you should be prompted to import the video into iMovie. If, for some reason, iMovie is not an option, the video can be exported to the Desktop or the Movies folder (if exporting, choose 'Movie' for Format), then imported into iMovie via the File menu, 'Import,' 'Movies...'
    QuickTime Player 10.x: Record video or audio
    http://support.apple.com/kb/PH5871
    QuickTime Player 10.x: Export a movie in another format
    http://support.apple.com/kb/PH5878
    iMovie '11: Import video from movie files
    http://support.apple.com/kb/PH2153
    Cheers,
    Allen

  • How can I execute a java class with arguments from an air application built from mxml?

    I have an mxml application. It has a button, and when that button select event occurs, I want my mxml air app to pass arguments to a java class I have built, which resides in a package path on my system. I need to be able to pass several arguments to my java method from my mxml call. How do I do this, and what config files are necessary? For the simple task I want to engineer, can you show me an example of a properly configured config file? My java class has been executed at the command line in the past as follows:
    java -cp %CP% com.abc.prism.queue.EmitMessage XYZ "my message text" 192.12.13.14 5672
    where %CP% is an env variable that tells my class the classpath it runs with, and XYZ, "my message text", the IP address, and the port are the arguments I must pass from mxml to my java class. How do I accomplish this?
    How do I make known to the java class I call from mxml the %CP% class path? It tells my java class where to find various rabbitMQ jars.

    Hi,
    You need to use Integration technology like BlazeDS or LCDS.

Maybe you are looking for

  • Sales order Creation when a PO is saved for a particular PO type

    Hi....... Can any one give me some idea and sort of sample code which will generate a SO when someone would save PO of a particular type ? Thanks is advance ...............

  • Batch classification class and MBC3

    Hi, I am a bit confused with the batch determination (i.e. how the R/3 searches the correct batch). Kindly please correct me on the following steps. 1 u2013 Base on OMCG setup, R/3 pulls the batch search procedure base on the movement type in IM. 2 u

  • DV camera firewire

    I need to get some video from my Mini DV Camera onto my iMac. Is there a certain firewire I need to get? I need to be able to go into and shop and find what I need. I have no idea about Firewire..or is there another way to get the vdeo onto the compu

  • ITunes imported a lot of trash...

    For some reason I have almost 2000 files with the sounds of a couple of games, many of them less than 1 second long. Is there a way to select them and delete them other than one-by-one? Thanks.

  • Itunes fails to run after upgrade

    i upgraded my itunes to v7.3 i had no problems before then, but now it produces an error: unable to start due to problem with audio configuration. there have been no changes to my audio configuration, so i don't understand how this has happened.... a