Advertisement
xlrnxnlx

dadafgs

Nov 26th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.HeadlessException;
  3. import javax.swing.JButton;
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.UIManager;
  7.  
  8. // @author rnxn
  9. public class Window extends JFrame {
  10.  
  11.     public Window(String title) throws HeadlessException {
  12.         super(title);
  13.         try {
  14.             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  15.         } catch(Exception e){}
  16.         initView();
  17.     }
  18.    
  19.     public JButton[] getButtons(){
  20.         return btnArray;
  21.     }
  22.    
  23.     public void setButtonState(boolean state){
  24.         btnArray[btnArray.length-1].setEnabled(state);
  25.     }
  26.    
  27.     private final String btnLabel[] = {"Procurar Arquivo...", "Gerar Arquivo"};
  28.     private final String btnAction[] = {"search", "create"};
  29.     private final JButton btnArray[] = new JButton[btnLabel.length];
  30.    
  31.     private void initView(){
  32.         setSize(400, 60);
  33.         setLocationRelativeTo(null);
  34.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  35.         setResizable(false);
  36.        
  37.         JPanel rootPanel = new JPanel(new WrapLayout());
  38.         rootPanel.setBackground(Color.WHITE);
  39.         setContentPane(rootPanel);
  40.        
  41.         int len = btnArray.length;
  42.         for(int i = 0; i < len; i++){
  43.             btnArray[i] = new JButton(btnLabel[i]);
  44.             btnArray[i].setSize(250, 40);
  45.             btnArray[i].setActionCommand(btnAction[i]);
  46.             rootPanel.add(btnArray[i]);
  47.         }
  48.         setButtonState(false);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement