I am a Java Programmer. \nI want to make \nmulti-column combobox \nin Java Swing. How can \nI do it?
95575
hope this helps u out..\n\nimport java.awt.*;\nimport java.awt.event.*;\nimport java.util.*;\nimport javax.swing.*;\nimport javax.swing.text.*;\n \npublic class ComboBoxMultiColumn extends JFrame\n{\npublic ComboBoxMultiColumn()\n{\ngetContentPane().setLayout( new GridLayout(0, 2) );\n \nVector items = new Vector();\nitems.addElement( new Item("1", "Car" ) );\nitems.addElement( new Item("23", "Plane" ) );\nitems.addElement( new Item("345", "Train" ) );\nitems.addElement( new Item("4567", "Nuclear Submarine" ) );\n \n//  Use a JTextArea as a renderer\n \nJComboBox comboBox1 = new JComboBox( items );\ncomboBox1.setRenderer( new TextAreaRenderer(5) );\n \ngetContentPane().add( new JLabel("TextArea Renderer") );\ngetContentPane().add( comboBox1 );\n \n//  Use a JTextPane as a renderer\n \nJComboBox comboBox2 = new JComboBox( items );\ncomboBox2.setRenderer( new TextPaneRenderer(10) );\n \ngetContentPane().add( new JLabel("TextPane Renderer") );\ngetContentPane().add( comboBox2 );\n \n//  Use a JPanel as a renderer\n \nJComboBox comboBox3 = new JComboBox( items );\ncomboBox3.setRenderer( new PanelRenderer(50) );\n \ngetContentPane().add( new JLabel("Panel Renderer") );\ngetContentPane().add( comboBox3 );\n \n//  Using HTML\n \nJComboBox comboBox4 = new JComboBox( items );\ncomboBox4.setRenderer( new HTMLRenderer() );\n \ngetContentPane().add( new JLabel("HTML Renderer") );\ngetContentPane().add( comboBox4 );\n}\n \nclass Item\n{\nprivate String id;\nprivate String description;\n \npublic Item(String id, String description)\n{\nthis.id = id;\nthis.description = description;\n}\n \npublic String getId()\n{\nreturn id;\n}\n \npublic String getDescription()\n{\nreturn description;\n}\n \npublic String toString()\n{\nreturn description;\n}\n}\n \npublic static void main(String[] args)\n{\nJFrame frame = new ComboBoxMultiColumn();\nframe.setDefaultCloseOperation( EXIT_ON_CLOSE );\nframe.pack();\nframe.setVisible( true );\n}\n \n/*\n**  Tabs are easier to use in a JTextArea, but not very flexible\n*/\nclass TextAreaRenderer extends JTextArea implements ListCellRenderer\n{\npublic TextAreaRenderer(int tabSize)\n{\nsetTabSize(tabSize);\n}\n \npublic Component getListCellRendererComponent(JList list, Object value,\nint index, boolean isSelected, boolean cellHasFocus)\n{\nItem item = (Item)value;\nsetText(item.getId() + "&#92;t" + item.getDescription());\nsetBackground(isSelected ? list.getSelectionBackground() : null);\nsetForeground(isSelected ? list.getSelectionForeground() : null);\nreturn this;\n}\n}\n \n/*\n**  Tabs are harder to use in a JTextPane, but much more flexible\n*/\nclass TextPaneRenderer extends JTextPane implements ListCellRenderer\n{\npublic TextPaneRenderer(int tabColumn)\n{\nsetMargin( new Insets(0, 0, 0, 0) );\n \nFontMetrics fm = getFontMetrics( getFont() );\nint width = fm.charWidth( 'w' ) * tabColumn;\n \nTabStop[] tabs = new TabStop[1];\ntabs[0] = new TabStop( width, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE );\nTabSet tabSet = new TabSet(tabs);\n \nSimpleAttributeSet attributes = new SimpleAttributeSet();\nStyleConstants.setTabSet(attributes, tabSet);\ngetStyledDocument().setParagraphAttributes(0, 0, attributes, false);\n}\n \npublic Component getListCellRendererComponent(JList list, Object value,\nint index, boolean isSelected, boolean cellHasFocus)\n{\nItem item = (Item)value;\nsetText(item.getId() + "&#92;t" + item.getDescription());\nsetBackground(isSelected ? list.getSelectionBackground() : null);\nsetForeground(isSelected ? list.getSelectionForeground() : null);\nreturn this;\n}\n}\n \n/*\n**  Use a panel to hold multiple components\n*/\nclass PanelRenderer implements ListCellRenderer\n{\nprivate JPanel renderer;\nprivate JLabel first;\nprivate JLabel second;\n \npublic PanelRenderer(int firstColumnWidth)\n{\nrenderer = new JPanel();\nrenderer.setLayout(new BoxLayout(
1083678
Question is not clear. \n\nAnyway, If you are using DataGrid or GridView, they have built-in features on ASP.NET. If not, you can impletment this manually using tricks.\n\nPlease explain your requirement with language, platform etc.
563283
You need to learn Java coding, especially client/server stuff and low-level sockets stuff. If you want to do it for free, you'll have to run the server on your own box. You'll also need to look at Swing and some way of creating a graphics engine. It'd be a lot of work - games these days are typically created by big teams.
1053311
//created by vinyl21 for yahoo answers\n//gjfr77@yahoo.com\nimport java.io.*;\nclass matrix{\nint n,m;\nint a[][]=new int[100][100];\nint r[]=new int[10];\nint c[]=new int[10];\nDataInputStream d=new DataInputStream(System.in);\n\nvoid input() throws IOException{\nSystem.out.println("ENTER THE NO OF ROW");\nn=Integer.parseInt(d.readLine());\nSystem.out.println("ENTER THE NO OF COLUMN");\nm=Integer.parseInt(d.readLine());\n\nfor(int i=1;i<=n;i++){\nfor(int j=1;j<=m;j++){\nSystem.out.print("("+i+","+j+"):");\na[i][j]=Integer.parseInt(d.readLine());}}}\n\nvoid process(){\nfor(int i=1;i<=n;i++){\nfor(int j=1;j<=m;j++){\nr[i]+=a[i][j];}}\n\nfor(int j=1;j<=m;j++){\nfor(int i=1;i<=n;i++){\nc[j]+=a[i][j];}}\n}\n\nvoid display(){\nSystem.out.println("given matrix");\n\nfor(int i=1;i<=n;i++){\nfor(int j=1;j<=m;j++){\n\nSystem.out.print(a[i][j]+"&#92;t");\n\n}\nSystem.out.println("&#92;n");}\n\nSystem.out.println("row sum");\n\nfor(int i=1;i<=n;i++){\nfor(int j=1;j<=m;j++){\n\nSystem.out.print(a[i][j]);\nif(j<m)System.out.print("   +   ");\nelse System.out.print("   =   ");}\nSystem.out.println(r[i]);\nSystem.out.println();}\n\nSystem.out.println("column sum");\n\nfor(int i=1;i<=n;i++){\nfor(int j=1;j<=m;j++){\n\nSystem.out.print(a[i][j]+"&#92;t");}\n\nif(i<n){\nSystem.out.print("&#92;n");\nfor(int d=0;d<m;d++){System.out.print("+&#92;t");}\n}\nelse {System.out.print("&#92;n");\nfor(int d=0;d<m;d++){System.out.print("=&#92;t");}}\nif(i==n){System.out.println();\nfor(int k=1;k<=m;k++){\nSystem.out.print(c[k]+"&#92;t");}}\nSystem.out.println();}\n\n}\n\nvoid displaye() throws IOException{\nSystem.out.println("PRESS ANY KEY TO EXIT");\nString n=d.readLine();}\n\n\npublic static void main(String args[])throws IOException{\nmatrix k=new matrix();\nk.input();\nk.process();\nk.display();\nk.displaye();}}\n\n/*output\nI:&#92;>cd j\n\nI:&#92;j>cd bin\n\nI:&#92;j&#92;bin>java matrix\nENTER THE NO OF ROW\n3\nENTER THE NO OF COLUMN\n3\n(1,1):1\n(1,2):2\n(1,3):3\n(2,1):9\n(2,2):8\n(2,3):7\n(3,1):4\n(3,2):5\n(3,3):6\ngiven matrix\n1       2       3\n\n9       8       7\n\n4       5       6\n\nrow sum\n1   +   2   +   3   =   6\n\n9   +   8   +   7   =   24\n\n4   +   5   +   6   =   15\n\ncolumn sum\n1       2       3\n+       +       +\n9       8       7\n+       +       +\n4       5       6\n=       =       =\n14      15      16\nPRESS ANY KEY TO EXIT\n*/
578619
seems like you have to download Sun Java\n\nwww.java.com
689958
I don't know which component u have to add ( its obvious if you search a little u can find ),\n\nbut i will tell the normal procedure.\n\nYou have to add a component ( this means including a DLL into our project and link it properly. Of course system will take care of lots of things ). You have add component and drag it from tool box and drop int onto the designer frame.\n\nNow you have to use the methods in the ( for which type the component name and press a DOT and it will show all methods under it ) and you will have to call proper method using button clicks or inside other ways to like page load... and call proper method with file name that you want to play.\n\nHope it helps.
898769
There are many things wrong with this program. First of all, you have "extends JPanel" when you don't even call a new (super) of JPanel. So, if you don't extend anything you will do alot better.\nUse something like this:\n\n\npublic class GridTest\n{\npublic void print(Graphics g)\n{\n\nint firstX = 0;\nint firstY = 0;\nint lastX = getWidth() - 10;\nint lastY = getHeight() - 10;\n\n//Draw vertical & horizontal lines.\nint x = firstX;\nwhile (x < lastX)\n{g.drawLine(x, firstY, x, lastY);\nx += 10;}\n\nint y = firstY;\nwhile (y < lastY) {\ng.drawLine(firstX, y, lastX, y);\ny += 10;} }\n\npublic static void main(String s[])\n{\nJFrame f = new JFrame("Grid Test");\nf.addWindowListener(new WindowAdapter() {\npublic void windowClosing(WindowEvent e) {System.exit(0);}\n});\nf.pack();\n\nf.setSize(new Dimension(1024,768));\nf.setSize(new Dimension(1024,768));\nf.setVisible(true);\n\nprint(f.getGraphics());\n\n}\n}\n\n\nI haven't tested this yet but I am positive it will work.
406314
If you know Java, it is not hard to write code to do such task, it might be tedious though.\nIf you don't, Ms excel could handle the job too with reasonable time and effort.
612072
use an array of string that the combo.itemdata value points to that string array. usefull?\n\n<finglish text>\nagar tozihe bishtar bedahid shayad bishtar betavanam komak konam.\n</finglish text>
2823
The standard Java development kit (JDK) supplied by Sun does not provide a tool to create platform specific executables (This is not suprising really). However, you do have a number of options to choose from that will help you get this done.\n\nFull article:\nhttp://uk.builder.com/programming/java/0,39026606,20283101,00.htm
842829
That will be JComboBox.\nSee link for more info\n\nOr do you mean JPopupMenu?
269418
There is a terrific Windows/Mac utility called Konfabulator that can run all sorts of cool Java-based applications, called "widgets". Some of those widgets are calculators. \n\nKonfabulator now belongs to Yahoo!, and is known as the "Yahoo! Widget Engine". I have included a link below. The software is free.\n\nIn the widget gallery, search for "calculator". Widgets that I think may meet your needs are "calculator", "Kalc", and "simpleCalc".
28466
Swing is a GUI toolkit for Java. Swing is one part of the Java Foundation Classes (JFC). Swing includes graphical user interface (GUI) widgets such as text boxes, buttons, split-panes, and tables.\n\nSwing widgets provide more sophisticated GUI components than the earlier Abstract Windowing Toolkit. Since they are written in pure Java, they run the same on all platforms, unlike the AWT which is tied to the underlying platform's windowing system. Swing supports pluggable look and feel – not by using the native platform's facilities, but by roughly emulating them. This means you can get any supported look and feel on any platform. The disadvantage of lightweight components is possibly slower execution. The advantage is uniform behavior on all platforms.
225729
do like this.\n<select name=combo1><option value=rs.getString("attribute")>rs.getString("attribute")</option>\n<option value=...>...</option>\n.....\n</select>\nwhere rs is the ResultSet object.\n\nI think this serves your purpose, i think javascript wont solve ur problem, since u have to display the combo with the options that were obtained from the database.
756425
community.java.net - Java Enterprise \nPopular Projects. Java BluePrints Solutions Catalog ... classes, and i explore how this might be useful in Swing EDT related programming. ...\nhttp://community.java.net/java-enterprise -\n\n\nA New Era for Java Protocol Handlers \nSecure class loading based on java.lang.SecureClassLoader. A rich GUI framework provided by Swing ... I work on Java projects in the real world. ...\nhttp://java.sun.com/developer/onlineTraining/protocolhandlers \n\n\n\nSpotlight \n... around Swing, the popular toolkit for building GUI's for Java desktop ... that are already involved in projects on java.net development are invited to ...\nhttp://today.java.net/today/projectspotlight.csp
651565
Swing components are not inherently thread safe, and as a general rule, after Swing components have been made visible on the screen, you can only safely modify their data from the event thread. If you modify Swing component data from any thread other than the event dispatching thread, you must take precautions to ensure data integrity. An exception to this rule is the setText method on a JTextComponent or any of its subclasses, or any Swing component method whose documentation explicitly states it is thread safe. \n\nSometimes, you cannot avoid modifying Swing component data from outside the event dispatching thread after it has been made visible. An example is spawning a thread to handle a long operation such as reading or writing a large file over the net. The advantage to spawning a new thread is that the user interface is made available to the user for other operations during the long file operation. The spawned thread is a new thread, and therefore, not on the event dispatching thread even if it is spawned by an event dispatching thread method. \n\nThis article explains how to use the InvokeLater method and synchronize keyword to ensure data integrity when modifying data in Swing components. If you are new to multi-threaded programming, see Creating a Threaded Slide Show Applet for an introduction to the threaded applications. \n\nFor furthur info please visit:\nhttp://java.sun.com/developer/technicalArticles/Threads/swing/
649903
What about Java?  What are you asking?\n\nI am not programmed to respond in that area.