Component 1 « Component « Java Swing Q&A





1. Do I need to free Swing components before letting them get garbage collected?    stackoverflow.com

Wnen I use external resources such as files or DB connection I need to close them before I let them go. Do I need to do the same thing with Swing components ...

2. Java: How do you style Swing components?    stackoverflow.com

I'm writing my first Java project. I was wondering if it's possible to style the Swing components (set a background color, remove the borders from the buttons, etc.)

3. Java Component.show() / hide() are deprecated ... why?    stackoverflow.com

Anyone know the reason (just curious)

4. "Spotlight" like component for Swing?    stackoverflow.com

I am just thinking about ways to improve the user experience for our data entry application and thought about a Mac OS X Spotlight like search bar which allow the user ...

5. How can I wait until a component is shown in Java?    stackoverflow.com

I have a component (JPanel) inside a Window. I always get false when calling panel.isShowing(), when calling from a windowGainedFocus() event (when the parent window gets focus). I assume that when the windowGainedFocus() event ...

6. Component based composition    stackoverflow.com

Can anyone assist me to implement a component-based project? I have designed two components i.e calculator and engine (source codes below) which need to be inside any of the swing components ...

7. Superimposing Swing components    stackoverflow.com

Is it possible at all to have one component superimposed (or stacked) over another in Swing? I'm thinking about having a progressbar (in the foreground) which would be sitting ...

8. How to do effective TDD for swing components    stackoverflow.com

I am working on Swing, I want to know how to effectively do TDD for my GUI applications. I have already done something using abbot and fest... but i still feel it ...

9. Advice welcomed on creating my own Swing component    stackoverflow.com

Recently I asked which was the best Swing component to bind to a BigDecimal variable (with some particular editing properties). It turns out that none of the standard Swing components ...





10. What is the proper way to get the current look-and-feel's component background color in Swing?    stackoverflow.com

I am writing a custom Swing component with my own painting. I'd like to query whether or not the current look and feel's components are opaque, and if so, what ...

11. Where are the really high quality and complex Swing components?    stackoverflow.com

Looking at Swing, I have the feeling that it comes with many useful and reasonable atomic components in its core. And when I look at the Web there are hundrets of ...

12. Rendering Swing Components to an Offscreen buffer    stackoverflow.com

I have a Java (Swing) application, running on a 32-bit Windows 2008 Server, which needs to render it's output to an off-screen image (which is then picked up by another C++ ...

13. Swing add new Component    stackoverflow.com

I need to add dynamicaly Components to JPanel, but if i make just add(Component) then component doesn't appears, if i make then JPanel.revalidate(); then it appears, but JPanel blinks, can I ...

14. How to wrap a Component to several lines    stackoverflow.com

I have a large component (say width=4000px, height=200px) and would like to be able to see it entirely even on a small screen. I don't see any easy way to do a ...

15. how to nest complicated Swing components    stackoverflow.com

In my Swing app, I have a POJO class called Command. Command has a few subclasses. Most of the Command subclasses consist of 2 or 3 Strings. But ...

16. How to switch two components    stackoverflow.com

I have a JPanel with a GridBagLayout. And I would like to give the user the possibility to switch two components. I tried it like that, but it doesn't work, what ...





17. Accessing Swing components of another class    stackoverflow.com

I have two classes gameWindow and gameEngine. The Main method is in gameWindow class & so is the swing GUI code. Now, I want to access the swing components in gameEngine. ...

18. Should I declare my Swing components as instance variables, or just return them from functions?    stackoverflow.com

I am just getting started with JAVA and I am trying to figure out what the best practice for declaring variables would be, esp in regards to GUI components. I am ...

19. Swing Component Difficulties    stackoverflow.com

I just can't seem to get this to work at all. I'm trying to get a JTextField (input) to pass text to a JTextArea (reader) positioned above it when the ...

20. Swing: problems with component's background    stackoverflow.com

I've got a problem, that swing components in different parts of program have sometimes wrong background. For example this or this. As I mentioned, the bug is not ...

21. General Question about Swing Components    stackoverflow.com

I was wondering how swing components themselves are actually made. It seems like a JComboBox is made up of a JButton and when you click it, a JList appears below it. ...

22. Problem in RAD 7.0 with java Swing component    stackoverflow.com

I am working on swing components and got the following error when i tried to add swing label "add(label)". Here is the error.

*Unhandled exception
Type=Segmentation error vmState=0x00040000
J9Generic_Signal_Number=00000004 ExceptionCode=c0000005 ExceptionAddress=6918465C ContextFlags=0001003f
Handler1=008505B0 Handler2=008974F0 InaccessibleAddress=AB924D78
EDI=68D11CA4 ...

23. looking up Swing components by their id?    stackoverflow.com

Is it possible to get a reference to a swing object via some lookup method ?? Keeping a multitude of instance variables for every single UI element seems to be such ...

24. NetBeans GUIBuilder - Adding multiples of same Swing component from pallete holding shift always results in NetBeans crashing    stackoverflow.com

Has anybody else experienced the above mentioned problem whilst using the NetBeans GUIBuilder? Could anyone recommend a fix? Thank you:)

25. Swing Java component visibility control    stackoverflow.com

I can control the visibility of the frame, but can't control the visibility of component. I can't get the code.

26. interactive component in Java Swing    stackoverflow.com

I'm required to implement a map in Java Swing, which is connected with a spatial database to handle some queries. I used a jLabel to represent the map image. I need to ...

27. Equivalent GUI components Swing    stackoverflow.com

I have the following question: given a Swing GUI application (source code included), how can I ascertain that two components (e.g: JButtons, JList, etc) are equivalent (in the way that the ...

28. Components disappearing after setting visable to false and then to true again    stackoverflow.com

i have this program with a small amount of settings, and it should look like this:
http://img4.imageshack.us/img4/8527/programbillede.png (sorry, cant post images..)
and this is loaded in main and then hidden, and ...

29. Java return Component    stackoverflow.com

I have a problem with my program. I'm working on the gui, and I can't get it to change the view with this line in the class MenuController:

currentComponent = timeRegController.getView().userRegisterTime(user);
But I have ...

30. How to call self component in Java swing?    stackoverflow.com

I have many buttons in a button group that need to search a database using their containing text as the query when toggled. Instead of typing out specific event code ...

31. Stream Java Swing Components over RTP    stackoverflow.com

Currently, I am looking for an option to stream the contents of a JPanel over RTP to a receiving client. The JPanel would e.g. contain a JFreeChart and some labels that ...

32. Which swing components to use    stackoverflow.com

Can you tell me which Java components I should use to achieve the same result as on picture?enter image description here After clicking on the link FileChooser is opened.

33. "Component cannot be instantiated" in Netbeans 7.0.1    stackoverflow.com

EDIT: Sorry, I just started programming in Java. It turned out to be a problem with an out of range array access... I am used to error messages about this kind ...

34. New Swing JLayer in Java 7    stackoverflow.com

I am just catching up with some of the new features in J7 and am perplexed by the addition of these JLayers in Swing. Since they're so new I am having ...

35. AWT and Swing components in NetBeans    stackoverflow.com

Scenario : In NetBeans, you create Swing components via drag & drop and customize some properties via the given GUI. Question : Later on, If you see the generated code of these ...

36. Java separate components with lines    stackoverflow.com

I am learning some GUI stuff on Java and I think Im missing something here. I have some components vertically listed using BoxLayout, such as some JButtons one above other. Now I ...

37. Line graphical component    stackoverflow.com

I want to draw a line between different components in a JPanel, but the line should be a component, ie, it can be clicked, highlighted, selected and deleted instead of just ...

38. What Java Components will suffice the need..?    stackoverflow.com

My application will be similar to MS Compiled HTML Help Viewer. On the left side, I will be using JList and on the right side, a JTextPane containing long text files. ...

39. Why are my swing components so big?    bytes.com

brendanmcdonagh Hi all, I might be being stupid here but for the life of me I can't understand/remember how to layouut my software so the buttons and textbox's don't go big, ...

40. Locking components to the GUI? Possible? help!    forums.netbeans.org

The netbeans free-form layout is REALLY starting to annoy me. It's perfect in so many ways but it can make me want to pull my hair out. I'm definitely not going ...

41. Trouble with Sun Swing Component in Netbeans GUI    forums.netbeans.org

Originally posted at http://forums.sun.com/thread.jspa?messageID=10930576� The ScrollDemo program on http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html uses a Rule class extending a Swing Component. I tried to add this component onto a Netbeans extended JPanel using the method ...

43. How to swtich Swing components with own implemented ones?    forums.netbeans.org

Hello, OK, I'm creating a GUI with netbeans cause I don't have few months to learn to code the components by hand... I added a jPanel in NetBeans class DrawLine extends JPanel { bla bla bla } and via Netbeans I added a normal jPanel in it's place and adjusted the size. Now I wanted the netbeans jPanel1 be switched from ...

45. heavy wt components    coderanch.com

46. Do Swing Components (but 4) look identical for Operating Systems    coderanch.com

Both. They will look very similar (font sizes may vary) on all systems. That is one reason for Swing. Each component handles its own rendering therefore they will be drawn the same on all systems. You can also force the Swing components to look like Motif, Windows, or Metal on all systems. If you just use Swing components without setting a ...

47. Need component separator ->    coderanch.com

Hello! I have an JPanel which contains several components (JButtons, JTextAraes etc) and every now and then I need to use a separator to get some space between the components. Up to now I have used an invisible Canvas for this purpose, but it gives me some "not so nice" problems, so I would like to know if there is any ...

48. Is there a swing component or an awt component for an IPAddress Field    coderanch.com

Hi Is there a swing component or an awt component for an IPAddress format to be accepted. If so, please let me know. Right now, I'm able to format using a JMaskedTextField, but I need to restrict the numbers entered into the IPADdress to 255 i.e 255.255.255.255. How do I do this ?!! Thanks Meghna

49. swing components    coderanch.com

50. Creating a table component    coderanch.com

I have to create a table component having features like * scrolling list of different items like Colors and text. * Names of the columns are displayed as headers. * Functionality of sorting the table, multiple-selection, add a col/row,... etc etc * The Table uses a TableModel for Data storage . I have created a scrollpane for details i.e. row/col and ...

51. component communication    coderanch.com

HI, I have a Frame inside of which there is a Canvas (acting as a toolbar). I need to drag the mouse from the canvas into the frame and release the mouse button on the frame area. now when i drag by clicking on the canvas, the mouse drag event of Canvas is called, but when i release the mouse over ...

52. Swing Component    coderanch.com

53. Placing a component on top of other components    coderanch.com

Hi i am not able to place/insert any componet on top of other components during runtime; if i try to place it, it goes behind the existing components, i know it could be done using java.awt.window. Using its toBack(),toFront() methods i can control the look, but its not possible using Canvas or other components.Could someone suggest an alternative. should i be ...

54. JChart component .. Need some pointers !!    coderanch.com

Hi This is a link to the API of the JChart component. I need to be able to achieve the following : 1. To be able to support multiple graphs 2. Support multiple YAxis labels 3. Zoom in a particular selected area 4. Display current X & Y values when the user moves the cursor on the graph 5. Display of ...

55. Using Swing Components    coderanch.com

Hi Guy's !!! Which swing component is similar to the "JTextPane component" in the sense of it's "ability to display text in various different formats,styles & color" and which also has the "ability to display continous text" and is "not dependent on the horizontal scrollbar" to view the text.(In this sense something like the "JTextField component" ). Can the JTextPane component ...

56. Question about internal components    coderanch.com

57. d'n'd any component    coderanch.com

58. How to autosize the components.    coderanch.com

59. while adding different components at same place    coderanch.com

I have some issues on my gui. while selecting values selected in the combobox components(comboboxes)have to be removed and has to add some other components(comboboxes) in that exact place. but, removing components is fine. but, while adding the same it's adding components to the gui is not working. because it's adding some where else.

60. adding and remoing components    coderanch.com

61. java Swing components fade    coderanch.com

62. Can I force components to front?    coderanch.com

Well, in that case, when you select on item on the list, the ComboBox returns back to it's textfield state. Then the buttons can be seem. So what is the problem? Does the user need to push the buttons while the combo box is dropped down? IF so, that doesn't sound like good GUI design. Could we know more about the ...

63. Help Initializing GUI Components?    coderanch.com

I am looking for ways to initialize a GUI screen and make sure that it is initialized only once. In other words, I am looking for examples that accomplish what the following code does. if (frame == null) { frame = new JFrame(); } else { frame.setTitle("Title"); } I am looking for a more elegant way to check if a gui ...

64. Creating Swing components on the fly    coderanch.com

65. placing swing components    coderanch.com

It seems that you are missing getContentPane() method that's why they are visible in AWT but not Swing cuz Swing requires this method to add component in the GUI. As you are adding your components to JPanel instance. And now what you have to do is to add your JPanel instance with the getContentPane(). Try out the following example: import java.awt.* ...

66. set components to support Hebrew    coderanch.com

67. swing components    coderanch.com

as far as i know i think JComponent is the only lightweight one. Lightweight componenets are swing components that dont use the native operating system peers for displaying the controls (or widgets). all awt controls are heavy ones since they use the operating system to display the buttons, labels, checkboxes etc.... (thus they wil look different on different OS). swing componeents ...

68. How to set this component?    coderanch.com

Hi Arun, It seems to me that you are just trying to add a background image to a panel. Look at the following class and see how it can help you. import java.awt.*; import java.awt.event.*; import javax.swing.*; class BackPanel extends JPanel { private Image image; public BackPanel() { this( new FlowLayout(), null ); } public BackPanel( String imagePath ) { this( ...

69. Which Component??need Help    coderanch.com

70. why this component access is multiplying?    coderanch.com

Hello, I have made the followin program and facing this problem. Whenever I click at go of Login screen it adds while printing on system. What i mean if i enter data into id & password and click at go it shows its value first time one time on scrren and in second tme 2 times and third times 3 times..and ...

71. How to create own Swing Component?    coderanch.com

73. getting a reference to every running gui component?    coderanch.com

I want to call SwingUtilities.updateComponentTreeUI(Component) on all of the components that are currently visible (JFrames and JPanels). Is there any way to keep track of this without implementing it manually? I just need a reference to every running window and I am wondering if swing provides this. Otherwise I will just write an event framework and have the gui components register ...

74. Determining component    coderanch.com

Thanks for your answer Nate. In my code below you'll see I do the cast as you suggest, ( I am using MouseListeners to call the popup ). But I get a Class Cast Exception Here's what I've got: if(e.getSource() == popupIngredientItem) { JTable t = ((JTable)e.getSource()); String confirm = "Print details for item: "; int r,c; r = t.getSelectedRow(); c ...

75. Swing components    coderanch.com

I have 3 swing components text field, combo box and a text field and want to display them in that order each on one line. I am not able to figure out Swing equivalent of text new line. I tried fiddling with Layout manager, but I think I am doing something wrong. Any ideas or pointers would be helpful. Thanks

76. Rightclicking on components    coderanch.com

I don't know how to do it with your extended button, since you didn't post the code... but here's how you can add a popup menu to a normal JButton... import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class ButtonPopupTest extends JFrame ...

77. Making components look the way you want them to    coderanch.com

Thanx Gregg, I saw these bunch of skins for your java app's & it just blew me off big time. I know it'll be pretty much a waste of time trying to make your app look like a work of art when functionality matters, but at times it does matter to the end user & well, I just gotta know how ...

78. JScrollPand and components    coderanch.com

79. Separating the business logic from the gui components    coderanch.com

Hi Everyone, I'm in the process of designing a GUI application using Swing. Is there any information available on the correct way to separate the business logic from the GUI piece? For example, if I want to create a GUI screen which accepts user information(i.e. name, ss#, phone #, etc), where is the right place to put the validation code? I ...

80. How to reference a component?    coderanch.com

Hello all, I am working on a GUI. This Gui is constitued of several components. Three of those components are 1 JTable, 2 TextArea. Each time the user select a row, a message must be displayed in the 2 Textareas. The two TextAreas are in different Panels. One way I'm using to reference those textareas, is to pass them to the ...

81. Component Hierarchy    coderanch.com

Hello I am trying to come up with a little tool to tag components on a user interface. Here's the strategy I am following: I take a component and traverse into it and find out the components in it and obtain its name. Thereby associating a tag to the component. Now I have a little problem in achieving this. I cannot ...

82. which the best way to add components    coderanch.com

The best ( and only ) way to add components to a container is through the container's add() method. Though, if you are having problems adding components to containers and having them show up like you wanted them, then you are having problems with layout managers instead. Read about layout managers here... also it might be a problem with setting the ...

83. Get a component from x / y coords    coderanch.com

84. Address Bar Component    coderanch.com

85. Swing: adding components later    coderanch.com

86. Customizing Swing Components    coderanch.com

87. how to create our own swing component    coderanch.com

88. Component Rearrangement by User    coderanch.com

89. Component Please??    coderanch.com

Hi, I am in development of a component. It should have following features. 1) It should take a image (Image) and and a popup menu as input. 2) It should display the image and when user scrolls on that image user should get the assigned popup for that image. 3) The image can be overlayed by other same component. Eg. I ...

90. Swing Components    coderanch.com

91. horizontal weight of a component    coderanch.com

Welcome to the Ranch Nadinha. I hope this is what you want: import javax.swing.*; import java.awt.*; public class Test extends JFrame { Test() { setDefaultCloseOperation(EXIT_ON_CLOSE); Container content = getContentPane(); content.setLayout(new GridBagLayout()); content.add(new JButton("durationPN"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 2, 0, 10), 0, 0)); content.add(new JButton("viewPN"), new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, ...

92. XP component in Java?    coderanch.com

Hello all, For a upcoming project i'm doing research for a easy familair user interface. My users know how to use windows xp, so i took a look at some screenshots and found a nice idea. The following image illustrates the idea: http://www.microsoft.com/presspass/newsroom/winxp/images/img010.jpg As you can see the main program objects are located at the right (in the big part of ...

93. Different UIs for different components    coderanch.com

Hello I have managed to change the look and feel for a whole application using the UImanager. I have a JfileChooser in the application this I want to use the windows LAF. How can I set the win LAF just for this one component, I have tried the getUI and setUI but have no joy.. Is there a simple method to ...

94. Self controlling component    coderanch.com

Hi Con, If you can see the circles drawn by the paint routine then I guess your point must have a size big enough to accept a mouse listener. Maybe you could also implement MouseMotionListener and see if that can detect your mouse. I would not have chosen Point as the class name since there is already a Point class in ...

95. swing components gui    coderanch.com

96. constructing a component (beginner)    coderanch.com

Hi all, I'm beginning to learn Swing/AWT, so my question might be a bit silly: We've got the task to write a program which plays the game Tower of Hanoi. I started with the smallest thing, the disc that will be put on one of the three towers. This slice should be a rectangle with rounded edges. So there is this ...

97. Problem when create many new components    coderanch.com

98. Component reference    coderanch.com

99. Inter-Component communication in Swing    coderanch.com

What is the preferred method of communicating across JFrames (or JPanels and JDialogs, for that matter) in Swing? For example, if I have two frames, and one has a few buttons that need to initiate actions in the other frame, what's the preferred way of sending the target frame a message? I could create both frames as Singletons and simply create ...

100. Reshaping swing components    coderanch.com