Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.jonalu.primes;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.event.ActionEvent;
- import java.beans.PropertyChangeListener;
- import javax.swing.Action;
- import javax.swing.JApplet;
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import javax.swing.JFileChooser;
- import javax.swing.JProgressBar;
- import javax.swing.JSpinner;
- import javax.swing.JTextArea;
- import javax.swing.UIManager;
- import javax.swing.UnsupportedLookAndFeelException;
- public class GUI extends JComponent {
- private JButton startButton;
- private JButton pauseButton;
- private JButton stopButton;
- private JSpinner threadCount;
- private JSpinner maxValue;
- private JFileChooser outputFileChooser;
- private JProgressBar progressViewer;
- private JTextArea log;
- private PrimeHandler ph;
- public GUI() {
- setLayout(null);
- setOpaque(true);
- /*try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
- e.printStackTrace();
- }*/
- {
- startButton = new JButton();
- startButton.setAction(new GUIActions(0));
- startButton.setOpaque(true);
- //startButton.setBackground(new Color(0,0,0,255));
- add(startButton);
- }
- {
- progressViewer = new JProgressBar();
- progressViewer.setMaximum(1);
- add(progressViewer);
- }
- updatePositions();
- }
- private void updatePositions() {
- if(ph == null) {
- progressViewer.setMaximum(1);
- progressViewer.setValue(0);
- } else {
- switch(ph.state) {
- case 0:
- progressViewer.setMaximum(1);
- progressViewer.setValue(0);
- break;
- case 1:
- case 2:
- long max = ph.maximum();
- long cur = ph.currentNumber();
- while(max > Integer.MAX_VALUE) {
- max /= 10;
- cur /= 10;
- }
- progressViewer.setMaximum((int) max);
- progressViewer.setValue((int) cur);
- }
- }
- progressViewer.setBounds(2, height()-16, width()-4, 14);
- progressViewer.setVisible(true);
- startButton.setBounds(10, 10, 100, 100);
- startButton.setText("Start");
- startButton.setVisible(true);
- }
- private void startCalc() {
- }
- public void paint(Graphics g) {
- setBackground(new Color(0,0,0,255));
- setForeground(new Color(0,0,0,255));
- //startButton.paint(g);
- updatePositions();
- super.paint(g);
- }
- protected void paintComponent(Graphics g){
- }
- private int width() {
- return 600;
- }
- private int height() {
- return 400;
- }
- private class GUIActions implements Action {
- private int id;
- public GUIActions(int id) {
- this.id = id;
- }
- public void actionPerformed(ActionEvent e) {}
- public void addPropertyChangeListener(PropertyChangeListener listener) {}
- public Object getValue(String key) { return null; }
- public boolean isEnabled() { return false; }
- public void putValue(String key, Object value) {}
- public void removePropertyChangeListener(PropertyChangeListener listener) {}
- public void setEnabled(boolean b) {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment