SEARCH YOUR SOLUTION HERE  

easiest way to create & setting jpanels?

I am try to creating 21 jpanels with different ways...

1. drag & drop from eclipse windowsbuilder 21 times so each time its code like with settings also
JPanel panel_example = new JPanel(); panel_example.setBackground(new Color(245, 245, 245)); panel_example.setFont(new Font("Trebuchet MS", Font.PLAIN, 12)); panel_example.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_example.setBounds(78, 68, 86, 82); panel_example.setLayout(new BorderLayout(0, 0));

Posted On: Saturday 22nd of September 2012 12:00:16 AM Total Views:  227
View Complete with Replies




Related Messages:

passing value and setting it to jlabel text   (282 Views)
This site is really helping a lot of people! I have a simple program that I can't understand why I am getting the NullPointerException each time I try to pass a value from one form to another and setting it up as a text in a label. If I pass the value and do the pritln, I can actually see the result but if I place it in the jlabel as text, that's the time I get the error. Please Help!
how to create dialog box in swing that will close automatically after some time.   (224 Views)
somebody ,please suggest me how to create dialog box in swing that will close automatically after some time
Error while trying to create a JTable   (185 Views)
I am taking elements from a Dom parser and writing its content into a JTable with TreeSelectionListener() of JTree to indicate which node's data is to be displayed. private TreeSelectionListener createSelectionListener() { return new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); TreePath selected_path = e.getNewLeadSelectionPath(); selected_node = selected_path.getLastPathComponent().toString(); navpoint = xmlTree.name_compare(selected_node); content = xmlTree.content_return(); tables(); } }; } String selected_node() { return selected_node; } void tables () {//JTable table_node; String columnName[] = { "Name", "Value" }; Object rowData_node[][] = null; Object rowData_content[][] = null; JTable table_content = new JTable(rowData_content, columnName); NamedNodeMap elementAttributes = navpoint.getAttributes(); int numAttributes = elementAttributes.getLength(); for (int j = 0; j < numAttributes; j++) { Node attribute = elementAttributes.item(j); System.out.println("Node name :" + attribute.getNodeName()); System.out.println("Node Value :" + attribute.getNodeValue()); System.out.println("j :"+j); rowData_node[j][0] = attribute.getNodeName().toString(); rowData_node[j][1] = attribute.getNodeValue().toString(); } /*table_node = new JTable(rowData_node, columnName); right.add(table_node); table_node.setBounds(10, 10, 300, 300);*/ }
create a jtable which can combine and split and the image change also   (220 Views)
hi newbie here and would like to know how to create a jtable with default images and with specific column and rows that if you combine the cells the image enlarge and when split the image decreases.
why we use swing to create GUI application instead of AWT?   (164 Views)
we can also use AWT(Absract Window Toolkit).but when it is used to create component, it's called its native method. native method is written in C language. but C is platfom depended language. so, look and feel of the component is different for different platform(operating system). so, devloper can't make sure about appearence of his GUI. so,it's better to use swing rather than AWT. AWT component is heavyweighted means use more system resources(memory,processor time).
Proper way to show images, whose alignment is based on a condition   (159 Views)
I am getting a number of images from a database and then I have to show them in a gui, with a specific alignment. The alignment will be tabular-like and is based on how many images are returned from the database, meaning that if I get less than 10 images (from 1 to 9), they have to appear in columns of three. If I get more than 10, they have to appear in columns of four. Also, in case the number of images does not fully complete all the rows, the first row should show the remaining images, aligned in the center. For instance, if I get 8 images (meaning that I will need to show them in 3 columns), the first row should show 2 images (aligned in the center) and all other rows 3 images. I give you some more examples in the attached file, just to make it more clear as to how the images should appear. The way that I have handled this so far is by using JLabels inside JLabels, using the fact that since JLabel is a Container, I can set the layout and add other components in it. At the beginning I am setting the layout inside the JLabel to be GridLayout: int totalNumberOfImages = getNumberOfImages(); // getting the number of images int columns = 0; int rows = 0; //getting the number of columns based on the number of images if (totalNumberOfImages < 10) { columns = 3; } else { columns = 4; } //calculate the rows. rows = totalNumberOfImages / columns; if (totalNumberOfImages % columns > 0) { rows++; } //after I have the number of rows and columns, I set the GridLayout to the JLabel mainLabel.setLayout(new GridLayout(rows,columns));
Can't create a brand new panel   (146 Views)
Morgan Morten wrote:Once the user clicks the button, a brand new panel is created That's true. on the frame (and of course, a new text field inside the panel) That's not true. I'm not sure what you mean by "on the frame" but at any rate you don't put that new JPanel into the JFrame in any way, so there's no way for it to be seen by the user. And I'm not sure what makes you think that a new text field is created in that panel -- I don't see any code which does that. I'm not going to suggest how you should fix that, because adding new components to an existing GUI is not a common thing to do. A lot of the time when you see code which is trying to do that, it was written by somebody who didn't know about better alternatives. And anyway I'm not sure what you expect to happen after you click the button a dozen times and have 13 panels in there somewhere. , why would you need a new panel and a new textfield when done with the sale, create a sale object from the data on the screen, save that to a db, then clear the screen
Why can't i create a new object?   (179 Views)
I am having a simple error. I want to create a jframe to say a player already exists and have created a class in its own right. I am new to swing, so am not even sure if this is the right thing to do Anyway there is an error when i try to create a new object and i cant for the life of me figure out what it is public void mouseClicked(MouseEvent e) { String firstname = txtFirstname.getText(); String secondname = txtSurname.getText(); if(!(Players.usercheck(firstname, secondname))) { Players.addplayer(firstname, secondname); PlayerAdded pla = new PlayerAdded(firstname, secondname); pla.setVisible(true); } else { UserExists userexists = new UserExists(); userexists.setvisible(true); } } });
having problems with setting the color of a buffered Imaghe   (305 Views)
I created a buffered image in my programme and I want it to have a green (orany color other than black)background however i have been unable to get it to change from black to any other other color.hers the code i have been working with .