1 package zirc.gui ; 2 3 import javax.swing.* ; 4 import java.awt.* ; 5 import javax.swing.border.* ; 6 import zirc.base.ToolBarItem ; 7 import zirc.base.IRCconnexion ; 8 import javax.swing.event.* ; 9 import java.awt.event.* ; 10 import zirc.threads.DCCincomingThread ; 11 12 25 32 33 public class DCCtransfer extends JInternalFrame 34 { 35 private final ImageIcon dlIMG = new ImageIcon("fichiers/images/dl.png") ; 36 String sender; 37 String filename; 38 int offset; 39 int port; 40 private GridLayout gridLayout1 = new GridLayout() ; 41 private JPanel jPanel1 = new JPanel() ; 42 private JPanel jPanel2 = new JPanel() ; 43 private GridLayout gridLayout2 = new GridLayout() ; 44 private JPanel jPanel4 = new JPanel() ; 45 private JButton jButton_Cancel = new JButton() ; 46 private JLabel jLabel_Info = new JLabel() ; 47 private ToolBarItem toolBarIcone ; 48 private IRCconnexion IRCchan ; 49 private DCCincomingThread threadIn ; 50 Border border1 ; 51 TitledBorder titledBorder1 ; 52 TitledBorder titledBorder2 ; 53 Border border2 ; 54 private GridLayout gridLayout3 = new GridLayout() ; 55 private JPanel jPanel3 = new JPanel() ; 56 private JPanel jPanel5 = new JPanel() ; 57 private JProgressBar jProgressBar1 = new JProgressBar() ; 58 private JLabel jLabel1 = new JLabel() ; 59 JButton jButton_Resume = new JButton() ; 60 61 public DCCtransfer() 62 { 63 super() ; 64 } 65 66 public DCCtransfer(MainFrame _frm, IRCconnexion _IRCchan, String title, DCCincomingThread _threadIn, String _sender, String _filename, int _offset, int _port) 67 { 68 try 69 { 70 IRCchan = _IRCchan ; 71 sender=_sender; 72 filename=_filename; 73 offset=_offset; 74 port=_port; 75 jbInit() ; 76 threadIn = _threadIn ; 77 this.setTitle(title) ; 78 setSize(IRCchan.getMainDesktopPane().getWidth() - 40, IRCchan.getMainDesktopPane().getHeight() - 40) ; 79 setResizable(true) ; 80 } 81 catch (Exception e) 82 { 83 e.printStackTrace() ; 84 } 85 86 toolBarIcone = new ToolBarItem(_frm.getFrameToolBar(), this) ; 87 } 88 89 private void jbInit() throws Exception 90 { 91 border1 = BorderFactory.createLineBorder(Color.gray, 1) ; 92 titledBorder1 = new TitledBorder("") ; 93 titledBorder2 = new TitledBorder("") ; 94 border2 = BorderFactory.createLineBorder(Color.black, 1) ; 95 gridLayout1.setRows(2) ; 96 this.getContentPane().setLayout(gridLayout1) ; 97 jPanel1.setBorder(null) ; 98 jPanel1.setDebugGraphicsOptions(0) ; 99 jPanel1.setLayout(gridLayout3) ; 100 jPanel2.setLayout(gridLayout2) ; 101 gridLayout2.setColumns(2) ; 102 jButton_Cancel.setText("Annuler") ; 103 jButton_Cancel.addActionListener(new java.awt.event.ActionListener () 104 { 105 public void actionPerformed(ActionEvent e) 106 { 107 jButton_Cancel_actionPerformed(e) ; 108 } 109 }) ; 110 setClosable(true) ; 111 this.setFrameIcon(dlIMG) ; 112 setIcon(false) ; 113 setIconifiable(true) ; 114 setLayer(1) ; 115 setMaximizable(true) ; 116 setResizable(true) ; 117 this.setMinimumSize(new Dimension(300, 250)) ; 118 this.setPreferredSize(new Dimension(300, 250)) ; 119 setSize(IRCchan.getMainDesktopPane().getX() - 20, IRCchan.getMainDesktopPane().getY() - 20) ; 120 getContentPane().setBackground(SystemColor.controlText) ; 121 setFont(new java.awt.Font ("Arial Narrow", 0, 12)) ; 122 this.setBorder(BorderFactory.createLineBorder(Color.gray)) ; 123 setDoubleBuffered(true) ; 124 125 this.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter () 126 { 127 public void internalFrameDeactivated(InternalFrameEvent e) 128 { 129 this_internalFrameDeactivated(e) ; 130 } 131 132 public void internalFrameActivated(InternalFrameEvent e) 133 { 134 this_internalFrameActivated(e) ; 135 } 136 137 public void internalFrameClosed(InternalFrameEvent e) 138 { 139 this_internalFrameClosed(e) ; 140 } 141 }) ; 142 gridLayout3.setRows(2) ; 143 jProgressBar1.setBorder(BorderFactory.createLineBorder(Color.gray)) ; 144 jProgressBar1.setStringPainted(true) ; 145 jLabel1.setText("Status: ") ; 146 jButton_Resume.setText("Resume") ; 147 jButton_Resume.addActionListener(new java.awt.event.ActionListener () 148 { 149 public void actionPerformed(ActionEvent e) 150 { 151 jButton_Resume_actionPerformed(e) ; 152 } 153 }) ; 154 this.getContentPane().add(jPanel1, null) ; 155 this.getContentPane().add(jPanel2, null) ; 156 jPanel2.add(jPanel4, null) ; 157 jPanel4.add(jButton_Cancel, null) ; 158 jPanel4.add(jButton_Resume, null) ; 159 jPanel1.add(jPanel3, null) ; 160 jPanel3.add(jProgressBar1, null) ; 161 jPanel1.add(jPanel5, null) ; 162 jPanel5.add(jLabel1, null) ; 163 jPanel5.add(jLabel_Info, null) ; 164 } 165 166 public void setTitle(String title) 167 { 168 super.setTitle(title) ; 169 } 170 171 void this_internalFrameActivated(InternalFrameEvent e) 172 { 173 toolBarIcone.setPressed() ; 174 IRCchan.setChatFrameWithFocus(this) ; 175 } 176 177 public JProgressBar getProgressBar() 178 { 179 return this.jProgressBar1 ; 180 } 181 182 public JLabel getInfoLabel() 183 { 184 return this.jLabel_Info ; 185 } 186 187 void this_internalFrameDeactivated(InternalFrameEvent e) 188 { 189 190 } 191 192 void this_internalFrameClosed(InternalFrameEvent e) 193 { 194 threadIn.abortTransfer() ; toolBarIcone.destroy() ; 197 } 198 199 void jButton_Cancel_actionPerformed(ActionEvent e) 200 { 201 threadIn.abortTransfer() ; 202 } 203 204 void jButton_Resume_actionPerformed(ActionEvent e) 205 { 206 IRCchan.sendCommand("PRIVMSG "+"#"+sender+" DCC RESUME "+ filename+" "+ port +" "+offset); 207 } 208 } 209 | Popular Tags |