Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.HeadlessException;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.UIManager;
- // @author rnxn
- public class Window extends JFrame {
- public Window(String title) throws HeadlessException {
- super(title);
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch(Exception e){}
- initView();
- }
- public JButton[] getButtons(){
- return btnArray;
- }
- public void setButtonState(boolean state){
- btnArray[btnArray.length-1].setEnabled(state);
- }
- private final String btnLabel[] = {"Procurar Arquivo...", "Gerar Arquivo"};
- private final String btnAction[] = {"search", "create"};
- private final JButton btnArray[] = new JButton[btnLabel.length];
- private void initView(){
- setSize(400, 60);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setResizable(false);
- JPanel rootPanel = new JPanel(new WrapLayout());
- rootPanel.setBackground(Color.WHITE);
- setContentPane(rootPanel);
- int len = btnArray.length;
- for(int i = 0; i < len; i++){
- btnArray[i] = new JButton(btnLabel[i]);
- btnArray[i].setSize(250, 40);
- btnArray[i].setActionCommand(btnAction[i]);
- rootPanel.add(btnArray[i]);
- }
- setButtonState(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement