Component 2 « Component « Java Swing Q&A





1. adding GUI components to parent components    coderanch.com

I'm working on my GUI to which I will add functionality later. Using about 4 different examples, the API, and tuts from sun. For the life of me I can't figure out how to add components from another class. I want a frame as a class and add a menu bar, and other components inside the frame, but want to work ...

2. Gui Component    coderanch.com

3. irregular shaped components    coderanch.com

4. Missing Components    coderanch.com

I converted a panel to a frame to make the flow of the program a little better. But, only the first panel and the last label of this class are now showing on the frame (the other panel is not). What am I missing? I have some things being put in panels and some things placed directly on screen. The last ...

6. unKnown component !!!!    coderanch.com

i need to add a component to my gui ********** /\ *text *| | ********** \/ do you know this component?? ..i can click on the arrows so that the value of the text increase or decrease(usually used with number to increase there values) ,,,i dont know how to make this component ,,what listener does it take and so on.please help ...

7. Component not working at Mac M/C    coderanch.com

On MAC the Browser is safari 2.0 and JRE version 1.4.2 The entire code is below: import java.io.*; import java.util.*; import java.awt.*; import java.awt.datatransfer.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; class NewUploadDemo extends JPanel { JPanel upperPanel, lowerPanel; NewUploadDemo() { super(new BorderLayout()); JLabel label=new JLabel(new ImageIcon("zone1.jpg")); label.setTransferHandler(new MyFileTransferHandler()); JPanel fcPanel = new JPanel(new BorderLayout()); fcPanel.add(label, BorderLayout.CENTER); JButton clear = new JButton("Clear ...

8. change component orientation    coderanch.com

Hi! I am trying to write code for a Calculator.In its GUI I want the textfield that accepts input as well as displays result to be oriented from right to left. I m not able to do this? setComponenetOrientation method of component class is not working. No error given. But no change in the orientation.Can u help me our? Warm Regards, ...





10. How to set margins between components    coderanch.com

11. component.removeAll() that doesnt work    coderanch.com

hi i have this problem, once again i have a splitpane that has 2 scrollpanes on the left and on the right.the left scrollpane contains a tree and the right sp contains a jpanel that displays various components depending on the node selected. the problem is , when selected , everything seems to work fine until the retrieval of the gui ...

12. Conversion of AccessibleComponent to Component    coderanch.com

Hi All, The objective is to obtain the parent as a Component for a JMenuItem. For ex: I have a menu which has menuItems added to it and also a submenu added to it. I should be able to get the parent component associated to the sub menu. Iam able to retrieve the name of the parent for a sub-menu but ...

13. Getting a Component to show?    coderanch.com

14. inactivate all components    coderanch.com

15. Swing Components    coderanch.com

Swing components have their own "look-and-feel," which is derived from Java. They make little use of the underlying OS, which is called "lightweight." Some AWT classes (eg Color) don't have a "look-and-feel" as such, and are therefore not duplicated in Swing. Their inheritance varies, but you will usually find a Swing class has a superclass in AWt somewhere. Those classes in ...

16. swing components problem    coderanch.com

pls i need help:am try to develop an application that handle balanced diet using various food list and price list.want them to be in a table such that once a food option is selected it display the price and the application should ask for amount you want to spend before the food option comes up. pls,advice on how to using the ...





17. Components that I could link to my app    coderanch.com

Hi, in my previous work I saw my officemates link some free Swing components which actually are jar files made by other people. I think they're very cool. For example, collapsing menus(but it's more than that). Do you know of such sites? I didn't have the change to try it since I was doing(and was most exposed) to web apps. Thanks! ...

18. About AWT Components    coderanch.com

Here's the best definition I've run across... Heavy weight components (AWT) are known to the operating system. They consist of a "peer", which is the implementation of the component in the operating system, and a Java object which manages the peer. Light weight components (Swing) are drawn entirely within Java; the operating system is not aware of or responsible for their ...

20. How to prevent AWT component flicker?    coderanch.com

My main Frame has two Panels added to it. Each of the Panels contain various components and custom components. Question is: how can I make it so the two Panels are added to the Frame (or are made visible) only after each of the Panels' components are fully rendered. I just need new screens to be shown cleanly, without flickering! (Am ...

21. how come swing components are lightweighted !    coderanch.com

HI to all Ranchers , While reading swings i got notice one thing almost all swing components have extended from awt components , while awt components are heavyweight how come swing components( most of them except top level compopnent ) are lightweight , what it is doing while extending that it is becoming lightweight.Can you please explain me this descriptively.

22. Modified Flag of a swing component    coderanch.com

23. in flow lay out how can i force to add component on next line?    coderanch.com

You can't. ok, nothing is impossible and there are some creative ways (read: "hacks") I can think of that might force FlowLayout to do something like this. But the easiest way to achieve the effect you want is to have two nested Containers within your Container. It would look something like this: JPanel nested1 = new JPanel(); // FlowLayout nested1.add(new JButton("blah")); ...

24. Not able to change Background color of a component    coderanch.com

Sorry forgot to wrap it with CODE on the first post. import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.awt.geom.*; public class Tanks extends JApplet { public static final int WIDTH = 400; public static final int HEIGHT = 400; private JButton button1; private PaintSurface currentSurface = new PaintSurface(); public Tanks() { this.add(currentSurface,BorderLayout.CENTER); ButtonListener b1 = new ButtonListener(); JPanel panel ...

25. laying components    coderanch.com

26. What Swing component to use    coderanch.com

27. Placing components with Swing    coderanch.com

Hello, A few months ago I started on Java, and now as a test I'm trying to create interfaces with Swing, the problem is that I can't seem to succeed in placing the widgets on the appropriate position. I've spend hours to get it to work, but either the widgets are partially displayed on the screen or they've become huge. Below ...

28. My own Component?    coderanch.com

Hi all, i want to make a class that has a visual representation on the screen and reacts to mouse-clicks or other events. I DONT want to interhit it from a JComponent, Button or something. I want to build it from the ground up, which will also teach me a bit more about Java (classes and interfaces i havent seen so ...

29. swing gui customizable components    coderanch.com

Ours is a typical three tier client server application, we are using a lot of modified JAVA gui components, where we had to spend lot of hours solving many issues, many of them related to compliance with java versions. Now we are looking for readymade or open source alternatives to integrate into our software so as to avoid this type of ...

31. doubt with this component    coderanch.com

33. How to open Swing components client side    coderanch.com

Sorry, I forgot about this post. Here is what I ended up doing. I basically ditched the whole swing thing and just sent a byte stream to the HttpServletResponse object, which a browser understands as a file download. Here is the code (java 5 compliant) public void saveFile(List fileEntries) { FacesContext context = null; HttpServletResponse response; OutputStream outStream = null; byte[] ...

34. No methods executing on component    coderanch.com

I have a class I created called picPanel that extends JPanel. Basically this class has a bufferedImage variable and in the paint event, it draws this image scaled down proportionally to fit inside the visible area of panel. The class contains only two methods: the constructor and paint. I added a mouseListener to the panel from it's container's class to open ...

35. What swing component should I use    coderanch.com

36. component help...    coderanch.com

hi.. Can anyone pleases help me with the following scenario.. well i am new to swings... i have to develop a window such that i can display some geometrical shape on click of one button and when i click another button the some geometrical transformation should be applied to the same figure and it should be displayed... how and where do ...

37. Component    coderanch.com

So you need a panel of over 2147483647 pixels, just for showing a wave form. I'll tell you this: unless you want to create your own component system you can forget that approach, since Component uses ints for its size. No way you can change that. Now I was thinking you could solve this problem by just adding a JScrollBar, listening ...

38. Q.Combine Swing components to simplify    coderanch.com

final Text textField = new Text( "Full Name", "John Doe"); ... public class Text extends JTextField { JLabel title; JPanel textPanel; Text( String label, String initialValue ){ super( initialValue ); title = new JLabel( label ); textPanel = new JPanel( new GridLayout(2,0) ); textPanel.add( title ); textPanel.add( this ); } JPanel getPanel(){return textPanel;} }

39. returning to the previous page with cleared GUI components    coderanch.com

Hi every one.I have page A which has some radio buttons. I should select one and click submit. Page B opens which has some details to be entered. After which i submit and should come bak to page A. But my problem is after i come back, the radio button which i selected is still SELECTED which i dont want to. ...

40. Problems with swing components    coderanch.com

42. GUI - Components    coderanch.com

43. Swing components not shown    coderanch.com

I have created a JFrame in which a JPanel and some JLabel,JPasswordField and JButton is added when I run my program my App does not show some of the components,when I minimize it and again restore it then it shows all the components and OK. My program is: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class UserInterface implements Runnable ...

44. getting rid of edges on round component    coderanch.com

45. swing components arrangement    coderanch.com

hi i have a jpanel in which i added a menubar and below it i have added some login related components. but when i make use of this panel in another class using jsplitpane my menubar component is displaying beside the login components.its not showing above the components. how to show menubar above the login components in the splitpane.

46. combining components    coderanch.com

Please use the code tags and don't disable BB code; your code is hard enough to read even with the indentation. I don't quite understand the question, I am afraid. Your two classes appear to do different things. You can add any number of components in a Swing class constructor, but you can't add Frames to Frames (at least I think ...

47. Component init best practices    coderanch.com

I'm not sure if the title is mis-leading, but I had a discussion with a buddy of mine the other day about properly setting up a given component. I have always started panels or components with all the super calls first ( like setsize,setvisible and all things related in that manner) and than after I would add all my necessary buttons,panels,etc,etc.. ...

48. Using synth only for certain components?    coderanch.com

Hello, is there any way to use synth just for certain components so that it doesn't blank out every component that isn't specified in the xml file? And if there isn't, is there another way of creating JButtons that use images depending on their current state (pressed or released)? Furthermore, are there any good synth articles / online resources? I read ...

49. missing components    coderanch.com

hate to bother you again, but this is someone else's code and i haven't done this in awhile. the JCheckbox's in the first group are missing. thanks in advance. import java.awt.Container; import java.awt.FlowLayout; import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import java.awt.event.*; public class TryWindow extends JFrame{ static JFrame aWindow = new JFrame("This is the Window ...

50. Compositing every component on Component?    coderanch.com

What i've got so far is a component which is set on a layeredPane, this component fades in and out when activated or triggered. The problem is that I can't figure out how to alter the composite of each component, the only thing which is being affected is the background ( which fades in and out as it should ). The ...

51. Generating swing components on fly slow    coderanch.com

Hello, I have a Java swing application that communicates with a server through HTTP client/server requests. the server sends me an html stream. i parse this html response and convert it to swing components. it is mapping html input fields to swing components. The solution is working but the performance is not satisfactory: -parsing the html form took 47 secs -generating ...

53. Angles on components?    coderanch.com

54. Please suggest me some swing component which should close automatically    coderanch.com

After clicking on a button it should get a popup window which has some text in it and after 2-3 secs it should close automatically. It should not contain any buttons in it. kindly suggest me some swing component which satisfies these requirements. I tried JPopup, but i cannot close it automatically. So it is not satisfying my requirement.

55. open acrobat reader in swing component    coderanch.com

57. Component Banners    coderanch.com

58. NetBeans manually added component does not appear    coderanch.com

hi all, When I programmatically add a component such as a list or button to a frame that I have used code to build then it will appear fine but I have an issue where the NetBeans frame that I have created and which is full of the NetBeans generated code, does not seem to respect the component that I add ...

60. ImagePanel with components    coderanch.com

I have created a panel that displays a background image as below:- public class ImagePanel extends JPanel { private static final long serialVersionUID = 694501043112892479L; private Image img; public ImagePanel(String img) { this(new ImageIcon(img).getImage()); } public ImagePanel(Image img) { this.img = img; Dimension size = new Dimension(img.getWidth(null), img.getHeight(null)); setPreferredSize(size); setMinimumSize(size); setMaximumSize(size); setSize(size); setLayout(null); } public void paintComponent(Graphics g) { g.drawImage(img, 0, ...

61. Component not being garbage collected    coderanch.com

Hello, I am working with an existing custom component that updates itself periodically. The component resides in its own JFrame which can be launched from my main application. The problem I'm having is that the component is not being garbage collected after its window has been closed. I've posted some simple sample code below. This is not the actual code, but ...

62. Question regarding Swing component.    coderanch.com

Hi guys, Its been 3 year since i was in touch with JAVA. Many things have changed since then. I know its hard for me to get in track soon. I hope you guys will help me find the exact track. To begin with i have downloaded netbean 6.8 IDE. I was going through some of training materials provided on netbean's ...

63. listening to disposed child components    coderanch.com

hi there. i am working on some frames when i got up to this issue... i have a child panel added to a frame through a button... the child panel added has input fields and a save button for saving the input and disposing the child panel... question is, how can i dispose the frame at the same time with the ...

64. Allignment Of Swing Component    coderanch.com

65. Why does this component appear shrunken ?    coderanch.com

Hi all. I have some components on a panel and then add this panel to a container and then have my frame displayed as the result of an ActionListener on a button. Why is it that my frame is displayed but is miniscule and looks minimised, only showing the title bar? This is really annoying. setVisible is set to true and ...

68. Need strategy for developing swing component.    coderanch.com

Hello All, I have to develop a dialog component with tabs in it. On each tab there are several groups. In each group there are 3 rows. Each row have several components like textbox, combobox, radio buttons. Please let me know what are the best strategies to develop above UI window. How to lay and group the components on window? Please ...

69. Why aren't my components wrapping?    coderanch.com

I understand that FlowLayout is the default layout manager for JPanels. So why isn't my text area wrapping in this window? Thanks for any suggestions... import java.awt.BorderLayout; import java.awt.Color; import javax.swing.*; public class LayoutExperiment { public static void main(String[] args) { new LayoutExperiment().buildGui(); } void buildGui(){ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception e) {System.out.println("Could not set look and feel"); } JFrame ...

70. Very Confusing Issue with adding Components    coderanch.com

Hey guys, I'm working on this small program. Just recently I started working on the GUI aspect of it. I have no idea what's going on, I'm using eclipse and it will randomly add the components correctly and sometimes it won't even add them. So I decided to make it add the panels and the JButtons in the methods that they ...

72. Component's showing issues!    coderanch.com

Hey guys, I'm having issues with this program that I started making. Basically I have a panel (located on the west side), that is going to hold components to alter what is being painted on the right (just the plain frame). I'm having issues with adding the components to the panel. I already have a JComboBox added to it (no issues ...

73. Swing Components Declared in an Interface    coderanch.com

Hey guys; I have trolled this forum a bunch. Love it. First time posting though. I have an interface that I am using for some Frames that I am using. I declare the components (Jbuttons, Jlabels etc) in the interface. Works great for the first Class that implements the interface; however the 2nd class that implements the interface retains the values ...

74. component classes    coderanch.com

75. Reuse component instances vs creating new ones.    coderanch.com

Hello, I've got a question regarding Components. Let's assume you've got a cardlayout with panels in it. In fact it is a wizard like like structure. Now this wizard has many components per card and it is reused very often to display and edit various data. Question now would be if it is better to reuse already created instances of those ...

76. Aspect ratio of Components    coderanch.com

I would take the longest side of the original component and try to fit it inside the shortest side of the new, resized, area (you need to take a measurement of your original component's size first, before it is resized.). Example: (shortest side of new) / (longest side of old) = multiplier for both of the component's dimensions. Or, as applied, ...

77. How to make components stick togather    coderanch.com

78. Problem In Swing Components    java-forums.org

I have no. of problems related to Swing. If you have the solution do reply to me. MY problems are: 1) JTABLE: I want to decide the no. of rows at runtime. Actually I need to show the database entries via Table. And these entries can be any no. So How I can Do this???? 2) JTABLE: Second problem with JTABLE ...

79. arrangement of components    java-forums.org

hi i am trying to add some components to a jframe. but as its layout is flowlayout by default its arranging one by one. i want to know by using which layout i can arrange components wherever i like. please help me out. for example i have login page i want to arrange the labels,textfields in the centre of the page ...

80. need guidance in component placement    java-forums.org

screenshots I've posted on this before, got sidetracked. I created an rpn calculator as an exercise to learn GUI, and it was my first attempt at using swing. What I am finding is that there is a great deal of ambiguity in component placement as opposed to what I am used to coding using the tools of the evil empire (visual ...

81. the component does not show    java-forums.org

82. Swing components not working    java-forums.org

I am trying to implement an interface which responds to mouseclick and with buttons Circle, Rectangle and Quit. On pressing Circle a Circle is drawn on the frame and so on. I cant get this code to work. Your help would be much appreciated. Java Code: import java.awt.*; import java.awt.event.*; import java.awt.event.ActionListener; import java.util.EventListener; import javax.swing.*; interface ActionListener extends EventListener{ public ...

83. Components not showing    java-forums.org

import javax.swing.*; import java.awt.*; public class core { private JTabbedPane tab = new JTabbedPane(); private Component[] tabComponents = {new start(), new quests()}; private String[] tabCaptions = {"Start", "Quests"}; public static void main(String[] args) { core Engine = new core(); } public core(){ JFrame window = new JFrame("Window"); for(int i = 0; i <= tabComponents.length - 1; i++) { tab.addTab(tabCaptions[i], new JScrollPane(tabComponents[i])); ...

84. Re: How i create this Gui program? Or I use what component for this GUI ?    java-forums.org

Are you learning about Turing machines or GUIs? I ask because the task of building a graphical editor is so much harder than exploring Turing machines; and not useful for learning about Turing machines. If you are doing a graphical editor, the first step is to draw some diagrams illustrating what the user will see. In general, the GUI tool basis ...

85. Component to use ?    java-forums.org

Hi all, I'm a beginner JAVA developer.....I have a JFrame and I need to display a list of names and email contact(two collums...maybe more) on it........is there an specific component to display my list of names please ? Need to say that these names and emails need to be read from database. This list needs to be refreshed..... JList would be ...

86. placing the components    java-forums.org

hi guys, I needed to know how to place a component (say a button ) wherever i want in side the container with customized size. I am actually trying to write a simple calculator gui.I tried to use GridBagLayout with constraints but,...i guess i am missing somewhere...its not working. PLease help. thank you

87. porblem with components    java-forums.org

Java Code: import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.*; public class TextConversion extends JFrame { private static final long serialVersionUID = 1L; private JRadioButton convertFrom[] = {new JRadioButton("Text", true), new JRadioButton("Binary"), new JRadioButton("Hexa-Decimal")}; private JRadioButton convertTo[] = {new JRadioButton("Text"), new JRadioButton("Binary", true), new JRadioButton("Hexa-Decimal")}; private JTextArea jtaFrom = new JTextArea(); private JTextArea jtaTo = new JTextArea(); private JButton jbtConvert = ...

88. Different components in an AWT list    java-forums.org

Hi All I am trying to do some enhancements to a legacy AWT application and basically I need to create a list of addable/removable rows where each row has a button in column 1, 2 radio-buttons/check-boxes in col2, 2 text boxes in cols 3&4 and then a drop down list in col 5 and then a button again in col 6. ...

89. swing component    java-forums.org

90. Calling url from java component    java-forums.org

Hi, I have a Joption pane, in which i am accepting values from user, i need to call an url by passing those values to it, and the url will do the authentication and return me true or false, i need to accept that flag and do check on it. I have no idea how to do this, can anybody help???? ...

91. Moving Components Around    java-forums.org

I used to be a VisualBASIC programmer and it was pretty easy to move a command button around. All you had to do was specify a left and a top value in the code. Ex: cmdButton.Left = 50 cmdButton.Top = 100 Is there a way to do this with AWT buttons & other components as well? P.S. Sorry for defiling this ...

93. Component Location Lag    java-forums.org

I'm trying to create a program in which panels/components start small and (visually) expand to their actual size once their parent has done the same thing. Therefore I need the actual location & dimensions of components. The thing I run into is that with any component you add, it takes a little while to get the correct location of the component ...

95. How to implement a push-pin component    java-forums.org

96. These components should at least TRY to look decent    java-forums.org

I've been rassling (kind of like wrestling, but with more "attitude") with getting my form to look more like Miss Universe than Miss Piggy. I'm to the point where I'd settle with just getting the JTextFields and JTextAreas to back off the edges of the form a little. The JButtons and JLabels are offset to the right a little bit, but ...

97. Build a ImageButton Component    java-forums.org

Are you sure that you're accessing the file correctly? Is that going where you think it's going? Have you tried using a full path instead? Why don't you just pass that icon into the super constructor? PS- You should probably use standard naming conventions- classes start with a capital letter, variables with a lowercase letter.

98. Get component from other program .    java-forums.org

Hi everybody !! I'm doing a program which similar to Windows Explorer . My problem is cut file . cut file in a program ( I done ) and cut file in two program running . I use cut , copy, paste of jlist . I dont' know the way to get source component to delete it ( cut file ) ...

99. Where is it best to declare swing components?    java-forums.org

Java Code: import javax.swing.*; class MyTest { // If another method (outside the constructor) needs to // see/access these then they will need to be declared // here as member variables in class scope. // Otherwise it is considered good practive to hide them // as local variables. The less you expose the better. JLabel alabel; JCheckBox acheckbox; MyTest() { // ...

100. Swing Components Placing    java-forums.org