How to center a JFrame object on the screen?
Does somebody know how to center a JFrame object on the screen. Please write an example because I'm new with java.
Thank you.
//this will set the size of the frame
frame.setSize(frameWidth,frameHeigth);
//get screen size
Toolkit kit=Toolkit.getDefaultToolkit();
//calculate location for frame
int x=(kit.getScreenSize().width/2)-(frameWidth/2);
int y=(kit.getScreenSize().height/2)-(frameHeigth/2);
//set location of frame at center of screen
frame.setLocation(x,y);
Similar Messages
-
How to place am mime object on the smartform ?
Hi All,
How to place am mime object on the smartform ?
Is there any function module to read a mime object from mime repository?
Any help would be appreciated.
Regards,
Raja Ram.Hi Vishwa,
Thanks for your prompt response.
How to get the obj ID of a MIME object?
I checked in So2_MIME_REPOSITORY bur couldn't find?
Is there any mapping table between MIME object and object ID ?
I am very new to MIME objects.
Please tell me.
Regards,
Raja Ram. -
How do I remove an object from the foreground of a photo eg a fence?
How do I remove an object from the foreground of a photo eg a fence?
What version of Photoshop?
If CC then try here
Learn Photoshop CC | Adobe TV -
How can I write new objects to the existing file with already written objec
Hi,
I've got a problem in my app.
Namely, my app stores data as objects written to the files. Everything is OK, when I write some data (objects of a class defined by me) to the file (by using writeObject method from ObjectOutputStream) and then I'm reading it sequencially by the corresponding readObject method (from ObjectInputStream).
Problems start when I add new objects to the already existing file (to the end of this file). Then, when I'm trying to read newly written data, I get an exception:
java.io.StreamCorruptedException
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
Is there any method to avoid corrupting the stream? Maybe it is a silly problem, but I really can't cope with it! How can I write new objects to the existing file with already written objects?
If anyone of you know something about this issue, please help!
JaiHere is a piece of sample codes. You can save the bytes read from the object by invoking save(byte[] b), and load the last inserted object by invoking load.
* Created on 2004-12-23
package com.cpic.msgbus.monitor.util.cachequeue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
* @author elgs This is a very high performance implemention of Cache.
public class StackCache implements Cache
protected long seed = 0;
protected RandomAccessFile raf;
protected int count;
protected String cacheDeviceName;
protected Adapter adapter;
protected long pointer = 0;
protected File f;
public StackCache(String name) throws IOException
cacheDeviceName = name;
f = new File(Const.cacheHome + name);
raf = new RandomAccessFile(f, "rw");
if (raf.length() == 0)
raf.writeLong(0L);
* Whne the cache file is getting large in size and may there be fragments,
* we should do a shrink.
public synchronized void shrink() throws IOException
int BUF = 8192;
long pointer = getPointer();
long size = pointer + 4;
File temp = new File(Const.cacheHome + getCacheDeviceName() + ".shrink");
FileInputStream in = new FileInputStream(f);
FileOutputStream out = new FileOutputStream(temp);
byte[] buf = new byte[BUF];
long runs = size / BUF;
int mode = (int) size % BUF;
for (long l = 0; l < runs; ++l)
in.read(buf);
out.write(buf);
in.read(buf, 0, mode);
out.write(buf, 0, mode);
out.flush();
out.close();
in.close();
raf.close();
f.delete();
temp.renameTo(f);
raf = new RandomAccessFile(f, "rw");
private synchronized long getPointer() throws IOException
long l = raf.getFilePointer();
raf.seek(0);
long pointer = raf.readLong();
raf.seek(l);
return pointer < 8 ? 4 : pointer;
* (non-Javadoc)
* @see com.cpic.msgbus.monitor.util.cachequeue.Cache#load()
public synchronized byte[] load() throws IOException
pointer = getPointer();
if (pointer < 8)
return null;
raf.seek(pointer);
int length = raf.readInt();
pointer = pointer - length - 4;
raf.seek(0);
raf.writeLong(pointer);
byte[] b = new byte[length];
raf.seek(pointer + 4);
raf.read(b);
--count;
return b;
* (non-Javadoc)
* @see com.cpic.msgbus.monitor.util.cachequeue.Cache#save(byte[])
public synchronized void save(byte[] b) throws IOException
pointer = getPointer();
int length = b.length;
pointer += 4;
raf.seek(pointer);
raf.write(b);
raf.writeInt(length);
pointer = raf.getFilePointer() - 4;
raf.seek(0);
raf.writeLong(pointer);
++count;
* (non-Javadoc)
* @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCachedObjectsCount()
public synchronized int getCachedObjectsCount()
return count;
* (non-Javadoc)
* @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCacheDeviceName()
public String getCacheDeviceName()
return cacheDeviceName;
} -
How to add a ChartOfAccounts object into the database.
how to add a ChartOfAccounts object into the database. please shows sample code
thanksDim CoA As SAPbobsCOM.ChartOfAccounts
CoA = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oChartOfAccounts)
CoA.Code = 11223344
CoA.ExternalCode = "a1234"
CoA.ForeignName = "f Test Account"
CoA.Name = "Test Account"
CoA.AccountType = SAPbobsCOM.BoAccountTypes.at_Other
CoA.ActiveAccount = SAPbobsCOM.BoYesNoEnum.tYES
CoA.FatherAccountKey = 100001
If CoA.Add <> 0 Then
MessageBox.Show(oCompany.GetLastErrorDescription)
Else
MessageBox.Show("Added Account")
End If
Remember the father account key must be a valid account number in the company where you are trying to add the new account. (The G/L Account code seen in the SBO client) -
[OKP1]Change the sequence of CO objects on the screen
Dear everyone,
Could anyone tell me how to change the sequence of CO objects on the screen in OKP1?
Or it is just another mission impossible?
Pls offer me some tips, I appreciate your help in advance.
Regards,
SCWHi...
how about a custom screen (have your abap developer involved) that will have the OKP1 transactions in the order you like and a custom SAVE button that when pressed will make a batch input to associated OKP1 transactions?
cheers
pan -
How much does it cost to replace the screen of a macbook air 11" ?
how much does it cost to replace the screen of a macbook air 11" ?
According to www.ifixit.com the display assembly for MBA 11" models before mid 2012 is US-$ 500, labor not included.
If you're not in the U.S., you better ask your local Apple service center. -
I cracked my iPod touch screen...how much would it cost to replace the screen? The iPod works perfectly, but the pieces of the screen are chipped and cracked. Please help!
Contact Apple or a third party repair center and ask.
-
I cracked my iPad 3. How much would it be to repair the screen?
Hello, I have recently cracked my ipad. I would like to get that apple device repaired. It is the ipad 3 by the way.PLEASE HELP! How much would it cost to get the screen repaired by Apple?
Apple's Limited Warranty http://www.apple.com/legal/warranty/ for iPad excludes coverage for damage resulting from accident, disassembly, unauthorized service and unauthorized modifications.
Apple will provide a replacement iPad for:
iPad model
Out-of-Warranty Service Fee
New iPad
$299
iPad 2, iPad
$249
Make a Genius Bar Reservation
http://www.apple.com/retail/geniusbar/
You can get the glass replaced at 3rd party repair sources for less $, however, the Apple warranty will be voided.
iPad Repair & Screen Replacement Services
http://www.ifixyouri.com/16-ipad-repairs
RepairZoom iPad Repair
http://www.repairzoom.com/ipad-repair.html
Mission Repair
http://www.missionrepair.com/Apple_iPad_Repair_Services_s/431.htm
iGadgetResQ
http://www.igadgetresq.com/ipad-repair/
Cheers, Tom -
How do I fix my itouch if the screen is flashing?
How do I fix my itouch if the screen is flashing purple, black, and white streaks and is unresponsiveness to the power on/off button?
Try here:
iOS: Not responding or does not turn on -
How do i fix my ipod when the screen cracks
how do i fix my ipod when the screen cracks
Have Apple, a third-party place or fix it yur self.
Apple - Support - iPod - Repair pricing
iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
DigiExpress.us - The iPad Repair Professionals
iPod Touch Glass Replacement -
My dock disappears when I am using Word. How can I get it back on the screen?
My dock disappears when I am using Word. How can I get it back on the screen? Thanks very much.
BillYou may have blundered into "Full Screen" mode, an abomination ported from iOS, the iPhone Operating System, land of tiny screens and one-at-a-time Applications.
Try clicking the double-arrows in the extreme upper right of the MenuBar or Window. -
How can I reboot my Touch when the screen is frozen and I cannot use the "slide to power off" feature?
Next try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
Apple Retail Store - Genius Bar -
How can I get an image from the screen? Like screen printer in PC to pasting after in word or other program.
If you do Cmd+Shift+3 you'll get a full screen image saved to your desktop as a jpg file.
Also, you can use Cmd+Shift+4 and you'll get a cursor which you click+drag to draw a box. When you release the drag the boxed in area will be saved to the Desktop as a jpg file. -
How do i save what is on the screen as a pdf or other picture file?
Question
how do i save what is on the screen as a pdf or other picture file?Hi jvanek, see in the next link how you can do that, and save a [http://en.wikipedia.org/wiki/Screenshot screenshot ] as a PNG file :
[https://support.mozilla.org/el/kb/how-do-i-create-screenshot-my-problem How do I create a screenshot ?]
thank you
Maybe you are looking for
-
Just got a new mac - how can I keep working on my old iWeb site??
Hi friends, I just migrated all my old data from an external hd onto my new MacBook. I see my website data, and I put it in the Sites folder, but opening iWeb prompts me to start a new website. How do I continue working on my website, i.e., open my o
-
Use Oracle Attachment for file located in network drive
Hi, We have a requirement to attach the item drawing file to the inventory master item record. The drawing file is stored in a network directory. However, the attachment type of web page only supports http:// not file:\\\. If we do not want to load t
-
I am having no luck getting some HD .mov files to import into Adobe Premiere. Premiere tells me I am missing a codec. Is there a Windows version of the Apple Intermediate Codec? The footage was recorded with a JVC camera onto a Firestore DR-HD100 dri
-
How to preserve recently changed passwords during a RPD promotion/overwrite
Hi All, 1. We are using BIEE built-in authentication (passwords are stored in RPD file); 2. Users are allowed to change their passwords at any time; 3. Other than PD, we also have a DEV and a QA environements where we fix bugs and do minor enhancemen
-
Single-click to open in finder
Is there an option to have single-click open files and folders in the Finder?