Created
April 23, 2013 18:30
-
-
Save moomoohk/5446132 to your computer and use it in GitHub Desktop.
Control panel for D-Shizzwitt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dylan; | |
import java.awt.Color; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JTextField; | |
public class ControlPanel | |
{ | |
private JFrame f2=new JFrame("Control panel"); | |
private JTextField input=new JTextField(); | |
private JLabel inputLabel=new JLabel("Path:"); | |
private JButton doneInput=new JButton("Done"); | |
private JButton label=new JButton("Label image"); | |
private JButton blackAndWhite=new JButton("Black and white"); | |
public ControlPanel() | |
{ | |
initFrame(); | |
setBounds(); | |
addElements(); | |
addActionListeners(); | |
f2.setVisible(true); | |
} | |
private void initFrame() | |
{ | |
f2.setLayout(null); | |
f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
f2.setSize(200, 220); | |
f2.setResizable(false); | |
f2.setLocationRelativeTo(null); | |
f2.getContentPane().setBackground(Color.gray); | |
} | |
private void setBounds() | |
{ | |
input.setBounds(10, 30, 180, 30); | |
inputLabel.setBounds(10, 10, 180, 30); | |
doneInput.setBounds(10, 60, 180, 30); | |
blackAndWhite.setBounds(10, 120, 180, 30); | |
label.setBounds(10, 150, 180, 30); | |
} | |
private void addElements() | |
{ | |
f2.add(input); | |
f2.add(inputLabel); | |
f2.add(doneInput); | |
f2.add(blackAndWhite); | |
f2.add(label); | |
} | |
private void addActionListeners() | |
{ | |
doneInput.addActionListener(new ActionListener() | |
{ | |
@Override | |
public void actionPerformed(ActionEvent arg0) | |
{ | |
System.out.println("done"); | |
} | |
}); | |
label.addActionListener(new ActionListener() | |
{ | |
@Override | |
public void actionPerformed(ActionEvent arg0) | |
{ | |
System.out.println("label"); | |
} | |
}); | |
blackAndWhite.addActionListener(new ActionListener() | |
{ | |
@Override | |
public void actionPerformed(ActionEvent arg0) | |
{ | |
System.out.println("black and white"); | |
} | |
}); | |
} | |
public static void main(String[] args) | |
{ | |
new ControlPanel(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment