Browse Source

erfolg nr 1

master
ahren 1 year ago
parent
commit
f7a0de0041

+ 8
- 0
src/ChatProgramm/Start.java View File

package ChatProgramm; package ChatProgramm;


import ChatProgramm.controller.CommandController; import ChatProgramm.controller.CommandController;
import ChatProgramm.controller.GrafikController;
import ChatProgramm.model.GrafikModel;
import ChatProgramm.view.ChatView; import ChatProgramm.view.ChatView;
import ChatProgramm.view.GrafikView;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.UIManager; import javax.swing.UIManager;


{ {
public Start() public Start()
{ {
GrafikModel model = new GrafikModel();
ChatView view = new ChatView(); ChatView view = new ChatView();
GrafikView zeichenflaeche = view.getGvZeichenflaeche();
zeichenflaeche.setModel(model);
GrafikController controller = new GrafikController(zeichenflaeche, model);
controller.registerEvents();
CommandController controller_commands = new CommandController(view); CommandController controller_commands = new CommandController(view);
controller_commands.registerEvents(); controller_commands.registerEvents();
controller_commands.registerCommands(); controller_commands.registerCommands();

+ 58
- 0
src/ChatProgramm/controller/GrafikController.java View File

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

package ChatProgramm.controller;

import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import ChatProgramm.model.GrafikModel;
import ChatProgramm.view.GrafikView;

/**
*
* @author le
*/
public class GrafikController extends MouseAdapter implements MouseMotionListener
{
private GrafikView view;
private GrafikModel model;
public GrafikController(GrafikView view, GrafikModel model)
{
this.view = view;
this.model = model;
}
public void registerEvents()
{
view.addMouseMotionListener(this);
view.addMouseListener(this);
}

@Override
public void mouseDragged(MouseEvent evt)
{
Point p = evt.getPoint();
model.addPoint(p);
view.drawPoint(p);
}

@Override
public void mouseMoved(MouseEvent e)
{
}
@Override
public void mouseReleased(MouseEvent evt)
{
model.endShape();
// if (evt.getButton() == MouseEvent.BUTTON3)
// {
// view.doPrint();
// }
}
}

+ 3
- 12
src/ChatProgramm/view/ChatView.form View File



<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents> <SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Container class="ChatProgramm.view.GrafikView" name="gvZeichenflaeche">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/> <BorderConstraints direction="Center"/>
</Constraint> </Constraint>
</Constraints> </Constraints>


<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout> </Layout>
</Container> </Container>
</SubComponents> </SubComponents>

+ 100
- 95
src/ChatProgramm/view/ChatView.java View File

public class ChatView extends javax.swing.JFrame public class ChatView extends javax.swing.JFrame
{ {


/**
* @return the gvZeichenflaeche
*/
public ChatProgramm.view.GrafikView getGvZeichenflaeche()
{
return gvZeichenflaeche;
}

/** /**
* Creates new form ChatView * Creates new form ChatView
*/ */
* regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

dialogChooseMode = new javax.swing.JDialog();
lblMode = new javax.swing.JLabel();
BtnServer = new javax.swing.JRadioButton();
BtnClient = new javax.swing.JRadioButton();
jPanel1 = new javax.swing.JPanel();
BtnConnect = new javax.swing.JButton();
BtnGrpMode = new javax.swing.ButtonGroup();
jPanel2 = new javax.swing.JPanel();

dialogChooseMode.setMinimumSize(new java.awt.Dimension(278, 208));
dialogChooseMode.getContentPane().setLayout(new java.awt.GridLayout(0, 1));

lblMode.setText(" Choose your mode:");
dialogChooseMode.getContentPane().add(lblMode);

BtnGrpMode.add(BtnServer);
BtnServer.setText("Server");
BtnServer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BtnServerActionPerformed(evt);
}
});
dialogChooseMode.getContentPane().add(BtnServer);

BtnGrpMode.add(BtnClient);
BtnClient.setText("Client");
BtnClient.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BtnClientActionPerformed(evt);
}
});
dialogChooseMode.getContentPane().add(BtnClient);

BtnConnect.setText("Connect");
BtnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BtnConnectActionPerformed(evt);
}
});

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(65, Short.MAX_VALUE)
.addComponent(BtnConnect)
.addContainerGap(76, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(BtnConnect)
.addContainerGap(57, Short.MAX_VALUE))
);

dialogChooseMode.getContentPane().add(jPanel1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(568, 548));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);

getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

pack();
}// </editor-fold>//GEN-END:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{

dialogChooseMode = new javax.swing.JDialog();
lblMode = new javax.swing.JLabel();
BtnServer = new javax.swing.JRadioButton();
BtnClient = new javax.swing.JRadioButton();
jPanel1 = new javax.swing.JPanel();
BtnConnect = new javax.swing.JButton();
BtnGrpMode = new javax.swing.ButtonGroup();
gvZeichenflaeche = new ChatProgramm.view.GrafikView();

dialogChooseMode.setMinimumSize(new java.awt.Dimension(278, 208));
dialogChooseMode.getContentPane().setLayout(new java.awt.GridLayout(0, 1));

lblMode.setText(" Choose your mode:");
dialogChooseMode.getContentPane().add(lblMode);

BtnGrpMode.add(BtnServer);
BtnServer.setText("Server");
BtnServer.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
BtnServerActionPerformed(evt);
}
});
dialogChooseMode.getContentPane().add(BtnServer);

BtnGrpMode.add(BtnClient);
BtnClient.setText("Client");
BtnClient.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
BtnClientActionPerformed(evt);
}
});
dialogChooseMode.getContentPane().add(BtnClient);

BtnConnect.setText("Connect");
BtnConnect.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
BtnConnectActionPerformed(evt);
}
});

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(65, Short.MAX_VALUE)
.addComponent(BtnConnect)
.addContainerGap(76, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(BtnConnect)
.addContainerGap(57, Short.MAX_VALUE))
);

dialogChooseMode.getContentPane().add(jPanel1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(568, 548));
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowOpened(java.awt.event.WindowEvent evt)
{
formWindowOpened(evt);
}
});
getContentPane().add(gvZeichenflaeche, java.awt.BorderLayout.CENTER);

pack();
}// </editor-fold>//GEN-END:initComponents


private void BtnClientActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnClientActionPerformed private void BtnClientActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_BtnClientActionPerformed
{//GEN-HEADEREND:event_BtnClientActionPerformed {//GEN-HEADEREND:event_BtnClientActionPerformed
}); });
} }


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton BtnClient;
private javax.swing.JButton BtnConnect;
private javax.swing.ButtonGroup BtnGrpMode;
private javax.swing.JRadioButton BtnServer;
private javax.swing.JDialog dialogChooseMode;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel lblMode;
// End of variables declaration//GEN-END:variables
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton BtnClient;
private javax.swing.JButton BtnConnect;
private javax.swing.ButtonGroup BtnGrpMode;
private javax.swing.JRadioButton BtnServer;
private javax.swing.JDialog dialogChooseMode;
private ChatProgramm.view.GrafikView gvZeichenflaeche;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblMode;
// End of variables declaration//GEN-END:variables


/** /**
* @return the BtnClient * @return the BtnClient

+ 0
- 89
src/ChatProgramm/view/GrafikFrame.form View File

<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JFileChooser" name="FcFileChooser">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSize" 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,-100,0,0,2,28"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</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 class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JToolBar" name="jToolBar1">
<Properties>
<Property name="rollover" type="boolean" value="true"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="btnFileOpen">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/mvcgrafik/view/Open24.gif"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Open File"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnFileSave">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/mvcgrafik/view/Save24.gif"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Safe File"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnPrint">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/mvcgrafik/view/Print24.gif"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Print File"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="ChatProgramm.view.GrafikView" name="gvZeichenflaeche">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
</Container>
</SubComponents>
</Form>

+ 0
- 171
src/ChatProgramm/view/GrafikFrame.java View File

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package ChatProgramm.view;

/**
*
* @author le
*/
public class GrafikFrame extends javax.swing.JFrame
{

/**
* @return the gvZeichenflaeche
*/
public ChatProgramm.view.GrafikView getGvZeichenflaeche()
{
return gvZeichenflaeche;
}

/**
* @return the FcFileChooser
*/
public javax.swing.JFileChooser getFcFileChooser()
{
return FcFileChooser;
}

/**
* @return the btnFileOpen
*/
public javax.swing.JButton getBtnFileOpen()
{
return btnFileOpen;
}

/**
* @return the btnFileSave
*/
public javax.swing.JButton getBtnFileSave()
{
return btnFileSave;
}
/**
* @return the gZeichenflaeche
*/


/**
* Creates new form GrafikFrame
*/
public GrafikFrame()
{
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{

FcFileChooser = new javax.swing.JFileChooser();
jToolBar1 = new javax.swing.JToolBar();
btnFileOpen = new javax.swing.JButton();
btnFileSave = new javax.swing.JButton();
btnPrint = new javax.swing.JButton();
gvZeichenflaeche = new ChatProgramm.view.GrafikView();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jToolBar1.setRollover(true);

btnFileOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Open24.gif"))); // NOI18N
btnFileOpen.setToolTipText("Open File");
btnFileOpen.setFocusable(false);
btnFileOpen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFileOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(btnFileOpen);

btnFileSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Save24.gif"))); // NOI18N
btnFileSave.setToolTipText("Safe File");
btnFileSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnFileSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(btnFileSave);

btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mvcgrafik/view/Print24.gif"))); // NOI18N
btnPrint.setToolTipText("Print File");
btnPrint.setFocusable(false);
btnPrint.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnPrint.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(btnPrint);

getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START);
getContentPane().add(gvZeichenflaeche, java.awt.BorderLayout.CENTER);

setSize(new java.awt.Dimension(540, 412));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
*/
public static void main(String args[])
{
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try
{
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
{
if ("Nimbus".equals(info.getName()))
{
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
}
catch (ClassNotFoundException ex)
{
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (InstantiationException ex)
{
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (IllegalAccessException ex)
{
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (javax.swing.UnsupportedLookAndFeelException ex)
{
java.util.logging.Logger.getLogger(GrafikFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new GrafikFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JFileChooser FcFileChooser;
private javax.swing.JButton btnFileOpen;
private javax.swing.JButton btnFileSave;
private javax.swing.JButton btnPrint;
private ChatProgramm.view.GrafikView gvZeichenflaeche;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration//GEN-END:variables

/**
* @return the btnPrint
*/
public javax.swing.JButton getBtnPrint() {
return btnPrint;
}
}

Loading…
Cancel
Save