Browse Source

Merge origin/master

Conflicts:
	src/wuerfelthreads/Start.java
	src/wuerfelthreads/view/WuerfelView.form
	src/wuerfelthreads/view/WuerfelView.java
master
BakeOrDie 3 years ago
parent
commit
849e262fdc

+ 69
- 0
src/EierUhrKomponente/EierUhr.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.awt.Graphics;
import java.net.Socket;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import ohmlogger.OhmLogger;

/**
* Builder Class
* @author le
*/
public class EierUhr extends JComponent
{
private static Logger lg = OhmLogger.getLogger();
private EierUhrView view;
private EierUhrModel model;
private EierUhrController ctrl;
private CopyOnWriteArrayList<EierUhrListener> listenerListe;
public EierUhr()
{
this.view = new EierUhrView(this);
this.model = new EierUhrModel();
this.ctrl = new EierUhrController(view, model, this);
this.listenerListe = new CopyOnWriteArrayList<EierUhrListener>();

}
public void paintComponent(Graphics g)
{
view.paintComponent(g);
}
public void Start(int zahl)
{
ctrl.start(zahl);
}
public int getZahl()
{
return ctrl.getZahl();
}
public void fireEierUhrEvent(EierUhrEvent evt)
{
listenerListe.forEach(listener -> listener.timeIsOver(evt));
}
public synchronized void addEierUhrListener(EierUhrListener listener)
{
listenerListe.add(listener);
}
public synchronized void removeEierUhrListener(EierUhrListener listener)
{
listenerListe.remove(listener);
}
}

+ 297
- 0
src/EierUhrKomponente/EierUhrBeanInfo.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package EierUhrKomponente;

import java.beans.*;

/**
*
* @author chris
*/
public class EierUhrBeanInfo extends SimpleBeanInfo
{

// Bean descriptor//GEN-FIRST:BeanDescriptor
/*lazy BeanDescriptor*/
private static BeanDescriptor getBdescriptor(){
BeanDescriptor beanDescriptor = new BeanDescriptor ( EierUhrKomponente.EierUhr.class , null ); // NOI18N//GEN-HEADEREND:BeanDescriptor
// Here you can add code for customizing the BeanDescriptor.

return beanDescriptor; }//GEN-LAST:BeanDescriptor


// Property identifiers//GEN-FIRST:Properties
private static final int PROPERTY_zahl = 0;

// Property array
/*lazy PropertyDescriptor*/
private static PropertyDescriptor[] getPdescriptor(){
PropertyDescriptor[] properties = new PropertyDescriptor[1];
try {
properties[PROPERTY_zahl] = new PropertyDescriptor ( "zahl", EierUhrKomponente.EierUhr.class, "getZahl", null ); // NOI18N
}
catch(IntrospectionException e) {
e.printStackTrace();
}//GEN-HEADEREND:Properties
// Here you can add code for customizing the properties array.

return properties; }//GEN-LAST:Properties

// EventSet identifiers//GEN-FIRST:Events
private static final int EVENT_eierUhrListener = 0;
private static final int EVENT_propertyChangeListener = 1;
private static final int EVENT_vetoableChangeListener = 2;

// EventSet array
/*lazy EventSetDescriptor*/
private static EventSetDescriptor[] getEdescriptor(){
EventSetDescriptor[] eventSets = new EventSetDescriptor[3];
try {
eventSets[EVENT_eierUhrListener] = new EventSetDescriptor ( EierUhrKomponente.EierUhr.class, "eierUhrListener", EierUhrKomponente.EierUhrListener.class, new String[] {"timeIsOver"}, "addEierUhrListener", "removeEierUhrListener" ); // NOI18N
eventSets[EVENT_propertyChangeListener] = new EventSetDescriptor ( EierUhrKomponente.EierUhr.class, "propertyChangeListener", java.beans.PropertyChangeListener.class, new String[] {"propertyChange"}, "addPropertyChangeListener", "removePropertyChangeListener" ); // NOI18N
eventSets[EVENT_vetoableChangeListener] = new EventSetDescriptor ( EierUhrKomponente.EierUhr.class, "vetoableChangeListener", java.beans.VetoableChangeListener.class, new String[] {"vetoableChange"}, "addVetoableChangeListener", "removeVetoableChangeListener" ); // NOI18N
}
catch(IntrospectionException e) {
e.printStackTrace();
}//GEN-HEADEREND:Events
// Here you can add code for customizing the event sets array.

return eventSets; }//GEN-LAST:Events

// Method identifiers//GEN-FIRST:Methods
private static final int METHOD_fireEierUhrEvent0 = 0;
private static final int METHOD_firePropertyChange1 = 1;
private static final int METHOD_firePropertyChange2 = 2;
private static final int METHOD_firePropertyChange3 = 3;
private static final int METHOD_firePropertyChange4 = 4;
private static final int METHOD_firePropertyChange5 = 5;
private static final int METHOD_firePropertyChange6 = 6;
private static final int METHOD_firePropertyChange7 = 7;
private static final int METHOD_firePropertyChange8 = 8;
private static final int METHOD_Start9 = 9;

// Method array
/*lazy MethodDescriptor*/
private static MethodDescriptor[] getMdescriptor(){
MethodDescriptor[] methods = new MethodDescriptor[10];
try {
methods[METHOD_fireEierUhrEvent0] = new MethodDescriptor(EierUhrKomponente.EierUhr.class.getMethod("fireEierUhrEvent", new Class[] {EierUhrKomponente.EierUhrEvent.class})); // NOI18N
methods[METHOD_fireEierUhrEvent0].setDisplayName ( "" );
methods[METHOD_firePropertyChange1] = new MethodDescriptor(java.awt.Component.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, byte.class, byte.class})); // NOI18N
methods[METHOD_firePropertyChange1].setDisplayName ( "" );
methods[METHOD_firePropertyChange2] = new MethodDescriptor(java.awt.Component.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, short.class, short.class})); // NOI18N
methods[METHOD_firePropertyChange2].setDisplayName ( "" );
methods[METHOD_firePropertyChange3] = new MethodDescriptor(java.awt.Component.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, long.class, long.class})); // NOI18N
methods[METHOD_firePropertyChange3].setDisplayName ( "" );
methods[METHOD_firePropertyChange4] = new MethodDescriptor(java.awt.Component.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, float.class, float.class})); // NOI18N
methods[METHOD_firePropertyChange4].setDisplayName ( "" );
methods[METHOD_firePropertyChange5] = new MethodDescriptor(java.awt.Component.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, double.class, double.class})); // NOI18N
methods[METHOD_firePropertyChange5].setDisplayName ( "" );
methods[METHOD_firePropertyChange6] = new MethodDescriptor(javax.swing.JComponent.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, boolean.class, boolean.class})); // NOI18N
methods[METHOD_firePropertyChange6].setDisplayName ( "" );
methods[METHOD_firePropertyChange7] = new MethodDescriptor(javax.swing.JComponent.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, int.class, int.class})); // NOI18N
methods[METHOD_firePropertyChange7].setDisplayName ( "" );
methods[METHOD_firePropertyChange8] = new MethodDescriptor(javax.swing.JComponent.class.getMethod("firePropertyChange", new Class[] {java.lang.String.class, char.class, char.class})); // NOI18N
methods[METHOD_firePropertyChange8].setDisplayName ( "" );
methods[METHOD_Start9] = new MethodDescriptor(EierUhrKomponente.EierUhr.class.getMethod("Start", new Class[] {int.class})); // NOI18N
methods[METHOD_Start9].setDisplayName ( "" );
}
catch( Exception e) {}//GEN-HEADEREND:Methods
// Here you can add code for customizing the methods array.

return methods; }//GEN-LAST:Methods

private static java.awt.Image iconColor16 = null;//GEN-BEGIN:IconsDef
private static java.awt.Image iconColor32 = null;
private static java.awt.Image iconMono16 = null;
private static java.awt.Image iconMono32 = null;//GEN-END:IconsDef
private static String iconNameC16 = null;//GEN-BEGIN:Icons
private static String iconNameC32 = null;
private static String iconNameM16 = null;
private static String iconNameM32 = null;//GEN-END:Icons

private static final int defaultPropertyIndex = -1;//GEN-BEGIN:Idx
private static final int defaultEventIndex = -1;//GEN-END:Idx


//GEN-FIRST:Superclass
// Here you can add code for customizing the Superclass BeanInfo.

//GEN-LAST:Superclass
/**
* Gets the bean's <code>BeanDescriptor</code>s.
*
* @return BeanDescriptor describing the editable properties of this bean. May
* return null if the information should be obtained by automatic analysis.
*/
@Override
public BeanDescriptor getBeanDescriptor()
{
return getBdescriptor();
}

/**
* Gets the bean's <code>PropertyDescriptor</code>s.
*
* @return An array of PropertyDescriptors describing the editable properties
* supported by this bean. May return null if the information should be
* obtained by automatic analysis.
* <p>
* If a property is indexed, then its entry in the result array will belong to
* the IndexedPropertyDescriptor subclass of PropertyDescriptor. A client of
* getPropertyDescriptors can use "instanceof" to check if a given
* PropertyDescriptor is an IndexedPropertyDescriptor.
*/
@Override
public PropertyDescriptor[] getPropertyDescriptors()
{
return getPdescriptor();
}

/**
* Gets the bean's <code>EventSetDescriptor</code>s.
*
* @return An array of EventSetDescriptors describing the kinds of events
* fired by this bean. May return null if the information should be obtained
* by automatic analysis.
*/
@Override
public EventSetDescriptor[] getEventSetDescriptors()
{
return getEdescriptor();
}

/**
* Gets the bean's <code>MethodDescriptor</code>s.
*
* @return An array of MethodDescriptors describing the methods implemented by
* this bean. May return null if the information should be obtained by
* automatic analysis.
*/
@Override
public MethodDescriptor[] getMethodDescriptors()
{
return getMdescriptor();
}

/**
* A bean may have a "default" property that is the property that will mostly
* commonly be initially chosen for update by human's who are customizing the
* bean.
*
* @return Index of default property in the PropertyDescriptor array returned
* by getPropertyDescriptors.
* <P>
* Returns -1 if there is no default property.
*/
@Override
public int getDefaultPropertyIndex()
{
return defaultPropertyIndex;
}

/**
* A bean may have a "default" event that is the event that will mostly
* commonly be used by human's when using the bean.
*
* @return Index of default event in the EventSetDescriptor array returned by
* getEventSetDescriptors.
* <P>
* Returns -1 if there is no default event.
*/
@Override
public int getDefaultEventIndex()
{
return defaultEventIndex;
}

/**
* This method returns an image object that can be used to represent the bean
* in toolboxes, toolbars, etc. Icon images will typically be GIFs, but may in
* future include other formats.
* <p>
* Beans aren't required to provide icons and may return null from this
* method.
* <p>
* There are four possible flavors of icons (16x16 color, 32x32 color, 16x16
* mono, 32x32 mono). If a bean choses to only support a single icon we
* recommend supporting 16x16 color.
* <p>
* We recommend that icons have a "transparent" background so they can be
* rendered onto an existing background.
*
* @param iconKind The kind of icon requested. This should be one of the
* constant values ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, or
* ICON_MONO_32x32.
* @return An image object representing the requested icon. May return null if
* no suitable icon is available.
*/
@Override
public java.awt.Image getIcon(int iconKind)
{
switch (iconKind)
{
case ICON_COLOR_16x16:
if (iconNameC16 == null)
{
return null;
}
else
{
if (iconColor16 == null)
{
iconColor16 = loadImage(iconNameC16);
}
return iconColor16;
}
case ICON_COLOR_32x32:
if (iconNameC32 == null)
{
return null;
}
else
{
if (iconColor32 == null)
{
iconColor32 = loadImage(iconNameC32);
}
return iconColor32;
}
case ICON_MONO_16x16:
if (iconNameM16 == null)
{
return null;
}
else
{
if (iconMono16 == null)
{
iconMono16 = loadImage(iconNameM16);
}
return iconMono16;
}
case ICON_MONO_32x32:
if (iconNameM32 == null)
{
return null;
}
else
{
if (iconMono32 == null)
{
iconMono32 = loadImage(iconNameM32);
}
return iconMono32;
}
default:
return null;
}
}
}

+ 85
- 0
src/EierUhrKomponente/EierUhrController.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Flow;
import java.util.concurrent.Flow.Subscriber;
import java.util.logging.Logger;
import ohmlogger.OhmLogger;

/**
*
* @author chris
*/
public class EierUhrController implements Flow.Subscriber<Integer>
{
private EierUhrView view;
private EierUhrModel model;
private EierUhr eierUhr;
private Flow.Subscription sub;
private static Logger lg = OhmLogger.getLogger();
public EierUhrController(EierUhrView view, EierUhrModel model, EierUhr eierUhr)
{
this.view = view;
this.model = model;
this.eierUhr = eierUhr;
addSubscription();
}
public void setZahl(int zahl)
{
view.setZahl(zahl);
}
public int getZahl()
{
return view.getZahl();
}

public void start(int zahl)
{
lg.info("Controller Start");
model.initZahl(zahl);
}

private void addSubscription()
{
model.addSubscription(this);
}

@Override
public void onSubscribe(Flow.Subscription subscription)
{
this.sub = subscription;
sub.request(1);
}

@Override
public void onNext(Integer item)
{
int zahl = view.getZahl();
sub.request(1);
view.setZahl(item);
eierUhr.firePropertyChange("zahl", zahl, view.getZahl());
if(item == 0)
{
eierUhr.fireEierUhrEvent(new EierUhrEvent(this));
}
}

@Override
public void onError(Throwable thrwbl)
{
}

@Override
public void onComplete()
{
}
}

+ 25
- 0
src/EierUhrKomponente/EierUhrEvent.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.util.EventObject;
import java.util.logging.Logger;
import ohmlogger.OhmLogger;

/**
*
* @author chris
*/
public class EierUhrEvent extends EventObject
{
private static Logger lg = OhmLogger.getLogger();
public EierUhrEvent(Object source)
{
super(source);
lg.info("event");
}
}

+ 19
- 0
src/EierUhrKomponente/EierUhrListener.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.util.EventListener;

/**
*
* @author chris
*/
public interface EierUhrListener extends EventListener
{
public void timeIsOver(EierUhrEvent evt);
}

+ 92
- 0
src/EierUhrKomponente/EierUhrModel.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;
import java.util.logging.Level;
import java.util.logging.Logger;
import ohmlogger.OhmLogger;

/**
*
* @author chris
*/
public class EierUhrModel implements Runnable
{
private int zahl;
private ExecutorService exe;
private boolean laufend;
private static Logger lg = OhmLogger.getLogger();
private SubmissionPublisher<Integer> ipublisher;
public EierUhrModel()
{
zahl = 100;
exe = Executors.newSingleThreadExecutor();
ipublisher = new SubmissionPublisher<>();
}

void start()
{
exe.submit(this);
laufend = true;
lg.info("Start Model");
}
public void initZahl(int zahl)
{
this.zahl = zahl;
lg.info("Reset Zahl to: " + Integer.toString(zahl));
start();
}

@Override
public void run()
{
while(laufend)
{
lg.info(Integer.toString(zahl));
if(zahl > 0)
{
try
{
Thread.sleep(1000);
zahl -= 1;
ipublisher.submit(zahl);
}
catch (InterruptedException ex)
{
lg.info("error: ");
Logger.getLogger(EierUhrModel.class.getName()).log(Level.SEVERE, null, ex);
}
}
else
{
lg.info("0 erreicht");
stop();
}
}
}
public void addSubscription(Flow.Subscriber<Integer> subscriber)
{
ipublisher.subscribe(subscriber);
}
public void stop()
{
laufend = false;
}

}

+ 83
- 0
src/EierUhrKomponente/EierUhrView.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package EierUhrKomponente;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Ellipse2D;
import java.util.logging.Logger;
import javax.swing.JComponent;
import ohmlogger.OhmLogger;

/**
*
* @author chris
*/
public class EierUhrView extends JComponent
{
private static Logger lg = OhmLogger.getLogger();
private int zahl;
private Ellipse2D.Float rand;
private int DICKE;
private BasicStroke pinsel;
private EierUhr eierUhr;
public EierUhrView(EierUhr eierUhr)
{
zahl = 99;
rand = new Ellipse2D.Float();
DICKE = 4;
pinsel = new BasicStroke(DICKE);
this.eierUhr = eierUhr;
}
@Override
public void paintComponent(Graphics g)
{
super.paintComponents(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int breite = eierUhr.getWidth() -1;
int hoehe = eierUhr.getHeight() -1;
int radius = -DICKE/2 + Math.min(breite, hoehe) / 2;
float x = breite/2 - radius;
float y = hoehe/2 - radius;
rand.setFrame(x, y, 1.5*radius, 2*radius);
g2.setStroke(pinsel);
// g2.setPaint(eierUhr.getParent().getBackground());
// g2.fill(rand);
float font = (g2.getFont().getSize()*DICKE);
g2.setPaint(Color.BLACK);
g2.setFont(g2.getFont().deriveFont(font));
g2.drawString(Integer.toString(zahl), (float) (x+radius*0.75-font/2), y+radius+font/2);
g2.draw(rand);
lg.info("paint" + Integer.toString(zahl));
}
public int getZahl()
{
return this.zahl;
}
public void setZahl(int zahl)
{
this.zahl = zahl;
eierUhr.repaint();
}
}

+ 0
- 70
src/graphicChat/Start.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package graphicChat;

import javax.swing.JFrame;
import javax.swing.WindowConstants;
import graphicChat.controller.CommandConnect;
import graphicChat.controller.CommandSend;
import graphicChat.controller.GraphicsController;
import graphicChat.controller.ReceiveAdapter;
import graphicChat.view.ChatView;
import graphicChat.model.ChatModel;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
/**
* Builder Class
* @author le
*/
public class Start
{
public Start()
{
JFrame frm = new JFrame();
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

ChatView view = new ChatView();
ChatModel model = new ChatModel();
view.getGrafikView1().setModel(model);
GraphicsController controller = new GraphicsController(view.getGrafikView1(), model);
controller.registerEvents();
CommandConnect cmdConnect = new CommandConnect(view, model);
cmdConnect.registerEvents();
CommandSend cmdSend = new CommandSend(view, model);
cmdSend.registerEvents();
ReceiveAdapter recAdapter = new ReceiveAdapter(view, model);
recAdapter.subscribe();
view.setVisible(true);
view.setTitle("Chat");

view.setSize(800, 600);
view.setVisible(true);

}

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null, ex.toString());
}
new Start();
new Start();
}
}

+ 51
- 0
src/test/Start.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package test;

import EierUhrKomponente.EierUhr;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

/**
*
* @author chris
*/
public class Start
{
public Start()
{
JFrame frm = new JFrame();
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

View view = new View();
// Model model = new Model();
// Controller ctrl = new Controller(view, model);

view.setTitle("Test");
view.setSize(800, 600);
view.setVisible(true);

}

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null, ex.toString());
}
new Start();
}
}

+ 82
- 0
src/test/View.form View File

<?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"/>
</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"/>
<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.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Ich bin nicht abgelaufen"/>
</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>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<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.DesignBoxLayout"/>
<SubComponents>
<Container class="EierUhrKomponente.EierUhr" name="eierUhr1">
<Events>
<EventHandler event="timeIsOver" listener="EierUhrKomponente.EierUhrListener" parameters="EierUhrKomponente.EierUhrEvent" handler="eierUhr1TimeIsOver"/>
<EventHandler event="propertyChange" listener="java.beans.PropertyChangeListener" parameters="java.beans.PropertyChangeEvent" handler="eierUhr1PropertyChange,eierUhr1PropertyChange1"/>
</Events>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MousePressed"/>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MouseReleased"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JProgressBar" name="jProgressBar1">
<Properties>
<Property name="maximum" type="int" value="3"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Form>

+ 166
- 0
src/test/View.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;

/**
*
* @author chris
*/
public class View extends javax.swing.JFrame
{

/**
* Creates new form View
*/
public View()
{
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()
{

jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
eierUhr1 = new EierUhrKomponente.EierUhr();
jButton1 = new javax.swing.JButton();
jProgressBar1 = new javax.swing.JProgressBar();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setText("Ich bin nicht abgelaufen");
getContentPane().add(jLabel1, java.awt.BorderLayout.PAGE_START);

jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS));

eierUhr1.addEierUhrListener(new EierUhrKomponente.EierUhrListener()
{
public void timeIsOver(EierUhrKomponente.EierUhrEvent evt)
{
eierUhr1TimeIsOver(evt);
}
});
eierUhr1.addPropertyChangeListener(new java.beans.PropertyChangeListener()
{
public void propertyChange(java.beans.PropertyChangeEvent evt)
{
eierUhr1PropertyChange(evt);
eierUhr1PropertyChange1(evt);
}
});
jPanel1.add(eierUhr1);

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

jButton1.setText("Start");
jButton1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mousePressed(java.awt.event.MouseEvent evt)
{
jButton1MousePressed(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt)
{
jButton1MouseReleased(evt);
}
});
getContentPane().add(jButton1, java.awt.BorderLayout.LINE_END);

jProgressBar1.setMaximum(3);
getContentPane().add(jProgressBar1, java.awt.BorderLayout.PAGE_END);

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

private void jButton1MouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MouseReleased
{//GEN-HEADEREND:event_jButton1MouseReleased

}//GEN-LAST:event_jButton1MouseReleased

private void jButton1MousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_jButton1MousePressed
{//GEN-HEADEREND:event_jButton1MousePressed
eierUhr1.Start(3);
}//GEN-LAST:event_jButton1MousePressed

private void eierUhr1PropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_eierUhr1PropertyChange
{//GEN-HEADEREND:event_eierUhr1PropertyChange

}//GEN-LAST:event_eierUhr1PropertyChange

private void eierUhr1TimeIsOver(EierUhrKomponente.EierUhrEvent evt)//GEN-FIRST:event_eierUhr1TimeIsOver
{//GEN-HEADEREND:event_eierUhr1TimeIsOver
jLabel1.setText("Zeit ist abgelaufen");
}//GEN-LAST:event_eierUhr1TimeIsOver

private void eierUhr1PropertyChange1(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_eierUhr1PropertyChange1
{//GEN-HEADEREND:event_eierUhr1PropertyChange1
jProgressBar1.setValue(eierUhr1.getZahl());
}//GEN-LAST:event_eierUhr1PropertyChange1

/**
* @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(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (InstantiationException ex)
{
java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (IllegalAccessException ex)
{
java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (javax.swing.UnsupportedLookAndFeelException ex)
{
java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

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

// Variables declaration - do not modify//GEN-BEGIN:variables
private EierUhrKomponente.EierUhr eierUhr1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JProgressBar jProgressBar1;
// End of variables declaration//GEN-END:variables
}

Loading…
Cancel
Save