Conflicts: src/wuerfelthreads/Start.java src/wuerfelthreads/view/WuerfelView.form src/wuerfelthreads/view/WuerfelView.javamaster
/* | |||||
* 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 bandit; | |||||
import javax.swing.JOptionPane; | |||||
import javax.swing.UIManager; | |||||
import bandit.controller.BanditAdapter; | |||||
import bandit.controller.BanditController; | |||||
import bandit.model.WuerfelModel; | |||||
import bandit.view.WuerfelView; | |||||
/** | |||||
* | |||||
* @author hd, chris | |||||
*/ | |||||
public class Start | |||||
{ | |||||
public Start() | |||||
{ | |||||
WuerfelView view = new WuerfelView(); | |||||
WuerfelModel model = new WuerfelModel(); | |||||
BanditAdapter adapter = new BanditAdapter(view, model); | |||||
BanditController ctrlCommand = new BanditController(view, model); | |||||
ctrlCommand.registerEvents(); | |||||
ctrlCommand.registerCommands(); | |||||
adapter.einschreiben(); | |||||
view.setVisible(true); | |||||
} | |||||
public static void main(String[] args) | |||||
{ | |||||
try | |||||
{ | |||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
JOptionPane.showMessageDialog(null, e.toString()); | |||||
} | |||||
new Start(); | |||||
} | |||||
} |
/* | |||||
* 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 bandit.controller; | |||||
import java.util.concurrent.Flow; | |||||
import java.util.concurrent.Flow.Subscriber; | |||||
import java.util.logging.Logger; | |||||
import bandit.model.WuerfelModel; | |||||
import bandit.view.WuerfelView; | |||||
/** | |||||
* | |||||
* @author hd | |||||
*/ | |||||
public class BanditAdapter implements Subscriber<Integer> | |||||
{ | |||||
private WuerfelView view; | |||||
private WuerfelModel model; | |||||
private Flow.Subscription subscription; | |||||
private static Logger lg = Logger.getLogger("Wuerfelthreads"); | |||||
public BanditAdapter(WuerfelView view, WuerfelModel model) | |||||
{ | |||||
this.view = view; | |||||
this.model = model; | |||||
} | |||||
public void einschreiben() | |||||
{ | |||||
model.addWertSubscription(this); | |||||
} | |||||
@Override | |||||
public void onSubscribe(Flow.Subscription subscription) | |||||
{ | |||||
this.subscription = subscription; | |||||
subscription.request(1); | |||||
lg.info("onSubsribe"); | |||||
} | |||||
@Override | |||||
public void onNext(Integer item) | |||||
{ | |||||
view.getLbZahl().setText(String.valueOf(item)); | |||||
subscription.request(1); | |||||
lg.info("onNext"); | |||||
} | |||||
@Override | |||||
public void onError(Throwable throwable) | |||||
{ | |||||
} | |||||
@Override | |||||
public void onComplete() | |||||
{ | |||||
} | |||||
} |
/* | |||||
* 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 bandit.controller; | |||||
import java.awt.event.ActionEvent; | |||||
import java.awt.event.ActionListener; | |||||
import bandit.model.WuerfelModel; | |||||
import bandit.view.WuerfelView; | |||||
/** | |||||
* | |||||
* @author chris | |||||
*/ | |||||
public class BanditController implements ActionListener | |||||
{ | |||||
private WuerfelView view; | |||||
private WuerfelModel model; | |||||
public BanditController(WuerfelView view, WuerfelModel model) | |||||
{ | |||||
this.view = view; | |||||
this.model = model; | |||||
} | |||||
public void registerEvents() | |||||
{ | |||||
view.getBtnStart().addActionListener(this); | |||||
view.getBtnStop().addActionListener(this); | |||||
} | |||||
public void registerCommands() | |||||
{ | |||||
// CommandOpen cmdOpen = new CommandOpen(view, model); | |||||
// invoker.addCommand(view.getMnuOpen(), cmdOpen); | |||||
// invoker.addCommand(view.getBtnOpen(), cmdOpen); | |||||
// //usw. | |||||
// | |||||
// | |||||
// CommandSave cmdSave = new CommandSave(view, model); | |||||
// invoker.addCommand(view.getMnuSave(), cmdSave); | |||||
// invoker.addCommand(view.getBtnSave(), cmdSave); | |||||
} | |||||
@Override | |||||
public void actionPerformed(ActionEvent e) | |||||
{ | |||||
if (e.getSource() == view.getBtnStart()) | |||||
{ | |||||
model.start(); | |||||
} | |||||
else | |||||
{ | |||||
model.stop(); | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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 bandit.model; | |||||
import java.util.logging.Logger; | |||||
import java.util.concurrent.ExecutorService; | |||||
import java.util.concurrent.Executors; | |||||
import java.util.concurrent.Flow.Subscriber; | |||||
import java.util.concurrent.SubmissionPublisher; | |||||
/** | |||||
* | |||||
* @author chris | |||||
*/ | |||||
public class WuerfelModel implements Runnable | |||||
{ | |||||
private int wert; | |||||
private volatile boolean laufend; | |||||
private SubmissionPublisher<Integer> iPublisher; | |||||
private SubmissionPublisher<Boolean> bPublisher; | |||||
private ExecutorService eService; | |||||
private static Logger lg = Logger.getLogger("Wuerfelthreads"); | |||||
public WuerfelModel() | |||||
{ | |||||
wert = 1; | |||||
laufend = false; | |||||
iPublisher = new SubmissionPublisher<>(); | |||||
bPublisher = new SubmissionPublisher<>(); | |||||
eService = Executors.newSingleThreadExecutor(); | |||||
} | |||||
public void start() | |||||
{ | |||||
laufend = true; | |||||
eService.submit(this); | |||||
lg.info("start"); | |||||
} | |||||
public void stop() | |||||
{ | |||||
laufend = false; | |||||
lg.info("stop"); | |||||
} | |||||
public void addWertSubscription(Subscriber<Integer> subscriber) | |||||
{ | |||||
iPublisher.subscribe(subscriber); | |||||
} | |||||
public void addZustandSubscription(Subscriber<Boolean> subscriber) | |||||
{ | |||||
bPublisher.subscribe(subscriber); | |||||
} | |||||
@Override | |||||
public void run() | |||||
{ | |||||
//wert++; | |||||
//if(wert >= 7){ | |||||
// wert = 1; | |||||
//} | |||||
while (laufend) | |||||
{ | |||||
/* | |||||
try | |||||
{ | |||||
Thread.sleep(10); | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
System.err.println(e); | |||||
} | |||||
wert++; | |||||
if(wert >= 7){ | |||||
wert = 1; | |||||
} | |||||
iPublisher.submit(wert); | |||||
*/ | |||||
} | |||||
} | |||||
} | |||||
<?xml version="1.0" encoding="UTF-8" ?> | |||||
<Form version="1.5" 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> | |||||
<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="Last"/> | |||||
</Constraint> | |||||
</Constraints> | |||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> | |||||
<SubComponents> | |||||
<Component class="javax.swing.JButton" name="btnStart"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Start"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JButton" name="btnStop"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="Stop"/> | |||||
</Properties> | |||||
</Component> | |||||
</SubComponents> | |||||
</Container> | |||||
<Container class="javax.swing.JPanel" name="jPanel2"> | |||||
<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.DesignFlowLayout"/> | |||||
<SubComponents> | |||||
<Component class="javax.swing.JLabel" name="lbZahl1"> | |||||
<Properties> | |||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | |||||
<Font name="Tahoma" size="64" style="0"/> | |||||
</Property> | |||||
<Property name="horizontalAlignment" type="int" value="0"/> | |||||
<Property name="text" type="java.lang.String" value="0"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JLabel" name="lbZahl2"> | |||||
<Properties> | |||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | |||||
<Font name="Tahoma" size="64" style="0"/> | |||||
</Property> | |||||
<Property name="horizontalAlignment" type="int" value="0"/> | |||||
<Property name="text" type="java.lang.String" value="0"/> | |||||
</Properties> | |||||
</Component> | |||||
<Component class="javax.swing.JLabel" name="lbZahl3"> | |||||
<Properties> | |||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> | |||||
<Font name="Tahoma" size="64" style="0"/> | |||||
</Property> | |||||
<Property name="horizontalAlignment" type="int" value="0"/> | |||||
<Property name="text" type="java.lang.String" value="0"/> | |||||
</Properties> | |||||
</Component> | |||||
</SubComponents> | |||||
</Container> | |||||
</SubComponents> | |||||
</Form> |
/* | |||||
* 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 bandit.view; | |||||
/** | |||||
* | |||||
* @author chris | |||||
*/ | |||||
public class WuerfelView extends javax.swing.JFrame | |||||
{ | |||||
/** | |||||
* @return the btnStart | |||||
*/ | |||||
public javax.swing.JButton getBtnStart() | |||||
{ | |||||
return btnStart; | |||||
} | |||||
/** | |||||
* @return the btnStop | |||||
*/ | |||||
public javax.swing.JButton getBtnStop() | |||||
{ | |||||
return btnStop; | |||||
} | |||||
/** | |||||
* @return the lbZahl | |||||
*/ | |||||
public javax.swing.JLabel getLbZahl() | |||||
{ | |||||
return lbZahl; | |||||
} | |||||
/** | |||||
* @param lbZahl the lbZahl to set | |||||
*/ | |||||
public void setLbZahl(javax.swing.JLabel lbZahl) | |||||
{ | |||||
this.lbZahl = lbZahl; | |||||
} | |||||
/** | |||||
* Creates new form WuerfelView | |||||
*/ | |||||
public WuerfelView() | |||||
{ | |||||
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() | |||||
{ | |||||
jPanel1 = new javax.swing.JPanel(); | |||||
btnStart = new javax.swing.JButton(); | |||||
btnStop = new javax.swing.JButton(); | |||||
jPanel2 = new javax.swing.JPanel(); | |||||
lbZahl1 = new javax.swing.JLabel(); | |||||
lbZahl2 = new javax.swing.JLabel(); | |||||
lbZahl3 = new javax.swing.JLabel(); | |||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |||||
btnStart.setText("Start"); | |||||
jPanel1.add(btnStart); | |||||
btnStop.setText("Stop"); | |||||
jPanel1.add(btnStop); | |||||
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END); | |||||
lbZahl1.setFont(new java.awt.Font("Tahoma", 0, 64)); // NOI18N | |||||
lbZahl1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |||||
lbZahl1.setText("0"); | |||||
jPanel2.add(lbZahl1); | |||||
lbZahl2.setFont(new java.awt.Font("Tahoma", 0, 64)); // NOI18N | |||||
lbZahl2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |||||
lbZahl2.setText("0"); | |||||
jPanel2.add(lbZahl2); | |||||
lbZahl3.setFont(new java.awt.Font("Tahoma", 0, 64)); // NOI18N | |||||
lbZahl3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |||||
lbZahl3.setText("0"); | |||||
jPanel2.add(lbZahl3); | |||||
getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); | |||||
pack(); | |||||
}// </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(WuerfelView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} | |||||
catch (InstantiationException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(WuerfelView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} | |||||
catch (IllegalAccessException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(WuerfelView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} | |||||
catch (javax.swing.UnsupportedLookAndFeelException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(WuerfelView.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 WuerfelView().setVisible(true); | |||||
} | |||||
}); | |||||
} | |||||
// Variables declaration - do not modify//GEN-BEGIN:variables | |||||
private javax.swing.JButton btnStart; | |||||
private javax.swing.JButton btnStop; | |||||
private javax.swing.JPanel jPanel1; | |||||
private javax.swing.JPanel jPanel2; | |||||
private javax.swing.JLabel lbZahl1; | |||||
private javax.swing.JLabel lbZahl2; | |||||
private javax.swing.JLabel lbZahl3; | |||||
// End of variables declaration//GEN-END:variables | |||||
} |
/* | |||||
* 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 grafik; | |||||
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.awt.geom.Line2D; | |||||
import java.util.logging.Logger; | |||||
import javax.swing.JComponent; | |||||
/** | |||||
* | |||||
* @author le | |||||
*/ | |||||
public class Gerade extends JComponent implements Runnable | |||||
{ | |||||
private Line2D.Double line; | |||||
private BasicStroke pinsel; | |||||
private float angle; | |||||
private float radius; | |||||
private Thread thd; | |||||
private long sleepTime; | |||||
private static final float DICKE = 8f; | |||||
private static Logger lg = Logger.getLogger("grafik"); | |||||
public Gerade(long sleepTime) | |||||
{ | |||||
this.sleepTime = sleepTime; | |||||
line = new Line2D.Double(); | |||||
angle = 0; | |||||
radius = 100; | |||||
pinsel = new BasicStroke(DICKE); | |||||
thd = null; | |||||
} | |||||
public void start() | |||||
{ | |||||
if (thd == null) | |||||
{ | |||||
thd = new Thread(this); | |||||
thd.start(); | |||||
} | |||||
} | |||||
@Override | |||||
public void paintComponent(Graphics g) | |||||
{ | |||||
super.paintComponent(g); | |||||
Graphics2D g2 = (Graphics2D)g; | |||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |||||
RenderingHints.VALUE_ANTIALIAS_ON); | |||||
int breite = this.getWidth() - 1; | |||||
int hoehe = this.getHeight() - 1; | |||||
float x1 = breite/2f; | |||||
float y1 = hoehe/2f; | |||||
float x2 = (float) Math.sin(angle); | |||||
float y2 = 2; | |||||
line.setLine(x1, y1, x2, y2); | |||||
g2.setStroke(pinsel); | |||||
g2.setPaint(Color.RED); | |||||
g2.fill(line); | |||||
g2.setPaint(Color.BLACK); | |||||
g2.draw(line); | |||||
} | |||||
@Override | |||||
public void run() | |||||
{ | |||||
while (true) | |||||
{ | |||||
if(angle >= 360){ | |||||
angle = 0; | |||||
} else { | |||||
angle += 1; | |||||
} | |||||
// if (radius > maxRadius) delta = -1f; | |||||
// if (radius < minRadius) delta = +1f; | |||||
// radius += delta; | |||||
this.repaint(); | |||||
try | |||||
{ | |||||
Thread.sleep(sleepTime); | |||||
} | |||||
catch (InterruptedException iex) | |||||
{ | |||||
lg.warning(iex.toString()); | |||||
} | |||||
} | |||||
} | |||||
} |
/* | |||||
* 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 grafik; | |||||
import java.awt.Color; | |||||
import java.awt.Container; | |||||
import javax.swing.JFrame; | |||||
import javax.swing.JOptionPane; | |||||
import javax.swing.OverlayLayout; | |||||
import javax.swing.UIManager; | |||||
import javax.swing.WindowConstants; | |||||
/** | |||||
* Builder Class | |||||
* @author chris, hd | |||||
*/ | |||||
public class Start | |||||
{ | |||||
public Start() | |||||
{ | |||||
JFrame frm = new JFrame(); | |||||
Container con = frm.getContentPane(); | |||||
con.setLayout(new OverlayLayout(con)); | |||||
con.setBackground(Color.WHITE); | |||||
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |||||
// for (int i = 0; i < 100; i++) | |||||
// { | |||||
// double zufall = Math.random(); | |||||
// long schlafzeit = (long)(1 + 100*zufall); | |||||
// Kreis leinwand = new Kreis(schlafzeit); | |||||
// leinwand.setOpaque(false); | |||||
// con.add(leinwand); | |||||
// leinwand.start(); | |||||
// } | |||||
Gerade gerade = new Gerade(1); | |||||
con.add(gerade); | |||||
frm.setSize(600, 400); | |||||
frm.setVisible(true); | |||||
} | |||||
/** | |||||
* @param args the command line arguments | |||||
*/ | |||||
public static void main(String[] args) | |||||
{ | |||||
try | |||||
{ | |||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
JOptionPane.showMessageDialog(null, e.toString()); | |||||
} | |||||
new Start(); | |||||
} | |||||
} |
/* | |||||
* 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 grafik; | |||||
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.awt.geom.Line2D; | |||||
import javax.swing.JComponent; | |||||
/** | |||||
* | |||||
* @author chris, hd | |||||
*/ | |||||
public class Zeichenflaeche extends JComponent // JPanel | |||||
{ | |||||
private Line2D.Double line; | |||||
private BasicStroke pinsel; | |||||
private static final float DICKE = 30f; | |||||
public Zeichenflaeche() | |||||
{ | |||||
line = new Line2D.Double(); | |||||
pinsel = new BasicStroke(DICKE); | |||||
} | |||||
@Override | |||||
public void paintComponent(Graphics g) | |||||
{ | |||||
super.paintComponent(g); | |||||
Graphics2D g2 = (Graphics2D)g; | |||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |||||
RenderingHints.VALUE_ANTIALIAS_ON); | |||||
int breite = this.getWidth() - 1; | |||||
int hoehe = this.getHeight() - 1; | |||||
line.x1 = breite/2; | |||||
line.y1 = hoehe/2; | |||||
line.x2 = 30; | |||||
line.y2 = 50; | |||||
// line.setFrame(DICKE/2, DICKE/2, breite-DICKE, hoehe-DICKE); | |||||
g2.setStroke(pinsel); | |||||
g2.setPaint(Color.RED); | |||||
g2.fill(line); | |||||
g2.setPaint(Color.BLACK); | |||||
g2.draw(line); | |||||
} | |||||
} |
/* | |||||
* 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 grafik; | |||||
/** | |||||
* | |||||
* @author chris | |||||
*/ | |||||
public class grafik | |||||
{ | |||||
public grafik() | |||||
{ | |||||
} | |||||
} |