J
I'm not sure I've got what you need, but that's what you're doing.package org.jazzteam.teamtask ;
import java.applet.Applet ;
import java.awt.* ;
import java.awt.event.WindowAdapter ;
import java.awt.event.WindowEvent ;
import javax.swing.JDialog ;
import javax.swing.JFrame ;
import javax.swing.JOptionPane ;
import javax.swing.UIManager ;
public class Sd extends JFrame
{
private class MainApplet extends Applet
{
@Override
public void paint ( final Graphics g )
{
super.paint ( g ) ;
final Graphics2D g2d = (Graphics2D) g ;
g2d.setColor ( Color.red ) ;
g2d.fillRect ( 10, 20, 10, 15 ) ;
g2d.setColor ( Color.pink ) ;
g2d.fillRect ( 30, 40, 20, 20 ) ;
g2d.setColor ( Color.red ) ;
g2d.fillRect ( 10, 20, 10, 15 ) ;
g2d.setColor ( Color.green ) ;
g2d.fillRect ( 40, 75, 30, 30 ) ;
g2d.setColor ( Color.red ) ;
g2d.fillRect ( 10, 20, 10, 15 ) ;
g2d.setColor ( Color.blue ) ;
g2d.fillRect ( 80, 60, 40, 20 ) ;
}
}
public static final Font FONT = new Font ( "Verdana", Font.PLAIN, 11 ) ;
public Sd ()
{
super ( "Игровое Поле" ) ;
setDefaultCloseOperation ( JFrame.DO_NOTHING_ON_CLOSE ) ;
addWindowListener ( new WindowAdapter ()
{
@Override
public void windowClosing ( final WindowEvent event )
{
final Object[] options = { "Да", "Нет!" } ;
final int n = JOptionPane.showOptionDialog ( event.getWindow (), "Закрыть окно?", "Подтверждение",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0] ) ;
if ( n == 0 )
{
event.getWindow ().setVisible ( false ) ;
System.exit ( 0 ) ;
}
}
} ) ;
add ( new MainApplet () ) ;
setPreferredSize ( new Dimension ( 700, 500 ) ) ;
pack () ;
setLocationRelativeTo ( null ) ;
}
public static void main ( final String[] args )
{
javax.swing.SwingUtilities.invokeLater ( new Runnable ()
{
public void run ()
{
UIManager.put ( "Button.font", FONT ) ;
UIManager.put ( "Label.font", FONT ) ;
JFrame.setDefaultLookAndFeelDecorated ( true ) ;
JDialog.setDefaultLookAndFeelDecorated ( true ) ;
new Sd ().setVisible ( true ) ;
}
} ) ;
}
}