Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JButton.setText horizontal cutted

import java.awt.Dimension;

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


public class Example {

public static void main(String args[]){
    JFrame frame = new JFrame();
    frame.setResizable(false);
    frame.setMinimumSize(new Dimension(200,150));
    frame.setLocationRelativeTo(null);
    frame.setLayout(null);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton exampleBtn1 = new JButton("set");
    exampleBtn1.setBounds(10, 10, 70, 10);
    frame.add(exampleBtn1);

    JButton exampleBtn2 = new JButton("set");
    exampleBtn2.setBounds(10, 30, 50, 10);
    frame.add(exampleBtn2);
}
}

this code display JFrame with 2 JButtons, each of then showing text "set" cutted a little bit vertically. but i cant get same result horizontally and JButton exampleBtn2 is an example of my problem.

how to make exampleBtn2 able to show all text in horizontal orientation? i want to get same result as vertical: even if JButton size is to small to show all text i want to see it cutted, not repleaced by dots.

like image 545
Periit Avatar asked Mar 05 '26 03:03

Periit


1 Answers

You can try with:

exampleBtn2.setMargin(new Insets(0, 0, 0, 0));
like image 119
Mateusz Sroka Avatar answered Mar 07 '26 16:03

Mateusz Sroka