- Added Chat messages

- Changed login port form field from text to spin
- Created an abstract class to message serialization
This commit is contained in:
Flávio Luiz Schiavoni committed 2017-01-20 17:30:53 -02:00
1 parent 69dbb18825
commit fd16955a34
13 files changed
+450 -185

No files matched your search

+6 -3
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.DialogFormInfo">
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.DialogFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
@@ -18,6 +18,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
@@ -82,9 +83,11 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextField2">
<Component class="javax.swing.JSpinner" name="jSpinner1">
<Properties>
<Property name="text" type="java.lang.String" value="8888"/>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="8000" maximum="9000" minimum="8000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel10">
+9 -8
View File
@@ -10,10 +10,11 @@ package br.edu.ufsj.sms.GUI;
* @author flavio
*/
public class Login extends java.awt.Dialog {
public Login(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
jTextField1.setText(System.getProperty("user.name"));
}
/**
@@ -33,7 +34,7 @@ public class Login extends java.awt.Dialog {
jPanel5 = new javax.swing.JPanel();
jPanel7 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jSpinner1 = new javax.swing.JSpinner();
jPanel10 = new javax.swing.JPanel();
jPanel6 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
@@ -66,8 +67,8 @@ public class Login extends java.awt.Dialog {
jLabel2.setPreferredSize(new java.awt.Dimension(200, 18));
jPanel5.add(jLabel2);
jTextField2.setText("8888");
jPanel5.add(jTextField2);
jSpinner1.setModel(new javax.swing.SpinnerNumberModel(8000, 8000, 9000, 1));
jPanel5.add(jSpinner1);
jPanel5.add(jPanel10);
add(jPanel5);
@@ -95,13 +96,13 @@ public class Login extends java.awt.Dialog {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
this.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
public String getName() {
return jTextField1.getText();
}
public int getPort() {
return Integer.parseInt(jTextField2.getText());
return ((Integer) jSpinner1.getValue()).intValue();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
@@ -116,7 +117,7 @@ public class Login extends java.awt.Dialog {
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration//GEN-END:variables
}
-74
View File
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Share My Sheet"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jToolBar1" alignment="0" pref="400" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jToolBar1" min="-2" pref="63" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="231" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JToolBar" name="jToolBar1">
<Properties>
<Property name="rollover" type="boolean" value="true"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="shareButton">
<Properties>
<Property name="text" type="java.lang.String" value="Share My Sheet!"/>
<Property name="actionCommand" type="java.lang.String" value="Share My Sheet!"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shareButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
+171
View File
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Share My Sheet"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jToolBar1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jToolBar1" min="-2" pref="63" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JToolBar" name="jToolBar1">
<Properties>
<Property name="rollover" type="boolean" value="true"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="shareButton">
<Properties>
<Property name="text" type="java.lang.String" value="Share My Sheet!"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shareButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Chat">
<Property name="tabTitle" type="java.lang.String" value="Chat"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">
<Properties>
<Property name="dividerLocation" type="int" value="400"/>
<Property name="orientation" type="int" value="0"/>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane3">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="left"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JEditorPane" name="chatBoard">
<Properties>
<Property name="contentType" type="java.lang.String" value="text/html" noResource="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="bottom"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="0"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextArea" name="jTextArea2">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Send"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
@@ -6,13 +6,15 @@
package br.edu.ufsj.sms.GUI;
import br.edu.ufsj.sms.control.AlarmClock;
import br.edu.ufsj.sms.net.Message;
import br.edu.ufsj.sms.net.ChatMessage;
import br.edu.ufsj.sms.net.ScreenCastMessage;
import br.edu.ufsj.sms.net.Socket;
import java.awt.Component;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -24,10 +26,10 @@ import javax.swing.JLabel;
*
* @author flavio
*/
public class Main extends javax.swing.JFrame {
public class MainWindow extends javax.swing.JFrame {
/**
* Creates new form Main
* Creates new form MainWindow
*/
private Socket socket;
private AlarmClock alarmClock;
@@ -38,13 +40,14 @@ public class Main extends javax.swing.JFrame {
private String name;
private int port;
public Main(String name, int port) throws UnknownHostException {
public MainWindow(String name, int port) throws UnknownHostException {
initComponents();
this.name = name;
this.port = port;
this.socket = new Socket(this);
this.socket.start();
this.timer = new Timer();
jLabel1.setText("Connected on port " + this.port + " name " + this.name);
}
/**
@@ -60,6 +63,15 @@ public class Main extends javax.swing.JFrame {
shareButton = new javax.swing.JToggleButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel2 = new javax.swing.JPanel();
jSplitPane1 = new javax.swing.JSplitPane();
jScrollPane3 = new javax.swing.JScrollPane();
chatBoard = new javax.swing.JEditorPane();
jPanel3 = new javax.swing.JPanel();
jTextArea2 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Share My Sheet");
@@ -67,7 +79,6 @@ public class Main extends javax.swing.JFrame {
jToolBar1.setRollover(true);
shareButton.setText("Share My Sheet!");
shareButton.setActionCommand("Share My Sheet!");
shareButton.setFocusable(false);
shareButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
shareButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
@@ -78,33 +89,81 @@ public class Main extends javax.swing.JFrame {
});
jToolBar1.add(shareButton);
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS));
jSplitPane1.setDividerLocation(400);
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
chatBoard.setContentType("text/html"); // NOI18N
jScrollPane3.setViewportView(chatBoard);
jSplitPane1.setLeftComponent(jScrollPane3);
jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jPanel3.add(jTextArea2);
jButton1.setText("Send");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel3.add(jButton1);
jSplitPane1.setBottomComponent(jPanel3);
jPanel2.add(jSplitPane1);
jTabbedPane1.addTab("Chat", jPanel2);
jScrollPane1.setViewportView(jTabbedPane1);
jLabel1.setText("jLabel1");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addComponent(jScrollPane1)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
.addComponent(jScrollPane1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void shareButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shareButtonActionPerformed
// TODO add your handling code here:
System.out.println("" + shareButton.isSelected());
if (shareButton.isSelected()) {
this.timer = new Timer();
this.alarmClock = new AlarmClock(this.name, this.socket);
this.timer.scheduleAtFixedRate(this.alarmClock, 0, Main.TIME);
this.timer.scheduleAtFixedRate(this.alarmClock, 0, MainWindow.TIME);
shareButton.setText("Stop sharing it!");
} else {
this.timer.cancel();
@@ -112,11 +171,25 @@ public class Main extends javax.swing.JFrame {
}
}//GEN-LAST:event_shareButtonActionPerformed
public void receiveMessage(Message message) {
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if (jTextArea2.getText().trim().length() == 0) {
return;
}
ChatMessage message = new ChatMessage();
message.setText(jTextArea2.getText());
message.setName(this.name);
try {
this.socket.send(message.toByteArray());
} catch (IOException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
jTextArea2.setText("");
}//GEN-LAST:event_jButton1ActionPerformed
public void receiveScreenCastMessage(ScreenCastMessage message) {
// Verificar se a aba existe, se existir, atualizo.
ByteArrayInputStream bais = new ByteArrayInputStream(message.getImageByte());
BufferedImage image;
Component tab = null;
try {
for (int i = 0; i < jTabbedPane1.getTabCount(); i++) {
String name = jTabbedPane1.getTitleAt(i);
@@ -132,13 +205,31 @@ public class Main extends javax.swing.JFrame {
JLabel myShoot = new JLabel(new ImageIcon(image));
jTabbedPane1.addTab(message.getName(), myShoot);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void receiveChatMessage(ChatMessage message) {
SimpleDateFormat dt = new SimpleDateFormat("dd/MM/yyyyy hh:mm:ss");
Date date = new Date();
chatBoard.setText(dt.format(date) + " | " +
"<b>" + message.getName() + "</b>: "+
message.getText() + "<br>" +
chatBoard.getText()
);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JEditorPane chatBoard;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JToggleButton shareButton;
// End of variables declaration//GEN-END:variables
-4
View File
@@ -20,14 +20,10 @@ import javax.imageio.ImageIO;
*/
public class ScreenShot {
public ScreenShot() {
}
public BufferedImage takeAShot() throws AWTException, IOException {
Robot robot = new Robot();
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage output = robot.createScreenCapture(screenRect);
return output;
}
}