001 package com.croftsoft.apps.agoracast.c2p; 002 003 import java.awt.*; 004 import java.awt.event.*; 005 import javax.swing.*; 006 import javax.swing.border.*; 007 008 import com.croftsoft.core.gui.ButtonPanel2; 009 import com.croftsoft.core.lang.NullArgumentException; 010 import com.croftsoft.core.net.news.UsenetMessage; 011 012 /********************************************************************* 013 * @version 014 * 2001-08-13 015 * @since 016 * 2001-07-29 017 * @author 018 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 019 *********************************************************************/ 020 021 public final class AgoracastConfirmPanel 022 extends JPanel 023 implements ActionListener 024 ////////////////////////////////////////////////////////////////////// 025 ////////////////////////////////////////////////////////////////////// 026 { 027 028 private final AgoracastPostPanel agoracastPostPanel; 029 030 private final JTextArea jTextArea; 031 032 private final JButton postButton; 033 034 private final JButton cancelButton; 035 036 ////////////////////////////////////////////////////////////////////// 037 ////////////////////////////////////////////////////////////////////// 038 039 /********************************************************************* 040 * Main constructor. 041 * 042 * @param panelBackgroundColor 043 * 044 * May be null. 045 *********************************************************************/ 046 public AgoracastConfirmPanel ( 047 AgoracastMediator agoracastMediator, 048 AgoracastPostPanel agoracastPostPanel ) 049 ////////////////////////////////////////////////////////////////////// 050 { 051 super ( new BorderLayout ( ), true ); // isDoubleBuffered 052 053 NullArgumentException.check ( agoracastMediator ); 054 055 NullArgumentException.check ( 056 this.agoracastPostPanel = agoracastPostPanel ); 057 058 AgoracastLib.setColor ( this, agoracastMediator ); 059 060 jTextArea = new JTextArea ( ); 061 062 jTextArea.setEditable ( false ); 063 064 // How do we know what font size is appropriate? 065 066 jTextArea.setFont ( AgoracastConstants.LOG_FONT ); 067 068 // How can I set the border to 2 characters wide? 069 070 jTextArea.setBorder ( new EmptyBorder ( 4, 4, 4, 4 ) ); 071 072 add ( new JScrollPane ( jTextArea ), BorderLayout.CENTER ); 073 074 postButton = new JButton ( "Confirm" ); 075 076 postButton.addActionListener ( this ); 077 078 cancelButton = new JButton ( "Cancel" ); 079 080 cancelButton.addActionListener ( this ); 081 082 add ( 083 new ButtonPanel2 ( 084 new JButton [ ] { cancelButton, postButton }, 085 agoracastMediator.getPanelBackgroundColor ( ) ), 086 BorderLayout.SOUTH ); 087 } 088 089 ////////////////////////////////////////////////////////////////////// 090 ////////////////////////////////////////////////////////////////////// 091 092 public void setText ( String text ) 093 ////////////////////////////////////////////////////////////////////// 094 { 095 jTextArea.setText ( text ); 096 } 097 098 public void actionPerformed ( ActionEvent actionEvent ) 099 ////////////////////////////////////////////////////////////////////// 100 { 101 Object source = actionEvent.getSource ( ); 102 103 if ( source == postButton ) 104 { 105 agoracastPostPanel.post ( ); 106 } 107 else if ( source == cancelButton ) 108 { 109 agoracastPostPanel.cancel ( ); 110 } 111 } 112 113 ////////////////////////////////////////////////////////////////////// 114 ////////////////////////////////////////////////////////////////////// 115 }