![]() ![]() ![]() GridBagConstraints constr = new GridBagConstraints() JPanel panel = new JPanel(new GridBagLayout()) JLabel headingLabel = new JLabel("Contact Us Panel") tLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)) Create frame with title Registration DemoįtTitle("JFrame Based Contact Form") In this example, using multiple methods of JFrame, Layout & Events classes to create forms inside of the frame. In the below screenshot a frame is created using JFrame classes of swing library. In the above-given example, the swing library is imported to include different classes to work with the Frame & events. SetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) Please see the below-given example import javax.swing.* Here are the following examples mentioned below. void update(Graphics g) – This one calls the paint to color the frames & elements Examples of JFrame in Java void setTransferHandler(TransferHandler newHandler) – This one sets the property related to the transferHandler, This one creates a mechanism to support the data transfer for the component.Ģ8. void setLayout(LayoutManager manager) – LayoutManager is created by using this method.Ģ7. void setLayeredPane(JLayeredPane jlPane) – LayeredPane Property is set by this method.Ģ6. void setJMenuBar(JMenuBar menubar) – Menubar for JFrame can be set by using this method.Ģ5. void setIconImage(Image img) – Icon for the window frame can be set by using this method.Ģ4. void setGlassPane(Component glassPane) – glassPane property can be set by using this method.Ģ3. void setDefaultCloseOperation(int operation) – Default operation set by this method which will happen when the user initiates the close operation for a Frame.Ģ2. void setContentPane(Container contentPane) – Property of the contentPane is set by this method.Ģ1. void repaint(long time, int x, int y, int width, int height) – This method is used to repaint the specific rectangle inside of the component in few milliseconds.Ģ0. void remove(Component comp) – For removing the specific component from JFrame container we can use this method.ġ9. TransferHandler getTransferHandler() – This method gets the transferHandler property.ġ8. static boolean isDefaultLookAndFeelDecorated() – If the newly created JFrames have their Window decorations as provided by the current look and feel then this method returns true.ġ7. void setRootPaneCheckingEnabled(boolean enabled) – This one sets calls to add & setLayout are forwarded to the contentPane or not.ġ6. void setRootPane(JRootPane root) – This method sets the rootPane Property.ġ5. void processWindowEvent(WindowEvent e) – This method process the window event occurred on the window component.ġ4. String paramString() – This method returns JFrame in the form of String.ġ3. boolean isRootPaneCheckingEnabled() – Calls to add & setLayout are forwarded to contentPane or not is validated by this methodġ2. void frameInit() – It is called by the constructor to initialize the JFrame.ġ1. JRootPane createRootPane() – Create the default rootPane & called by the constructor.ġ0. addImpl(Component comp, Object constraints, int index) – This method adds the specified child element for this frame.ĩ. JRootPane getRootPane() – The rootPane object is returned by this method.īelow given methods access modifier “protected” need to be added at the start of the method –Ĩ. JLayeredPane getLayeredPane() – LayeredPane object is returned by this method.ħ. JMenuBar getJMenuBar() – Menubar set created at the Frame by using this method.Ħ. int getDefaultCloseOperation() – When the user clicks on the close button on this Frame then this method returns the operation.ĥ. Component getGlassPane() – This method creates the glassPane object for JFrame.Ĥ. ![]() ![]() Container getContentPane() – This method creates the JFrame’s contentPane object.ģ. AccessibleContext getAccessibleContext() – This method gets the accessible context that remains associated with the JFrame.Ģ. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |