how to hide text on JButton in java?

how to hide text on JButton in java?

By : Help
Date : November 14 2020, 04:51 PM
I hope this helps you . It's not a very good practice to set the text of a button to use it in comparisons etc, you should find another way to do that; maybe change your gumbi object to a Map.
If you insist on using setText you could set the same color for the backgroud and the text.
code :

Share : facebook icon twitter icon
Change size of JButton and text of a label on focus Gain and lost event of JButton

Change size of JButton and text of a label on focus Gain and lost event of JButton

By : Łukasz M
Date : March 29 2020, 07:55 AM
hop of those help? The problem is that you are mixing absolute-layout (or null-layout) with an implicit LayoutManager (JPanel comes with a FlowLayout by default).
When you call setText on a JLabel (and that text changes), it automatically calls revalidate which will eventually trigger the LayoutManager to lay out the components.
Java - How to hide JButton by pressing another JButton?

Java - How to hide JButton by pressing another JButton?

By : Steve
Date : March 29 2020, 07:55 AM
will help you When you press a button, in the ActionListener, tell the button to be disabled, using buttonObject.setEnabled(false)
How your ActionListener is currently set up, the easiest way to solve it is to expose JButton to the rest of the package (though, that isn't really... recommended).
code :
buttonName.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
        // Whatever other stuff you want to do.
How to change the text of one JButton by clicking a second JButton in Java

How to change the text of one JButton by clicking a second JButton in Java

By : Diego Fernandez
Date : March 29 2020, 07:55 AM
I hope this helps you . I want to change the text of one JButton when I click on the second JButton, but it's doing nothing. I don't know what is the problem is. If anyone will help me as soon as possible then I would be really thankful and will appreciate every effort. , Actually you have two issues:
code :
package a.b.c;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class myJPanel6 extends JPanel implements ActionListener {
    JButton b1, b2;
    student st1;
    String s1;

    public myJPanel6() {
        setLayout(new GridLayout(1, 1));

        st1 = new student("Michael", "Robinson", 20);
        b1 = new JButton(st1.getName());

        b2 = new JButton(st1.WhatIsUp());

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == b1) {
            s1 = st1.getName();


    public static void main(String[] args) {
        JFrame frm=new JFrame();
        myJPanel6 pnl=new myJPanel6();
java jbutton text does not fit on different environments

java jbutton text does not fit on different environments

By : Jan Nejman
Date : March 29 2020, 07:55 AM
With these it helps
FlowLayout by default acceptiong PreferredSize that came from JComponents
JButton with icon and text but hide text

JButton with icon and text but hide text

By : 肖振良
Date : March 29 2020, 07:55 AM
it fixes the issue
I need to create a JButton with text and icon but only show the icon.
Related Posts Related Posts :
  • Content autocomplete in spring tool suite 4
  • Super Noob Help ~ MouseEvent/Frame
  • Making one project with dependencies stand-alone in Eclipse (Java)
  • Jsoup- getting certain attributes from website
  • MongoDB, how to make a link between collections with JAVA code
  • Overriding an abstract method means class abstract class or not in java?
  • Bukkit teleport - nullPointerException
  • How to check if a Float variable is negative in java
  • Servlet: Cannot forward after response has been committed
  • sql query to select a specific cell in excel
  • How to make new picture when mouse dragged in java
  • Use Constants interface in GWT Project
  • Setting size of a JPanel in GroupLayout
  • Construct a map from two equal size arrays
  • Implementing Read-Write Locks with Double-Checked Locking
  • Disable NO_BUTTON from JOptionPane Java if a condition is true
  • UDP multiple socket
  • Android Threading: This Handler class should be static or leaks might occur
  • The type org.openqa.selenium.firefox.FirefoxDriver is not accessible
  • Limitations (drawbacks) of java programming language?
  • Error: ')' expected Error: illegal start of expression
  • TableRowSorter use LookAndFeel of TableHeader, but own Comparator
  • Difference between @GeneratedValue and @GenericGenerator
  • Design Scenario: Smartphone class and will have derived classes like IPhone,AndroidPhone,WindowsMobilePhone can be even
  • Java date parsing without separators?
  • how to map an array of custom type from postgres to java using hibernate
  • Why hibernate always call "update" statement after using "select" statement in MySQL?
  • An interview topic: What can go wrong with this code?
  • How do I regex remove whitespace and newlines from a text, except for when they are in a json's string?
  • How to turn off Preferences > Compiles > User External Build?
  • how to convert arraylist to string array with all items in double quote
  • PMD+Maven+JAVA Error:: Can't find resource rulesets/comments.xml. Make sure the resource is a valid file or URL or is on
  • How to extend AbstractScheduledService.Scheduler
  • Primefaces tabview: set Active Index after some counting
  • Need help in Regex to exclude splitting string within "
  • Get header from HttpUrlConnection object
  • encoding xlsx as base64 and send it as an attachment
  • How to acess HttpServletRequest in Jaas login module in Tomcat
  • How to implement a basic pointer
  • Java Swing Exit Icon?
  • Why onNext has no effect
  • IntelliJ Idea 2018.2 no option for importing gradle project
  • Remove a negative element from an array w/o array.copy
  • Could this prevent overflow in Java?
  • In Java Swing, can I receive Caret events in real time?
  • I need help not using brute force when using JFrames and DrawWindows
  • How do I refactor ArrayList<MyClass> into MyClassLIst?
  • My program keeps saying that the method cannot be resolved
  • BubbleSort -my code returns random addresses
  • JavaFX components inside HTML?
  • Character in Java game not responding
  • Working around access denied in a FileWalking Tree in Java7
  • How to avoid if/else when using multple suppliers?
  • How to pass object from table cell editor to Table Model?
  • Paypal Sandbox payment state pending
  • sejda-console.bat passing parameters with spaces
  • Multiple Consumers Spring Kafka
  • Bitbucket pipeline: environmental variables in build.gradle file not recognized
  • Java static enum method to return a default enum value
  • What is the complexity of empty for loop?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org