Advertisement
mrkarp

Untitled

Oct 24th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. package FLMain;
  2. /*
  3. *Author: Zach Karp
  4. *Date:
  5. */
  6.  
  7. import java.awt.BorderLayout;
  8. import java.awt.Color;
  9. import java.awt.FlowLayout;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.io.File;
  13. import java.io.IOException;
  14.  
  15. import javax.imageio.ImageIO;
  16. import javax.swing.ButtonGroup;
  17. import javax.swing.ImageIcon;
  18. import javax.swing.JButton;
  19. import javax.swing.JFrame;
  20. import javax.swing.JLabel;
  21. import javax.swing.JPanel;
  22. import javax.swing.JRadioButton;
  23. import javax.swing.RootPaneContainer;
  24.  
  25. @SuppressWarnings("serial")
  26. public class FLInstall extends JFrame {
  27.  
  28. // Panels
  29. private JPanel panel;
  30. private JPanel panel2;
  31.  
  32. // Buttons
  33. private JButton installButton;
  34. private JButton directoryButton;
  35.  
  36. //private JLabel messageLabel;
  37.  
  38. // Window parameters
  39. private final int WINDOW_WIDTH = 512; // Window Width
  40. private final int WINDOW_HEIGHT = 288; // Window Height
  41.  
  42. public FLInstall() {
  43. // Set the title bar text
  44. setTitle("FreeLancer Install");
  45.  
  46. // Set the size of the window
  47. setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
  48.  
  49. // Close window when the exit button is clicked
  50. setDefualtCloseOperation(JFrame.EXIT_ON_CLOSE);
  51.  
  52. setLayout(new BorderLayout());
  53. try {
  54. rootPane.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("logo.png")))));
  55. } catch (IOException e) {
  56. // TODO Auto-generated catch block
  57. e.printStackTrace();
  58. }
  59. //add(background);
  60. setLayout(new FlowLayout());
  61.  
  62. panel2 = new JPanel();
  63.  
  64. // Set panels background colors
  65. panel2.setBackground(Color.WHITE);
  66.  
  67. // Adding the panels to the App
  68. add(panel2, BorderLayout.NORTH);
  69.  
  70. // Create the buttons.
  71. installButton = new JButton("Install");
  72. directoryButton = new JButton("Choose Directory");
  73.  
  74. // Declaring that panel2 has the buttons
  75. panel2.add(installButton);
  76. panel2.add(directoryButton);
  77.  
  78. // Adding the action listeners to the buttons
  79. installButton.addActionListener(new InstallButtonListener());
  80. directoryButton.addActionListener(new DirectoryButtonListener());
  81.  
  82. // Add the buttons color.
  83. installButton.setBackground(Color.RED);
  84. directoryButton.setBackground(Color.ORANGE);
  85.  
  86. // Display the window
  87. setVisible(true);
  88.  
  89. }
  90.  
  91. // Color Button Listener Actions
  92. private class InstallButtonListener implements ActionListener {
  93.  
  94. public void actionPerformed(ActionEvent e) {
  95. panel.setBackground(Color.RED);
  96.  
  97. }
  98.  
  99. }
  100.  
  101. // Color Button Listener Actions
  102. private class DirectoryButtonListener implements ActionListener {
  103.  
  104. public void actionPerformed(ActionEvent e) {
  105. panel.setBackground(Color.ORANGE);
  106.  
  107. }
  108.  
  109. }
  110.  
  111.  
  112. // Generated default close operation
  113. private void setDefualtCloseOperation(int exitOnClose) {
  114. }
  115.  
  116. // Generated clearSelection
  117. public Object clearSelection() {
  118. return null;
  119. }
  120.  
  121. // Run that thang!
  122. public static void main(String[] args) {
  123. new FLInstall();
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement