javax.swing.JButton#setPreferredSize ( )源码实例Demo

下面列出了javax.swing.JButton#setPreferredSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: plugins   文件: ClockTabPanel.java
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;
}
 
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;
}
 
源代码3 项目: iBioSim   文件: EditPreferences.java
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;
}
 
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};
}
 
源代码5 项目: runelite   文件: TimerPanel.java
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);
}
 
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;
}
 
源代码7 项目: snap-desktop   文件: RemoteTopologyPanel.java
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;
}
 
源代码8 项目: rapidminer-studio   文件: TypeSelectionView.java
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;
}
 
源代码9 项目: jplag   文件: JPlagCreator.java
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;
}
 
源代码10 项目: brModelo   文件: Controler.java
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);
    }
}
 
源代码11 项目: mars-sim   文件: SettlementTransparentPanel.java
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);
	}
 
源代码12 项目: magarena   文件: ManaCostXChoicePanel.java
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);
}
 
源代码13 项目: chipster   文件: TaskImportDialog.java
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);
}
 
源代码14 项目: openjdk-8-source   文件: Test6910490.java
private JScrollPane create(String name, Dimension size, MatteBorder border) {
    JButton button = new JButton(name);
    button.setPreferredSize(size);
    button.setBorder(border);
    return new JScrollPane(button);
}
 
源代码15 项目: oim-fx   文件: OnlyMessageBox.java
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);
  }
 
源代码16 项目: runelite   文件: ConfigPanel.java
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);
}
 
源代码17 项目: chipster   文件: ClipboardImportDialog.java
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();
	}
}
 
源代码18 项目: chipster   文件: FeedbackDialog.java
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);
}
 
源代码19 项目: snap-desktop   文件: SourceProductSelector.java
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);
        }
    };
}
 
源代码20 项目: jdk8u-jdk   文件: Test6910490.java
private JScrollPane create(String name, Dimension size, MatteBorder border) {
    JButton button = new JButton(name);
    button.setPreferredSize(size);
    button.setBorder(border);
    return new JScrollPane(button);
}