src/main/java/de/uapcore/sudoku/ButtonPanel.java

changeset 9
576e7a2861ae
parent 3
ed931970b4ac
child 10
369903afbb29
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/main/java/de/uapcore/sudoku/ButtonPanel.java	Sat Jul 25 14:01:28 2020 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +/*
     1.5 + * Copyright 2013 Mike Becker. All rights reserved.
     1.6 + * 
     1.7 + * Redistribution and use in source and binary forms, with or without
     1.8 + * modification, are permitted provided that the following conditions are met:
     1.9 + * 
    1.10 + * 1. Redistributions of source code must retain the above copyright
    1.11 + *    notice, this list of conditions and the following disclaimer.
    1.12 + * 
    1.13 + * 2. Redistributions in binary form must reproduce the above copyright
    1.14 + *    notice, this list of conditions and the following disclaimer in the
    1.15 + *    documentation and/or other materials provided with the distribution.
    1.16 + * 
    1.17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.18 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.20 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    1.21 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.22 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.23 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.24 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.25 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.26 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.27 + * POSSIBILITY OF SUCH DAMAGE.
    1.28 + */
    1.29 +
    1.30 +package de.uapcore.sudoku;
    1.31 +
    1.32 +import javax.swing.*;
    1.33 +import java.awt.*;
    1.34 +
    1.35 +/**
    1.36 + *
    1.37 + * @author mike
    1.38 + */
    1.39 +public final class ButtonPanel extends JPanel {
    1.40 +    
    1.41 +    private JButton save, check, solve;
    1.42 +
    1.43 +    public ButtonPanel(ActionHandler l) {
    1.44 +        setLayout(new GridBagLayout());
    1.45 +        
    1.46 +        GridBagConstraints c = new GridBagConstraints();
    1.47 +        c.insets = new Insets(10, 10, 10, 10);
    1.48 +        c.fill = GridBagConstraints.HORIZONTAL;
    1.49 +        c.weightx = 1;
    1.50 +        
    1.51 +        c.gridx = 0;
    1.52 +        c.gridy = 0;
    1.53 +        save = new JButton("Speichern");
    1.54 +        add(save, c);
    1.55 +        c.gridx++;
    1.56 +        check = new JButton("Prüfen");
    1.57 +        add(check, c);
    1.58 +        solve = new JButton("Lösen");
    1.59 +        c.gridx++;
    1.60 +        add(solve, c);
    1.61 +        
    1.62 +        save.setActionCommand(ActionHandler.SAVE);
    1.63 +        save.addActionListener(l);
    1.64 +        check.setActionCommand(ActionHandler.CHECK);
    1.65 +        check.addActionListener(l);
    1.66 +        solve.setActionCommand(ActionHandler.SOLVE);
    1.67 +        solve.addActionListener(l);
    1.68 +        
    1.69 +        setBackground(Color.WHITE);
    1.70 +    }
    1.71 +}

mercurial