Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

GridBagLayout text not appearing on top left corner of the frame

$
0
0
I cant see the text appearing from top left corner... how can i modify the code to do this

 


	JFrame frame= new JFrame("frame name");
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(500,500);
		 
		String t=Integer.toString(x);
		JPanel panel = new JPanel(new GridBagLayout());
		
		
		
		
		
		
		frame.getContentPane().add(panel, BorderLayout.NORTH);
		GridBagConstraints c= new GridBagConstraints();
		
	//	frame.add(panel);
		
		
		
		JLabel label= new JLabel(t);
		c.gridx=0;
		c.gridy=0;
		c.insets = new Insets(10, 10, 10, 10);
		panel.add(label,c);
		
		JLabel labe2= new JLabel("10");
		c.gridx=500;
		c.gridy=50;
		//c.insets = new Insets(10, 10, 10, 10);
		panel.add(labe2,c);
		







Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>