Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Java modal window


Hi everyone, today i want to share with you about MODAL WINDOW.How it's look like? Before i show you example of MODAL WINDOW, let we look for it's little description :

If a window is modal, no other window can be active while the modal window is displayed.

Simple example is message box from JOptionPane. When a message box is showing, you can't work with other window until you press OK or others button on the message box.
This message box is a simple example of MODAL WINDOW.

You can try compile java code below to see how it's look like.

***********************************************************
COMPLETE SOURCE CODE FOR : ModalWindow.java
***********************************************************


import javax.swing.JFrame;

import javax.swing.JOptionPane;

public class ModalWindow
{
public static void main(String[]args)
{
JFrame myWindow=new JFrame("My Window");

myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myWindow.setSize(400,400);
myWindow.setVisible(true);

JOptionPane.showMessageDialog(null,"Hello");
}
}


***********************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************

Borderless window

Source code below will show you how to create borderless window in java.

*****************************************************************
COMPLETE SOURCE CODE FOR : BorderlessWindow.java
*****************************************************************


import javax.swing.JWindow;
import javax.swing.JButton;

import java.awt.BorderLayout;

public class BorderlessWindow
{
public static void main(String[]args)
{
JButton button1=new JButton("MY BUTTON");
JWindow window=new JWindow();

window.getContentPane().add(button1,BorderLayout.CENTER);

window.setSize(400,400);

window.setVisible(true);
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************

Create window without title bar and window management button

In java, we can use JWindow to create window without title bar and window management button.

RELAXING NATURE VIDEO