Java Code Examples for javax.swing.JButton#setPreferredSize()

The following examples show how to use javax.swing.JButton#setPreferredSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraceEventTypePopupMenu.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
private JButton getSelectAllJButton() {
    JButton selectAllJButton = new JButton("Select All");

    Dimension size = new Dimension(80, 20);
    selectAllJButton.setPreferredSize(size);
    selectAllJButton.setMinimumSize(size);
    selectAllJButton.setMaximumSize(size);

    selectAllJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {

            applySelectAll();
        }
    });

    return selectAllJButton;
}
 
Example 2
Source File: ClockTabPanel.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createHeaderPanel(String title, String type, boolean largePadding, ActionListener actionListener)
{
	JPanel panel = new JPanel(new BorderLayout());
	panel.setBorder(new EmptyBorder(largePadding ? 11 : 0, 0, 0, 0));
	panel.setBackground(ColorScheme.DARK_GRAY_COLOR);

	JLabel headerLabel = new JLabel(title);
	headerLabel.setForeground(Color.WHITE);
	headerLabel.setFont(FontManager.getRunescapeSmallFont());
	panel.add(headerLabel, BorderLayout.CENTER);

	JButton addButton = new JButton(ADD_ICON);
	addButton.setRolloverIcon(ADD_ICON_HOVER);
	SwingUtil.removeButtonDecorations(addButton);
	addButton.setPreferredSize(new Dimension(14, 14));
	addButton.setToolTipText("Add a " + type);
	addButton.addActionListener(actionListener);
	panel.add(addButton, BorderLayout.EAST);

	return panel;
}
 
Example 3
Source File: TimerPanel.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
TimerPanel(ClockManager clockManager, Timer timer)
{
	super(clockManager, timer, "timer", true);

	JToggleButton loopButton = new JToggleButton(ClockTabPanel.LOOP_ICON);
	loopButton.setRolloverIcon(ClockTabPanel.LOOP_ICON_HOVER);
	loopButton.setSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON);
	loopButton.setRolloverSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON_HOVER);
	SwingUtil.removeButtonDecorations(loopButton);
	loopButton.setPreferredSize(new Dimension(16, 14));
	loopButton.setToolTipText("Loop timer");
	loopButton.addActionListener(e -> timer.setLoop(!timer.isLoop()));
	loopButton.setSelected(timer.isLoop());
	leftActions.add(loopButton);

	JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON);
	SwingUtil.removeButtonDecorations(deleteButton);
	deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER);
	deleteButton.setPreferredSize(new Dimension(16, 14));
	deleteButton.setToolTipText("Delete timer");
	deleteButton.addActionListener(e -> clockManager.removeTimer(timer));
	rightActions.add(deleteButton);
}
 
Example 4
Source File: SelectDisplaySettingsWizardPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
private Component[] createColorField(String text, Color defaultColor) {
	JLabel colorLabel = new JLabel(text);
	final JTextField colorField = new JTextField();
	colorField.setEditable(false);
	colorField.setPreferredSize(txtDim);
	colorField.setMinimumSize(txtDim);
	colorField.setText(String.valueOf(defaultColor.getRGB()));	
	colorField.setBackground(defaultColor);
	JButton colorButton = new JButton();
	colorButton.setPreferredSize(buttonDim);
	colorButton.setMinimumSize(buttonDim);
	colorButton.setMaximumSize(buttonDim);
	colorButton.setIcon(ImageUtil.getImageIcon("copy_settings"));
	colorButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Color color = ExtendedColorChooser.showDialog(SwingUtilities.getWindowAncestor(SelectDisplaySettingsWizardPanel.this), 
					I18NSupport.getString("color.dialog.title"), null);
			if (color != null) {
				colorField.setText(String.valueOf(color.getRGB()));	
				colorField.setBackground(color);
			}
		}			
	});		
	return new Component[] {colorLabel, colorField, colorButton};
}
 
Example 5
Source File: EditPreferences.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
private static JButton createColorButton(Color color) {
	JButton colorButton = new JButton();
	colorButton.setPreferredSize(new Dimension(30, 20));
	colorButton.setBorder(BorderFactory.createLineBorder(Color.darkGray));
	colorButton.setBackground(color);
	colorButton.setForeground(color);
	colorButton.setUI(new MetalButtonUI());
	//colorButton.setActionCommand("" + i);
	colorButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			//int i = Integer.parseInt(e.getActionCommand());
			Color newColor = JColorChooser.showDialog(Gui.frame, "Choose Color", ((JButton) e.getSource()).getBackground());
			if (newColor != null) {
				((JButton) e.getSource()).setBackground(newColor);
				((JButton) e.getSource()).setForeground(newColor);
			}
		}
	});
	return colorButton;
}
 
Example 6
Source File: GenerateFromBuildFileSelectProjectViewOption.java    From intellij with Apache License 2.0 6 votes vote down vote up
public GenerateFromBuildFileSelectProjectViewOption(BlazeNewProjectBuilder builder) {
  this.builder = builder;
  this.userSettings = builder.getUserSettings();

  this.buildFilePathField = new TextFieldWithStoredHistory(LAST_WORKSPACE_PATH);
  buildFilePathField.setName("build-file-path-field");
  buildFilePathField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE);
  buildFilePathField.setText(userSettings.get(LAST_WORKSPACE_PATH, ""));
  buildFilePathField.setMinimumAndPreferredWidth(MINIMUM_FIELD_WIDTH);

  JButton button = new JButton("...");
  button.addActionListener(action -> chooseWorkspacePath());
  int buttonSize = buildFilePathField.getPreferredSize().height;
  button.setPreferredSize(new Dimension(buttonSize, buttonSize));

  JComponent box =
      UiUtil.createHorizontalBox(
          HORIZONTAL_LAYOUT_GAP, new JLabel("BUILD file:"), buildFilePathField, button);
  UiUtil.setPreferredWidth(box, PREFERRED_COMPONENT_WIDTH);
  this.component = box;
}
 
Example 7
Source File: TypeSelectionView.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private JButton createDataSourceSelectionButton(@SuppressWarnings("rawtypes") final DataSourceFactory factory) {
	String label = DataImportWizardUtils.getFactoryLabel(factory);
	String description = DataImportWizardUtils.getFactoryDescription(factory);

	JButton typeSelectionButton = new JButton(new AbstractAction() {

		private static final long serialVersionUID = 1L;

		@Override
		@SuppressWarnings("unchecked")
		public void actionPerformed(ActionEvent e) {
			enableDataSourceButtons(false);

			// update the wizard by setting the selected factory
			wizard.setDataSource(factory.createNew(), factory);

			// switch to the next wizard step (location selection)
			wizard.nextStep();
		}

	});

	typeSelectionButton.setText(label);
	typeSelectionButton.setToolTipText(description);

	typeSelectionButton.setMinimumSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setPreferredSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setMaximumSize(TYPE_BUTTON_DIMENSION);
	typeSelectionButton.setIcon(DataImportWizardUtils.getFactoryIcon(factory));

	return typeSelectionButton;
}
 
Example 8
Source File: ManaCostXChoicePanel.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public ManaCostXChoicePanel(final SwingGameController controller,final MagicSource source,final int maximumX) {
    this.controller = controller;
    this.maximumX=maximumX;
    x=maximumX;

    setLayout(new BorderLayout());
    setOpaque(false);

    final TextLabel textLabel=new TextLabel(SwingGameController.getMessageWithSource(source,MESSAGE),UserActionPanel.TEXT_WIDTH,true);
    add(textLabel,BorderLayout.CENTER);

    final JPanel buttonPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,10,0));
    buttonPanel.setOpaque(false);
    buttonPanel.setBorder(FontsAndBorders.EMPTY_BORDER);
    add(buttonPanel,BorderLayout.SOUTH);

    leftButton=new JButton("",MagicImages.getIcon(MagicIcon.LEFT));
    leftButton.setPreferredSize(BUTTON_DIMENSION);
    leftButton.addActionListener(this);
    leftButton.setFocusable(false);
    buttonPanel.add(leftButton);

    numberButton=new JButton(Integer.toString(x));
    numberButton.setPreferredSize(BUTTON_DIMENSION);
    numberButton.addActionListener(this);
    numberButton.setFocusable(false);
    buttonPanel.add(numberButton);

    rightButton=new JButton(MagicImages.getIcon(MagicIcon.RIGHT));
    rightButton.setPreferredSize(BUTTON_DIMENSION);
    rightButton.addActionListener(this);
    rightButton.setFocusable(false);
    buttonPanel.add(rightButton);
}
 
Example 9
Source File: SettlementTransparentPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void buildLabelPane() {

        labelPane = new JPanel(new FlowLayout(FlowLayout.LEADING));
        labelPane.setBackground(new Color(0,0,0,128));
		labelPane.setOpaque(false);

		JButton labelsButton = new JButton(Msg.getString("SettlementTransparentPanel.button.labels")); //$NON-NLS-1$
		//labelsButton.setFont(new Font("Dialog", Font.BOLD, 16));
		//labelsButton.setBackground(new Color(139,69,19)); // (139,69,19) is brown
		//labelsButton.setBackground(new Color(139,69,19,40));
		//labelsButton.setBackground(new Color(51,25,0,5)); // dull gold color
//		labelsButton.setBackground(new Color(0,0,0));//,0));
		labelsButton.setPreferredSize(new Dimension(80, 20));
//		labelsButton.setForeground(Color.green);
		labelsButton.setOpaque(false);
		labelsButton.setVerticalAlignment(JLabel.CENTER);
		labelsButton.setHorizontalAlignment(JLabel.CENTER);
		//labelsButton.setContentAreaFilled(false); more artifact when enabled
//		labelsButton.setBorder(new LineBorder(Color.green, 1, true));
		labelsButton.setToolTipText(Msg.getString("SettlementTransparentPanel.tooltip.labels")); //$NON-NLS-1$
		labelsButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				JButton button = (JButton) evt.getSource();
				if (labelsMenu == null) {
					labelsMenu = createLabelsMenu();
				}
				labelsMenu.show(button, 0, button.getHeight());
				//repaint();
			}
		});

		labelPane.add(labelsButton);


		labelPane.add(emptyLabel);
	}
 
Example 10
Source File: Controler.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
public void PopuleBarra(JComponent obj) {
    ButtonGroup buttons = new ButtonGroup();
    Barra = obj;

    Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
    JToggleButton btn = arrume(new JToggleButton(ac));
    buttons.add(btn);
    obj.add(btn);
    btn.setSelected(true);
    ac.IDX = -1;
    this.BtnNothing = btn;
    int i = 0;
    for (ConfigAcao ca : Lista) {
        if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
            ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
            ac.IDX = i++;
            btn = arrume(new JToggleButton(ac));
            buttons.add(btn);
            //obj.add(btn);
            listaBotoes.put(ca.command, btn);
        }
    }
    menuComandos c = menuComandos.cmdDel;
    String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
    ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
    ListaDeAcoesEditaveis.add(ac);
    ac.normal = false;
    JButton btn2 = new JButton(ac);
    btn2.setHideActionText(true);
    btn2.setFocusable(false);
    btn2.setPreferredSize(new Dimension(40, 40));
    obj.add(btn2);

    LayoutManager la = obj.getLayout();
    if (la instanceof GridLayout) {
        ((GridLayout) la).setRows(i + 2);
    }
}
 
Example 11
Source File: JPlagCreator.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
public static JButton createOpenFileButton(String toolTip) {
	JButton button = new JButton();
	button.setText("");
	button.setToolTipText(toolTip);
	button.setIcon(new ImageIcon(JPlagCreator.class.getResource("/atujplag/data/open.gif")));
	button.setPreferredSize(new java.awt.Dimension(24, 24));
	button.setBackground(JPlagCreator.SYSTEMCOLOR);

	return button;
}
 
Example 12
Source File: RemoteTopologyPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static JButton buildButton(String resourceImagePath, ActionListener buttonListener, Dimension buttonSize) {
    ImageIcon icon = UIUtils.loadImageIcon(resourceImagePath);
    JButton button = new JButton(icon);
    button.setFocusable(false);
    button.addActionListener(buttonListener);
    button.setPreferredSize(buttonSize);
    button.setMinimumSize(buttonSize);
    button.setMaximumSize(buttonSize);
    return button;
}
 
Example 13
Source File: ConfigPanel.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ConfigPanel()
{
	super(false);

	setLayout(new BorderLayout());
	setBackground(ColorScheme.DARK_GRAY_COLOR);

	JPanel topPanel = new JPanel();
	topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
	topPanel.setLayout(new BorderLayout(0, BORDER_OFFSET));
	add(topPanel, BorderLayout.NORTH);

	mainPanel = new FixedWidthPanel();
	mainPanel.setBorder(new EmptyBorder(8, 10, 10, 10));
	mainPanel.setLayout(new DynamicGridLayout(0, 1, 0, 5));
	mainPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

	JPanel northPanel = new FixedWidthPanel();
	northPanel.setLayout(new BorderLayout());
	northPanel.add(mainPanel, BorderLayout.NORTH);

	JScrollPane scrollPane = new JScrollPane(northPanel);
	scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	add(scrollPane, BorderLayout.CENTER);

	JButton topPanelBackButton = new JButton(BACK_ICON);
	topPanelBackButton.setRolloverIcon(BACK_ICON_HOVER);
	SwingUtil.removeButtonDecorations(topPanelBackButton);
	topPanelBackButton.setPreferredSize(new Dimension(22, 0));
	topPanelBackButton.setBorder(new EmptyBorder(0, 0, 0, 5));
	topPanelBackButton.addActionListener(e -> pluginList.getMuxer().popState());
	topPanelBackButton.setToolTipText("Back");
	topPanel.add(topPanelBackButton, BorderLayout.WEST);

	pluginToggle = new PluginToggleButton();
	topPanel.add(pluginToggle, BorderLayout.EAST);
	title = new JLabel();
	title.setForeground(Color.WHITE);

	topPanel.add(title);
}
 
Example 14
Source File: ClipboardImportDialog.java    From chipster with MIT License 4 votes vote down vote up
public ClipboardImportDialog(ClientApplication client) {
	super(Session.getSession().getFrames().getMainFrame(), true);

	this.client = client;
	this.setTitle("Import data from clipboard");
	this.setModal(true);

	label = new JLabel("Filename");
	nameField = new JTextField(30);
	nameField.setText("clipboard.txt");
	nameField.addCaretListener(this);
	skipCheckBox = new JCheckBox(VisualConstants.getImportDirectlyText());
	if (!Session.getSession().getApplication().isStandalone()) {
		skipCheckBox.setSelected(true);
	} else {
		skipCheckBox.setSelected(false);
	}

	folderNameCombo = new JComboBox(ImportUtils.getFolderNames(true).toArray());
	folderNameCombo.setEditable(true);

	okButton = new JButton("OK");
	okButton.setPreferredSize(BUTTON_SIZE);
	okButton.addActionListener(this);

	cancelButton = new JButton("Cancel");
	cancelButton.setPreferredSize(BUTTON_SIZE);
	cancelButton.addActionListener(this);

	GridBagConstraints c = new GridBagConstraints();

	this.setLayout(new GridBagLayout());
	// Label
	c.anchor = GridBagConstraints.WEST;
	c.insets.set(10, 10, 5, 10);
	c.gridx = 0;
	c.gridy = 0;
	this.add(label, c);

	// Combobox
	c.insets.set(0, 10, 10, 10);
	c.gridy++;
	this.add(nameField, c);

	c.insets.set(10, 10, 5, 10);
	c.gridy++;
	this.add(new JLabel("Insert in folder"), c);

	c.fill = GridBagConstraints.HORIZONTAL;
	c.insets.set(0, 10, 10, 10);
	c.gridy++;
	this.add(folderNameCombo, c);

	c.insets.set(10, 10, 10, 10);
	c.anchor = GridBagConstraints.EAST;
	c.gridy++;
	this.add(skipCheckBox, c);
	c.fill = GridBagConstraints.NONE;
	// Buttons
	c.insets.set(10, 10, 10, 10);
	c.anchor = GridBagConstraints.EAST;
	c.gridy++;
	JPanel keepButtonsRightPanel = new JPanel();
	keepButtonsRightPanel.add(okButton);
	keepButtonsRightPanel.add(cancelButton);
	this.add(keepButtonsRightPanel, c);

	if (this.isDataAvailable()) {

		this.pack();
		Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
		this.setVisible(true);
	} else {
		JOptionPane.showMessageDialog(this, "There is no text content on the clipboard");
		this.dispose();
	}
}
 
Example 15
Source File: FeedbackDialog.java    From chipster with MIT License 4 votes vote down vote up
public FeedbackDialog(SwingClientApplication application, String errorMessage, boolean sendSessionByDefault) {
    super(application.getMainFrame(), true);

    this.application = application;
    this.setTitle("Contact support");
    this.errorMessage = errorMessage;
    
    // Layout
    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0; 
    c.gridy = 0;
    
    // Text are for entering details
    c.insets.set(10,10,5,10);
    c.gridy++;
    this.add(new JLabel("Message"), c);
    detailArea = new JTextArea();
    detailArea.setLineWrap(true);
    detailArea.setWrapStyleWord(true);
    detailArea.setPreferredSize(new Dimension(300, 150));
    c.insets.set(0, 10, 10, 10);  
    c.gridy++;
    this.add(detailArea, c);
    
    // Email
    c.insets.set(10,10,5,10);
    c.gridy++;
    this.add(new JLabel("Your email"), c);
    emailField = new JTextField();
    emailField.setPreferredSize(new Dimension(300, 20));
    c.insets.set(0, 10, 10, 10);  
    c.gridy++;
    this.add(emailField, c);
    
    // Checkbox for attaching user data
    c.insets.set(10,10,5,10);
    c.gridy++;
    attachSessionBox = new JCheckBox("Attach data and workflow information");
    attachSessionBox.setSelected(sendSessionByDefault);
    this.add(attachSessionBox, c);
    
    // Checkbox for client logs
    c.insets.set(10,10,5,10);
    c.gridy++;
    attachLogsBox = new JCheckBox("Attach log files");
    attachLogsBox.setSelected(true);
    this.add(attachLogsBox, c);
    
    // OK button
    okButton = new JButton("OK");
    okButton.setPreferredSize(BUTTON_SIZE);
    okButton.addActionListener(this);
    
    // Cancel button
    cancelButton = new JButton("Cancel");
    cancelButton.setPreferredSize(BUTTON_SIZE);
    cancelButton.addActionListener(this);
    
    // Buttons pannel
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(buttonsPanel, c);
}
 
Example 16
Source File: OnlyMessageBox.java    From oim-fx with MIT License 4 votes vote down vote up
private void init(String message, OnlyMessageBox.MessageType messageType, int option) {

      iconMap = new HashMap<OnlyMessageBox.MessageType, Icon>();
      iconMap.put(OnlyMessageBox.MessageType.ERROR, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.INFORMATION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.QUESTION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.WARNING, new ImageIcon());

      JPanel buttonPane = new JPanel();
      lbMessage = new JLabel(message, iconMap.get(messageType), JLabel.LEFT);
      btnOK = new JButton("确定");
      btnCancel = new JButton("取消");
      btnYes = new JButton("是");
      btnNo = new JButton("否");
      JButton[] buttons = {btnOK, btnYes, btnNo, btnCancel};
      int[] options = {OK_OPTION, YES_OPTION, NO_OPTION, CANCEL_OPTION};
      final Dimension buttonSize = new Dimension(69, 21);
      int index = 0;
      boolean hasDefaultButton = false;

     
      lbMessage.setIconTextGap(16);
      lbMessage.setHorizontalAlignment(JLabel.LEFT);
      lbMessage.setVerticalAlignment(JLabel.TOP);
      lbMessage.setVerticalTextPosition(JLabel.TOP);
      lbMessage.setBorder(new EmptyBorder(15, 25, 15, 25));
      buttonPane.setLayout(new LineLayout(6, 0, 0, 0, 0, LineLayout.LEADING, LineLayout.LEADING, LineLayout.HORIZONTAL));
      buttonPane.setPreferredSize(new Dimension(-1, 33));
      buttonPane.setBorder(new EmptyBorder(5, 9, 0, 9));
      buttonPane.setBackground(new Color(255, 255, 255, 170));

      for (JButton button : buttons) {
          button.setActionCommand(String.valueOf(options[index]));
          button.setPreferredSize(buttonSize);
          button.setVisible((option & options[index]) != 0);
          button.addActionListener(this);
          buttonPane.add(button, LineLayout.END);
          index++;

          if (!hasDefaultButton && button.isVisible()) {
              getRootPane().setDefaultButton(button);
              hasDefaultButton = true;
          }
      }

      getContentPane().setLayout(new LineLayout(0, 1, 1, 3, 1, LineLayout.LEADING, LineLayout.LEADING, LineLayout.VERTICAL));
      getContentPane().add(lbMessage, LineLayout.MIDDLE_FILL);
      getContentPane().add(buttonPane, LineLayout.END_FILL);
  }
 
Example 17
Source File: SourceProductSelector.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public SourceProductSelector(AppContext appContext, String labelText, boolean enableEmptySelection) {
    this.appContext = appContext;
    this.enableEmptySelection = enableEmptySelection;

    productListModel = new DefaultComboBoxModel<>();

    productNameLabel = new JLabel(labelText);
    productFileChooserButton = new JButton(new ProductFileChooserAction());
    final Dimension size = new Dimension(26, 16);
    productFileChooserButton.setPreferredSize(size);
    productFileChooserButton.setMinimumSize(size);

    productNameComboBox = new JComboBox<>(productListModel);
    productNameComboBox.setPrototypeDisplayValue("[1] 123456789 123456789 12345");
    productNameComboBox.setRenderer(new ProductListCellRenderer());
    productNameComboBox.addPopupMenuListener(new ProductPopupMenuListener());
    productNameComboBox.addActionListener(e -> {
        final Object selected = productNameComboBox.getSelectedItem();
        if (selected != null && selected instanceof Product) {
            Product product = (Product) selected;
            if (product.getFileLocation() != null) {
                productNameComboBox.setToolTipText(product.getFileLocation().getPath());
            } else {
                productNameComboBox.setToolTipText(product.getDisplayName());
            }
        } else {
            productNameComboBox.setToolTipText("Select a source product.");
        }
    });

    productFilter = ProductFilter.ALL;
    selectionContext = new ComboBoxSelectionContext(productNameComboBox);

    productManagerListener = new ProductManager.Listener() {
        @Override
        public void productAdded(ProductManager.Event event) {
            addProduct(event.getProduct());
        }

        @Override
        public void productRemoved(ProductManager.Event event) {
            Product product = event.getProduct();
            if (productListModel.getSelectedItem() == product) {
                productListModel.setSelectedItem(null);
            }
            productListModel.removeElement(product);
        }
    };
}
 
Example 18
Source File: Test6910490.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private JScrollPane create(String name, Dimension size, MatteBorder border) {
    JButton button = new JButton(name);
    button.setPreferredSize(size);
    button.setBorder(border);
    return new JScrollPane(button);
}
 
Example 19
Source File: TaskImportDialog.java    From chipster with MIT License 4 votes vote down vote up
public TaskImportDialog(ClientApplication application, String title, ImportSession importSession, Operation importOperation, String okButtonText, String cancelButtonText, String skipButtonText, String noteText) throws MicroarrayException {
	super(Session.getSession().getFrames().getMainFrame(), true);

	this.application = application;
	this.importSession = importSession;
	this.importOperation = importOperation;
	this.setTitle("Import");
	this.setModal(true);
	this.setPreferredSize(new Dimension(500, 300));

	// initialise components
	titleLabel = new JLabel("<html><p style=" + VisualConstants.HTML_DIALOG_TITLE_STYLE + ">" + title + "</p></html>");
	descriptionLabel = new JLabel("<html>" + importOperation.getDescription() + "</html>");
	noteLabel = new JLabel("<html><p style=\"font-style:italic\">" + noteText + "</p></html>");

	folderNameCombo = new JComboBox(ImportUtils.getFolderNames(false).toArray());
	folderNameCombo.setEditable(true);

	okButton = new JButton(okButtonText);
	okButton.setPreferredSize(BUTTON_SIZE);
	okButton.addActionListener(this);

	skipButton = new JButton(skipButtonText);
	skipButton.setPreferredSize(BUTTON_SIZE);
	skipButton.addActionListener(this);

	cancelButton = new JButton(cancelButtonText);
	cancelButton.setPreferredSize(BUTTON_SIZE);
	cancelButton.addActionListener(this);

	ImportParameterPanel parameterPanel = new ImportParameterPanel(importOperation, null);

	JPanel keepButtonsRightPanel = new JPanel(new GridBagLayout());
	GridBagConstraints buttonConstraints = new GridBagConstraints();
	buttonConstraints.weightx = 1.0;
	buttonConstraints.weighty = 1.0;
	buttonConstraints.anchor = GridBagConstraints.EAST;
	buttonConstraints.insets.set(0, 0, 0, 8);
	keepButtonsRightPanel.add(cancelButton, buttonConstraints);
	if (importSession != null) {
		buttonConstraints.anchor = GridBagConstraints.CENTER;		
		keepButtonsRightPanel.add(skipButton, buttonConstraints);
	}
	buttonConstraints.gridx = GridBagConstraints.RELATIVE;
	buttonConstraints.insets.set(0, 0, 0, 0);
	keepButtonsRightPanel.add(okButton, buttonConstraints);
	
	
	// layout
	GridBagConstraints c = new GridBagConstraints();
	this.setLayout(new GridBagLayout());

	// title label
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(10, 10, 5, 10);
	c.gridx = 0;
	c.gridy = 0;
	this.add(titleLabel, c);

	// description label
	c.gridy++;
	this.add(descriptionLabel, c);
	
	// parameter panel
	c.gridy++;
	c.weighty = 120.0;
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(0, 10, 10, 10);
	this.add(parameterPanel, c);

	// note
	c.gridy++;
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.insets.set(0, 10, 10, 10);
	c.fill = GridBagConstraints.HORIZONTAL;
	this.add(noteLabel, c);
	
	// buttons
	c.insets.set(10, 10, 10, 10);
	c.anchor = GridBagConstraints.SOUTHEAST;
	c.gridy++;
	c.fill = GridBagConstraints.NONE;
	this.add(keepButtonsRightPanel, c);


	// make visible
	this.pack();
	Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
	this.setVisible(true);
}
 
Example 20
Source File: Test6910490.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private JScrollPane create(String name, Dimension size, MatteBorder border) {
    JButton button = new JButton(name);
    button.setPreferredSize(size);
    button.setBorder(border);
    return new JScrollPane(button);
}