Jump to content

Button.setborder(null) not work

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Serialcek

Serialcek

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Hello guys!
I've created a JFrame with a JPanel in Netbeans and then I moved the project in Eclipse.
In the JPanel I put a grid layout with buttons. I want that these buttons have no border.
But setborder(null) is not working :(

I have already one project in eclipse and there setborder(null) is working..

I actually don't know what to do.. is there some trick or something, is something wrong with my container (JPanel)?

Thx

#2
Serialcek

Serialcek

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Hi guys..
So I tried also this:

Border empty;
empty = BorderFactory.createEmptyBorder();
start.setBorder(empty);

And is also not working.. does someone have any idea?

#3
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
Have you tried using the setBorderPainted(false); method?

#4
Serialcek

Serialcek

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
Yes I've tried and nothing..

Could it be that because of some library it doesn't work?

#5
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
This seems to be working for me (using setBorderPainted(false))

	public static void main(String[] args) {

		// TODO Auto-generated method stub

		JFrame frame = new JFrame("frame");

		JPanel panel = new JPanel() {

			public Dimension getPreferredSize() {

				return new Dimension(100, 100);

			}

		};

		JButton button = new JButton("Hello");

		button.setBorderPainted(false);

		

		panel.add(button);

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		frame.setContentPane(panel);

		frame.setLocationRelativeTo(null);

		frame.pack();

		frame.setVisible(true);

	}


#6
Serialcek

Serialcek

    Learning Programmer

  • Members
  • PipPipPip
  • 72 posts
I believe you that is working.. on some of my project is working too..
I don't know what's wrong with this my project. As I sad I created GUI in Netbeans and then put it in Eclipse..
I've also tried to put the border away in Netbeans and still it's not working... don't know where is the problem.. :/ :confused:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users