One of the MulticastTest
2005-10-29 14:18
281 查看
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MulticastTest{
public static void main(String args[]){
MulticastFrame frame = new MulticastFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
/**
A frame with buttons to make and close secondary frames
*/
class MulticastFrame extends JFrame{
public MulticastFrame(){
setTitle("Sketch");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
//add panel to frame
MulticastPanel panel = new MulticastPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static int DEFAULT_WIDTH = 300;
public static int DEFAULT_HEIGHT =200;
}
/**
A panel with buttons to create and close sample frames.
*/
class MulticastPanel extends JPanel{
public MulticastPanel(){
//add "New" button
JButton newButton = new JButton("New");
add(newButton);
final JButton closeAllButton = new JButton("Close all");
add(closeAllButton);
ActionListener newListener = new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
BlankFrame frame = new BlankFrame(closeAllButton);
frame.show();
}
};
newButton.addActionListener(newListener);
}
}
/**
A blank frame that can be closed by cliking a button.
*/
class BlankFrame extends JFrame{
/**
Constructs a blank frmae
@param closeButton the button to close this frmae
*/
public BlankFrame(final JButton closeButton){
counter++;
setTitle("Frmae"+ counter);
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
setLocation(SPACING * counter, SPACING * counter);
closeListener = new
ActionListener(){
public void actionPerformed(ActionEvent event){
closeButton.removeActionListener(closeListener);
dispose();
}
};
closeButton.addActionListener(closeListener);
}
private ActionListener closeListener;
private static final int DEFAULT_WIDTH = 200;
private static final int DEFAULT_HEIGHT = 300;
private static final int SPACING = 40;
private static int counter = 0;
}
import javax.swing.*;
import java.awt.event.*;
public class MulticastTest{
public static void main(String args[]){
MulticastFrame frame = new MulticastFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
/**
A frame with buttons to make and close secondary frames
*/
class MulticastFrame extends JFrame{
public MulticastFrame(){
setTitle("Sketch");
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
//add panel to frame
MulticastPanel panel = new MulticastPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static int DEFAULT_WIDTH = 300;
public static int DEFAULT_HEIGHT =200;
}
/**
A panel with buttons to create and close sample frames.
*/
class MulticastPanel extends JPanel{
public MulticastPanel(){
//add "New" button
JButton newButton = new JButton("New");
add(newButton);
final JButton closeAllButton = new JButton("Close all");
add(closeAllButton);
ActionListener newListener = new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
BlankFrame frame = new BlankFrame(closeAllButton);
frame.show();
}
};
newButton.addActionListener(newListener);
}
}
/**
A blank frame that can be closed by cliking a button.
*/
class BlankFrame extends JFrame{
/**
Constructs a blank frmae
@param closeButton the button to close this frmae
*/
public BlankFrame(final JButton closeButton){
counter++;
setTitle("Frmae"+ counter);
setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
setLocation(SPACING * counter, SPACING * counter);
closeListener = new
ActionListener(){
public void actionPerformed(ActionEvent event){
closeButton.removeActionListener(closeListener);
dispose();
}
};
closeButton.addActionListener(closeListener);
}
private ActionListener closeListener;
private static final int DEFAULT_WIDTH = 200;
private static final int DEFAULT_HEIGHT = 300;
private static final int SPACING = 40;
private static int counter = 0;
}
相关文章推荐
- 75.Your test database is configured to run in NOARCHIVELOG mode. One of the data files in the USERS
- One of the Mouse Event
- The notes of How We Test Software At Microsoft(1)
- The notes of How We Test Software At Microsoft(4)
- Class JavaLaunchHelper is implemented in both … libinstrument.dylib. One of the two will be used. Wh
- The adidas NMD Singapore is one of the brands top selling
- Refreshing One Column based on the value of Another Column in ADFdi Table
- One usage of recurison: the tower of Hanoi
- The notes of How We Test Software At Microsoft(5)
- vmware:Cannot open the disk 'XXX' or one of the snapshot disks it depends on. reason: failed to lock
- The Practice of Programming Chapter One - Style
- geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
- Test the efficiency of the exclusion objects in Windows
- one of the two jquery Plug-in named "Confirm"
- 评一篇文章(Experiments of the effectiveness of dataflow- and controlflow-based test adequacy criteria)
- Windows Azure CloudBlobContainer.CreateIfNotExist : One of the request inputs is out of range.
- Harvard case-INSEAD, one of the best bschools in the world
- power of the test
- the debug of Test.ipdl demo
- 解决yum升级的问题“There was a problem importing one of the Python modules”