Subtrees hinzugefügt
This commit is contained in:
parent
e913ca6350
commit
7cf55ce953
53 changed files with 3807 additions and 0 deletions
53
Quellcodes/iud_key_rsachat/PicPanel.java
Normal file
53
Quellcodes/iud_key_rsachat/PicPanel.java
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
|
||||
//pic erbt von Panel - spart eine Klasse
|
||||
public class PicPanel extends JPanel {
|
||||
|
||||
ArrayList<Key> keys;
|
||||
|
||||
|
||||
public PicPanel(ArrayList<Key> keys){
|
||||
|
||||
this.keys = keys;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void drawCenteredString(String s, int xx, int yy, Graphics g) {
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
int x = xx- fm.stringWidth(s) / 2;
|
||||
g.drawString(s, x, yy);
|
||||
}
|
||||
|
||||
//paintComponent überschreiben, Image zeichnen, super-Aufruf nicht vergessen
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
for (int x = 0; x < keys.size(); x++) {
|
||||
g.drawImage(keys.get(x).getImage(),x*32,2,this);
|
||||
drawCenteredString(keys.get(x).getName(),x*32+16,50,g);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getToolTipText(MouseEvent evt) {
|
||||
int k = evt.getX() /32;
|
||||
if (keys.size()>k) {
|
||||
return "<html><p width=400><b>Exponent:</b><br>"+keys.get(k).getE()+"</p><p width=400><b>Modul:</b><br>"+keys.get(k).getN()+"</p></html>";
|
||||
} // end of if
|
||||
return "Schlüsselspeicher";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue