1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
public FlowFrame(String name, String flow) {
super();
//Settings.
this.setSize(550, this.getToolkit().getScreenSize().height-50); //Give the size of the frame.
this.setTitle(name);
this.setDefaultCloseOperation(FlowFrame.DISPOSE_ON_CLOSE);
this.flowArea = new JTextArea();
this.flowArea.setFont(new Font("Arial", 0, 11));
this.flowArea.setText(flow);
//Put the flow text area in a scrollpane.
this.scrollPanel = new JScrollPane();
this.scrollPanel.setViewportView(this.flowArea);
//Create a clear button.
this.clearButton = new JButton(Constants.CLEAR);
//Create a follow button.
this.followButton = new JButton(Constants.UNFOLLOW);
//Create an exit button.
this.exitButton = new JButton(Constants.EXIT);
//Construct the panel containing the buttons.
FlowLayout flowLayout1 = new FlowLayout();
flowLayout1.setHgap(20);
JPanel buttonPanel = new JPanel(flowLayout1);
//Construct a panel for two buttons.
FlowLayout flowLayout2 = new FlowLayout();
flowLayout2.setHgap(100);
JPanel buttonSubpanel = new JPanel(flowLayout2);
//Add the button to the subpanel.
buttonSubpanel.add(this.clearButton);
buttonSubpanel.add(this.followButton);
//Add all the buttons to the panel buttons.
buttonPanel.add(buttonSubpanel);
buttonPanel.add(this.exitButton);
//Add the panel buttons and the flow area to the frame.
this.getContentPane().add(BorderLayout.SOUTH, buttonPanel);
this.getContentPane().add(BorderLayout.CENTER, this.scrollPanel);
this.setVisible(true);
} |
Partager