Package javax.swing

Examples of javax.swing.JButton


    mSettingsPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    JButton config = new JButton(mLocalizer.msg("configure", "Search options"));

    config.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        showConfigDialog();
      }
View Full Code Here


      }
    });

    panel.setBackground(mText.getBackground());

    mSearchButton = new JButton(TVBrowserIcons.search(TVBrowserIcons.SIZE_SMALL));
    mSearchButton.setBorder(BorderFactory.createEmptyBorder());
    mSearchButton.setContentAreaFilled(false);
    mSearchButton.setMargin(new Insets(0, 0, 0, 0));
    mSearchButton.setFocusPainted(false);
    mSearchButton.setBorderPainted(false);
    mSearchButton.setFocusable(false);
    mSearchButton.setRequestFocusEnabled(false);
    mSearchButton.setRolloverEnabled(false);
    mSearchButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        showConfigureDialog(mText);
      };
    });
    mSearchButton.addMouseListener(new MouseAdapter() {

      @Override
      public void mousePressed(MouseEvent e) {
        showConfigureDialog(mText);
      }
    });
    mSearchButton.setToolTipText(mLocalizer.msg("preferences.tooltip", "Click to change search preferences"));

    mGoOrCancelButton = new JButton(IconLoader.getInstance().getIconFromTheme("action", "media-playback-start", 16));
    mGoOrCancelButton.setBorder(BorderFactory.createEmptyBorder());
    mGoOrCancelButton.setContentAreaFilled(false);
    mGoOrCancelButton.setMargin(new Insets(0, 0, 0, 0));
    mGoOrCancelButton.setFocusPainted(false);
    mGoOrCancelButton.setVisible(false);
View Full Code Here

    CellConstraints cc = new CellConstraints();

    panel.add(form, cc.xyw(1, 1, 3));

    JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        configure.setVisible(false);
        mSearchFormSettings = form.getSearchFormSettings();
        saveSearchFormSettings();
        textField.requestFocusInWindow();
View Full Code Here

    if (mChannel.getUserIconFileName() != null) {
      mIconFile = new File(mChannel.getUserIconFileName());
    }
   
    mIconLabel = new JLabel(createUserIcon());
    mChangeIcon = new JButton(mLocalizer.msg("useIcon", "Select channel icon"));
    mChangeIcon.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        changeIcon();
      }
    });

    panel.add(mIconLabel, cc.xy(3, 5));
    panel.add(mChangeIcon, cc.xy(3, 7));

    // URL
    panel.add(new JLabel(mLocalizer.msg("webAddress", "Web Address:")), cc.xy(1, 9));
    mWebPage =new JTextField(mChannel.getWebpage());
    panel.add(mWebPage, cc.xy(3, 9));

    // time correction
    panel.add(new JLabel(mLocalizer.msg("time", "Time zone correction:")), cc.xy(1, 11));
    mCorrectionCB = new JComboBox(new String[] { "-1:00", "-0:45", "-0:30", "-0:15", "0:00", "+0:15", "+0:30", "+0:45", "+1:00" });
    mCorrectionCB.setSelectedIndex(mChannel.getTimeZoneCorrectionMinutes() / 15 + 4);
    panel.add(mCorrectionCB, cc.xy(3, 11));

    JTextArea txt = UiUtilities.createHelpTextArea(mLocalizer.msg("DLSTNote", ""));
    // Hack because of growing JTextArea in FormLayout
    txt.setMinimumSize(new Dimension(150, 20));
    panel.add(txt, cc.xy(3, 13));

    // time limitation
    panel.add(DefaultComponentFactory.getInstance().createLabel(mLocalizer.msg("timeLimits","Time limits:")), cc.xy(1,15));
   
    String timePattern = mLocalizer.msg("timePattern", "hh:mm a");
       
    mStartTimeLimit = new JSpinner(new SpinnerDateModel());
    mStartTimeLimit.setEditor(new JSpinner.DateEditor(mStartTimeLimit, timePattern));
    setTimeDate(mStartTimeLimit, mChannel.getStartTimeLimit());

    mEndTimeLimit = new JSpinner(new SpinnerDateModel());
    mEndTimeLimit.setEditor(new JSpinner.DateEditor(mEndTimeLimit, timePattern));
    setTimeDate(mEndTimeLimit, mChannel.getEndTimeLimit());
       
    ((JSpinner.DateEditor)mStartTimeLimit.getEditor()).getTextField().setHorizontalAlignment(SwingConstants.LEFT);
    ((JSpinner.DateEditor)mEndTimeLimit.getEditor()).getTextField().setHorizontalAlignment(SwingConstants.LEFT);
   
    CaretPositionCorrector.createCorrector(((JSpinner.DateEditor)mStartTimeLimit.getEditor()).getTextField(), new char[] {':'}, -1);
    CaretPositionCorrector.createCorrector(((JSpinner.DateEditor)mEndTimeLimit.getEditor()).getTextField(), new char[] {':'}, -1);
   
    PanelBuilder timeLimitPanel = new PanelBuilder(new FormLayout("default:grow,10dlu,default:grow","default,2dlu,default"));
   
    timeLimitPanel.addLabel(mLocalizer.msg("startTime","Start time:"), cc.xy(1,1));
    timeLimitPanel.addLabel(mLocalizer.msg("endTime","End time:"), cc.xy(3,1));
    timeLimitPanel.add(mStartTimeLimit, cc.xy(1,3));
    timeLimitPanel.add(mEndTimeLimit, cc.xy(3,3));
   
    panel.add(timeLimitPanel.getPanel(), cc.xy(3,15));
   
    JTextArea txt2 = UiUtilities.createHelpTextArea(mLocalizer.msg("DLSTNote", ""));
    // Hack because of growing JTextArea in FormLayout
    txt2.setMinimumSize(new Dimension(150, 20));
    panel.add(txt2, cc.xy(3, 17));
   
    // buttons
    ButtonBarBuilder2 builder = new ButtonBarBuilder2();
    JButton defaultButton = new JButton(Localizer.getLocalization(Localizer.I18N_DEFAULT));
   
    defaultButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        resetToDefaults();
      }

    });
   
    builder.addButton(defaultButton);
    builder.addRelatedGap();
    builder.addGlue();

    mOKBt = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    mOKBt.addActionListener(this);
   
    getRootPane().setDefaultButton(mOKBt);
   
    mCloseBt = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    mCloseBt.addActionListener(this);

    builder.addButton(new JButton[] { mOKBt, mCloseBt });

    panel.add(new JSeparator(), cc.xyw(1, 19, 3));
View Full Code Here

    content.add(scrollPane, BorderLayout.CENTER);

    JPanel buttonp = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    JButton test = new JButton(mLocalizer.msg("testScript", "Test Script"));

    test.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent arg0) {
        testScript();
      }
View Full Code Here

      public void pluginDeactivated(PluginProxy proxy) {
        fillListbox();
      }
    });

    JButton addSeparator = new LineButton();
    addSeparator.setToolTipText(mLocalizer.msg("separator", "Add Separator"));
    addSeparator.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        int pos = mList.getList().getSelectedIndex();
        if (pos < 0) {
          pos = mList.getList().getModel().getSize();
        }
        mList.addElement(pos, new SeparatorMenuItem());
        mList.getList().setSelectedIndex(pos);
        mList.getList().ensureIndexIsVisible(pos);
      }
    });

    mList.addButton(addSeparator);

    final JButton garbage = new JButton(TVBrowserIcons.delete(TVBrowserIcons.SIZE_LARGE));
    garbage.setToolTipText(mLocalizer.msg("garbage", "Remove Separator"));
    garbage.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        Object[] items = mList.getList().getSelectedValues();
        for (Object item : items) {
          mList.removeElement(item);
        }
      };
    });

    mList.getList().addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(javax.swing.event.ListSelectionEvent e) {
        Object[] items = mList.getList().getSelectedValues();
        if (items.length == 0) {
          garbage.setEnabled(false);
          return;
        }
        for (int i=0;i<items.length;i++) {
          if (!(items[i] instanceof SeparatorMenuItem)) {
            garbage.setEnabled(false);
            return;
          }
        }

        garbage.setEnabled(true);
      };
    });

    garbage.setEnabled(false);
    mList.addButton(garbage);
  }
View Full Code Here

      FormLayout layout = new FormLayout("default,5dlu,default,5dlu,default","pref");
      layout.setColumnGroups(new int[][] {{1,3,5}});

      JPanel buttonPanel = new JPanel(layout);

      mAdd = new JButton(Localizer.getLocalization(Localizer.I18N_ADD));
      mAdd.setIcon(TVBrowserIcons.newIcon(TVBrowserIcons.SIZE_SMALL));
      mAdd.addActionListener(this);

      mEdit = new JButton(Localizer.getLocalization(Localizer.I18N_EDIT));
      mEdit.setIcon(TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));
      mEdit.setEnabled(false);
      mEdit.addActionListener(this);

      mDelete = new JButton(Localizer.getLocalization(Localizer.I18N_DELETE));
      mDelete.setIcon(TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));
      mDelete.setEnabled(false);
      mDelete.addActionListener(this);

      buttonPanel.add(mAdd, cc.xy(1,1));
View Full Code Here

    JPanel okButtonPanel = new JPanel();
    okButtonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    okButtonPanel.setLayout(new BoxLayout(okButtonPanel, BoxLayout.X_AXIS));
    okButtonPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));

    JButton ok = new JButton("OK");
    ok.addActionListener(this);

    okButtonPanel.add(Box.createHorizontalGlue());
    okButtonPanel.add(ok);

    // Register ActionListener to the settings
View Full Code Here

    // Add all availableActions to the buttonPanel
    for (Action action : mAvailableActions) {
      // <html> is needed to have a black color of the letters of a button,
      // because the Buttons have to be disabled for Drag'n'Drop
      JButton button = new JButton("<html><div style=\"text-align:center\">" + (String) action.getValue(Action.NAME)
          + "</div></html>");
      button.setBorder(new CompoundBorder(BorderFactory
          .createEmptyBorder(1, 1, 1, 1), BorderFactory.createEmptyBorder(1, 1,
          1, 1)));

      Icon icon = (Icon) action.getValue(Plugin.BIG_ICON);
      if (icon == null) {
        mLog.warning("Big icon missing for action " + action.getValue(Action.NAME));
        icon = (Icon) action.getValue(Action.SMALL_ICON);
      }
      if ((icon != null)
          && ((icon.getIconHeight() != TVBrowserIcons.SIZE_LARGE) || (icon.getIconWidth() != TVBrowserIcons.SIZE_LARGE))) {
        icon = UiUtilities.scaleIcon(icon, TVBrowserIcons.SIZE_LARGE, TVBrowserIcons.SIZE_LARGE);
      }
      button.setIcon(icon);
      button.setDisabledIcon(icon);
      button.setVerticalTextPosition(SwingConstants.BOTTOM);
      button.setHorizontalTextPosition(SwingConstants.CENTER);
      button.setFont(new Font("Dialog", Font.PLAIN, 10));
      button.addMouseListener(this);
      addMouseAdapterForHandCursorToComponent(button);
      button.setContentAreaFilled(false);

      // Set up the available ActionButtons for dragging
      DragSource d = new DragSource();
      d.createDefaultDragGestureRecognizer(button, DnDConstants.ACTION_MOVE, this);

      button.setEnabled(false);
      mButtonPanel.add(button);
    }
    mButtonPanel.updateUI();
  }
View Full Code Here

    add(button);
  }

  private void addButton(final Action action) {
    final JButton button = new PopupButton();
    addButtonProperties(button, action);
    button.setBorderPainted(false);
    button.setAlignmentX(Component.CENTER_ALIGNMENT);
    action.putValue(ACTION_VALUE, button);

    if(action.equals(((DefaultToolBarModel)mModel).getUpdateAction())) {
      mUpdateButton = button;
    }

    button.addMouseListener(new MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        button.setBorderPainted(true);
      }

      public void mouseExited(MouseEvent e) {
        button.setBorderPainted(false);
      }

      public void mousePressed(MouseEvent e) {
        if (e.isPopupTrigger() && !disabled) {
          showPopupMenu(e);
        }
      }

      public void mouseReleased(MouseEvent e) {
        if (e.isPopupTrigger() && !disabled) {
          showPopupMenu(e);
        }
      }
    });

    action.addPropertyChangeListener(new PropertyChangeListener() {
      @Override
      public void propertyChange(PropertyChangeEvent evt) {
        if (evt.getPropertyName().equals("enabled")) {
          button.setEnabled(action.isEnabled());
        }
      }
    });

    add(button);
View Full Code Here

TOP

Related Classes of javax.swing.JButton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.