need help in making my application dispaly with the dialog box appearing at the center.The "InputDialog.java" contains the dialog i want to appear at the center of th "FoodFrame.java" class.pls somebody help me out.
frame.getX() + frame.getWidth() / 2 is the horizontal center of the frame. You then subtract half of the dialog width, so its left and right are both half of the dialog width off the center. In other words, the dialog is centered.
Please make sure you don't pack() your dialog or frame after centering, otherwise the centering size will not be the actual size on screen.