GUI components always make me confuse!

Hi all!
Firstly, The problem I 've just encountered is that: I 'd like to add a JLabel with an icon onto the contentPane of the JFrame, But the Icon canot be drawn. Tell me why?
This is the code:
import javax.swing.*;
import java.awt.*;
class TestLabel extends JFrame {
     public TestLabel(String title) {
          super(title);
          ImageIcon icon = new ImageIcon(getToolkit().getImage("./images/chat.bmp"));
          JLabel lb = new JLabel( icon);
          this.getContentPane ().add(lb, BorderLayout.CENTER);
          this.setSize(300, 300);
          this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          this.show();
     public static void main(String [] args) {
          new TestLabel("Test Label with Icon");
Secondly: I would like to make an introduction for my application. So I creat an introduce canvas and then add some text and an Image on to it. But the Image can't not be displayed anyway. I'm going to be crazy with every thing!!!. Help me as soon as posible. This is the code of the Canvas ( JPanel). To test how things are, would you please creat a JFrame and add it on to the contentpane of the frame. Thanks!
package caro;
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
* <p>Title: Caro Game</p>
* <p>Description: Two player caro game, playing through a Local Area Network</p>
* <p>Copyright: Copyright (c) 2004 Group 8 - Tin 4 - K46</p>
* <p>Company: FIT - HUT</p>
* @author PhuongVM, AnhLT, KienNT, AnhNT
* @version 1.0
class IntroduceCanvas extends JPanel {
private Color pink = new Color(255, 200, 200);
private Color blue = new Color(150, 200, 255);
private int w, h;
private int edge = 16;
private static final String title = "Caro Game";
private static final String name = "Version 1.0-2004";
private static final String foot = "Group 8 - Tin 4 - K46";
private static final String subFoot = "FIT - HUT";
private Font namefont, titlefont, footfont;
Image hutImg;
public IntroduceCanvas() {
titlefont = new Font("SansSerif", Font.BOLD, 58);
namefont = new Font("SansSerif", Font.BOLD, 18);
footfont = new Font("SansSerif", Font.BOLD, 12);
hutImg = getToolkit().getImage("./images/intro.jpg");
// draw the specify String s with specify font, color and position
private void d(Graphics g, String s, Color c, Font f, int y, int off) {
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
g.setColor(c);
g.drawString(s, (w - fm.stringWidth(s)) / 2 + off, y + off);
//Overide the paint method from the parent
public void paintComponent(Graphics g) {
//get the size of the window.
Dimension d = getSize();
w = d.width;
h = d.height;
//set the back ground color to CYAN
g.setColor(Color.CYAN);
g.fillRect(0, 0, w, h);
// draw a blue 3D rectangle to put introduction
g.setColor(blue);
g.fill3DRect(edge, edge, w - 2 * edge, h - 2 * edge, true);
//draw information and logo on to the rectangle
g.clearRect(w/2 - 100/2, edge, 100, 140);
g.drawImage(hutImg, w/2 - 100/2, edge, 100, 140, this);
d(g, title, Color.black, titlefont, h / 2, 1);
d(g, title, Color.white, titlefont, h / 2, -1);
d(g, title, Color.pink, titlefont, h /2 , 0);
d(g, name, Color.black, namefont, h * 3 / 4, 0);
d(g, foot, Color.black, footfont, h * 9/11, 0);
d(g, subFoot, Color.black, footfont, h * 7/8, 0);
Thanks!!

Hi all!
Firstly, The problem I 've just encountered is that: I 'd like to add a JLabel with an icon onto the contentPane of the JFrame, But the Icon canot be drawn. Tell me why?
This is the code:
import javax.swing.*;
import java.awt.*;
class TestLabel extends JFrame {
public TestLabel(String title) {
super(title);
ImageIcon icon = new ImageIcon(getToolkit().getImage("./images/chat.bmp"));
JLabel lb = new JLabel( icon);
this.getContentPane ().add(lb, BorderLayout.CENTER);
this.setSize(300, 300);
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
this.show();
public static void main(String [] args) {
new TestLabel("Test Label with Icon");
Secondly: I would like to make an introduction for my application. So I creat an introduce canvas and then add some text and an Image on to it. But the Image can't not be displayed anyway. I'm going to be crazy with every thing!!!. Help me as soon as posible. This is the code of the Canvas ( JPanel). To test how things are, would you please creat a JFrame and add it on to the contentpane of the frame. Thanks!
package caro;
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
* <p>Title: Caro Game</p>
* <p>Description: Two player caro game, playing through a Local Area Network</p>
* <p>Copyright: Copyright (c) 2004 Group 8 - Tin 4 - K46</p>
* <p>Company: FIT - HUT</p>
* @author PhuongVM, AnhLT, KienNT, AnhNT
* @version 1.0
class IntroduceCanvas extends JPanel {
  private Color pink = new Color(255, 200, 200);
  private Color blue = new Color(150, 200, 255);
  private int w, h;
  private int edge = 16;
  private static final String title = "Caro Game";
  private static final String name = "Version 1.0-2004";
  private static final String foot = "Group 8 - Tin 4 - K46";
  private static final String subFoot = "FIT - HUT";
  private Font namefont, titlefont, footfont;
  Image hutImg;
  public IntroduceCanvas() {
    titlefont = new Font("SansSerif", Font.BOLD, 58);
    namefont = new Font("SansSerif", Font.BOLD, 18);
    footfont = new Font("SansSerif", Font.BOLD, 12);
    hutImg = getToolkit().getImage("./images/intro.jpg");
// draw the specify String s with specify font, color and position
  private void d(Graphics g, String s, Color c, Font f, int y, int off) {
    g.setFont(f);
    FontMetrics fm = g.getFontMetrics();
    g.setColor(c);
    g.drawString(s, (w - fm.stringWidth(s)) / 2 + off, y + off);
//Overide the paint method from the parent
  public void paintComponent(Graphics g) {
//get the size of the window.
    Dimension d = getSize();
    w = d.width;
    h = d.height;
  //set the back ground color to CYAN
    g.setColor(Color.CYAN);
    g.fillRect(0, 0, w, h);
// draw a blue 3D rectangle to put introduction
    g.setColor(blue);
    g.fill3DRect(edge, edge, w - 2 * edge, h - 2 * edge, true);
//draw information and logo on to the rectangle
    g.clearRect(w/2 - 100/2, edge, 100, 140);
    g.drawImage(hutImg, w/2 - 100/2, edge, 100, 140, this);
    d(g, title, Color.black, titlefont, h / 2, 1);
    d(g, title, Color.white, titlefont, h / 2, -1);
    d(g, title, Color.pink, titlefont, h /2 , 0);
    d(g, name, Color.black, namefont, h * 3 / 4, 0);
    d(g, foot, Color.black, footfont, h * 9/11, 0);
    d(g, subFoot, Color.black, footfont, h * 7/8, 0);
//??????????????????????????????????????????????????????????????????????????????Sorry! in the last post I don't know that our forum suport the  tag.
Thanks for informing me!
Thanks!

Similar Messages

  • Can I make a class holding multiple GUI components and make it visible?

    I am implementing an MDI where the different JInternalFrames are filled with a JPanel with components. Since the contents of my screen is dynamically generated, each screen can have multiple Jlabels, JTextFields, etc.
    So I thought, I make a class containing the representation of one row of GUI components on my screen, which is: one JLAbel and 4 JTextFields.
    Here is the code which adds the components to the panel:
    // create panel
    JPanel qpanel = new JPanel();
    qpanel.setLayout(new BoxLayout(qpanel, BoxLayout.Y_AXIS));
    qpanel.add(Box.createVerticalStrut(5));
    //add rows to panel
    for( int i = 0; i < nrRows; i++)
    // qpanel.add(new JLabel("Hello how are you"));
    qpanel.add(new ProcessRow("hello","how","are","you"));
    // add panel to scrollpanel
    this.getViewport().add(qpanel);
    Here is the ProcessRow class:
    public class ProcessRow extends JComponent
    public JLabel rowLabel = null;
    public JTextField myCost = null;
    public JTextField saratogaCost = null;
    public JTextField sapCost = null;
    public JTextField totalCost = null;
    public ProcessRow() {
    super();
    public ProcessRow(String LABEL,
    String DEFAULTCOST,
    String SARATOGACOST,
    String SAPCOST){
    super();
    JLabel rowLabel = new JLabel(LABEL);
    JTextField myCost = new JTextField(DEFAULTCOST, 6);
    JTextField saratogaCost = new JTextField(SARATOGACOST, 6);
    JTextField sapCost = new JTextField(SAPCOST, 6);
    JTextField totalCost = new JTextField(6);
    If I add the label "Hello how are you" directly to the panel, it shows fine but if I use my ProcessRow class, nothing shows.
    How can I make it visible and if not,
    how can I dynamically keep adding all these GUI components without loosing control over the components.
    Thanks,
    Johnny

    Modify your ProcessRow:
    (1) First extends JPanel ( Container, not Component)
    (2) Add Label and TextField to the container
    public class ProcessRow extends JPanel
    public JLabel rowLabel = null;
    public JTextField myCost = null;
    public JTextField saratogaCost = null;
    public JTextField sapCost = null;
    public JTextField totalCost = null;
    public ProcessRow() {
    super();
    public ProcessRow(String LABEL,
    String DEFAULTCOST,
    String SARATOGACOST,
    String SAPCOST){
    super();
    JLabel rowLabel = new JLabel(LABEL);
    JTextField myCost = new JTextField(DEFAULTCOST, 6);
    JTextField saratogaCost = new JTextField(SARATOGACOST, 6);
    JTextField sapCost = new JTextField(SAPCOST, 6);
    JTextField totalCost = new JTextField(6);
    // add everything to the container.
    add(rowLabel);
    add(myCost);
    add(sapCost);
    add(totalCost);
    }

  • Event handling in custom Non-GUI components

    I have a class which needs to fire events to outside. These events maybe captured by several objects in outside world. How can I achieve this? In so many places I read, they always refer to AWT and Swing whereas my objects don't have any dependency to GUI.
    I simply need to fire an event from an object, and capture that event from other objects by registering event handlers.
    I have experience in .Net programming with Events and Delegates (function pointers), but cannot find something like that in Java. All it offers is various kinds of GUI related Listeners where I can't find a proper help resource using them in Non-GUI components.

    ravinsp wrote:
    I have a class which needs to fire events to outside. These events maybe captured by several objects in outside world. How can I achieve this? In so many places I read, they always refer to AWT and Swing whereas my objects don't have any dependency to GUI.
    I simply need to fire an event from an object, and capture that event from other objects by registering event handlers.
    I have experience in .Net programming with Events and Delegates (function pointers), but cannot find something like that in Java. All it offers is various kinds of GUI related Listeners where I can't find a proper help resource using them in Non-GUI components.If you want to make your own Listener make your Listener. Create an event class that encapsulates the event as you want, create a listener interface that has a method like handleMyEvent(MyEvent me) and then add addMyEventListener, removeMyEventListener methods to your original class. Add a List<MyEvent> to your original class and add the listeners to it and then when events happen
    MyEvent someEvent = new MyEvent();
    for(MyEventListener mel : eventlisteners)
       mel.handleMyEvent(someEvent);

  • Clearing GUI components displayed in a JFrame window

    Hi Programmers and Developers,
    Good day to y'all!
    My application displays a number of GUI components on the screen. I intend to design a JButton that can clear the window of all these GUI components when it is clicked. Is there a method that can erase already displayed GUI's or is their a technique i can implement to achieve this??
    Many Thanks and Merry Xmas!

    You clear components the in much the same way that you added them
    See Container.remove(Component)
    You will of course want to call validate(); repaint() after removing a component.
    Make a small dummy app to test this out.
    You might also want to look at tjacobs.ui.util.ComponentMapper (which you can find in TUS). It may make finding the components you want to remove easier

  • Adding custom GUI components to a panel

    <sorry about the 'Hello All' subject in the previous post>
    I am creating a Backgammon game for my JAVA programming class. I would like to design a board and have certain checker pieces that can be dragged around on the board. In the course I am taking, I still have not been able to understand how a GUI interface has GUI components that is "custom built" like my checker class. My checker class below draws a picture of a checker on a JPanel. I want it to exist inside a JPanel(that has a board painted in it) with 30 checkers that can be moved around. Any feedback would be appreciated including helpful packages, classes, trails, etc.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.util.Random;
    import javax.swing.JPanel;
    import java.awt.BasicStroke;
    // Checker.java - This will draw the checkers used in the game
    public class Checker extends JPanel
    private Color checker_color; // color of checker
    private int abs_pos;
    private int player; // player 1 or player 2
    Checker(Color check_color, int pos, int plyr)
         checker_color = check_color;
         abs_pos = pos;
         player = plyr;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2d = (Graphics2D) g; // cast g to Graphics2D
         this.setBackground(Color.WHITE);
         // make a circle
         g2d.setColor(checker_color);
         g2d.setStroke(new BasicStroke(1.0f));
         g2d.fillOval(47,47, 35, 35);
         g2d.setColor(Color.BLACK);
         g2d.setStroke(new BasicStroke(2.0f));
         g2d.drawOval(47, 47, 35, 35);
    public int getPlayer(){
         return player;
    public Color getCheckerColor(){
         return checker_color;
    public int getPosition(){
         return abs_pos;
    public void setPosition(int pos){
         abs_pos = pos;
    }

    Um... pretty much the way you are doing it in the code you already posted. What is the problem? Not that there's not problems....
    1) setBackground called in paintComponent doesn't do much. Just set the background outside paint and super.paintComponent() will fill the BG color if the component isn't opaque.
    2) a checker, I would expect, would be opaque, actually.
    3) the oval size you draw would probably be better off being based on the size of the component (getSize()) instead, that way it scales easily.
    But other then that, you are doing it right. You probably need to set the size and location of each checker object explicitly, since most likely it's being used in a container with a null layout.

  • Positioning of GUI components

    a question for the java veterans out there,
    i am a student of programming and i wish to learn how to place/position GUI components in java by hard coding it. Is there any trick/technique that this could be done easily? I don't want to rely on netbeans's GUI maker to make my programs's GUI for the rest of my life.
    any help is appreciated.
    (please don't make it quite complicated. ^_^)

    Hi,
    The link to the tutorial you requested is [Laying out Components within a Container|http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html], more specific [Doing Without a Layout Manager (Absolute Positioning)|http://java.sun.com/docs/books/tutorial/uiswing/layout/none.html]. But I would suggest you start to learn using the default layout managers first before you venture out into the wild lands named 'absolute positioning'. The layout mangers supplied by Sun (and made by a big bunch of seasoned Sun Java Programmers) help you when something happens in your screen, like resizing the window. If you use absolute positioning you have to handle such cases yourself.
    Abel

  • GUI components not clearing from JDialog closing

    Greetings,
    I have developed an application which works on several different computers with several different JVMs, but which does not operate as anticipated on my (new) tablet PC. It leaves GUI components on the main JFrame from various Jdialog boxes (after closing them) that I throw at the user when the program starts.
    I also have a username/password prompt at the beginning which is another JFrame that doesn't appear correctly. The input areas do not appear with a white background and the Username and Password JLabels have echoed themselves into that area.
    I'm guessing this is Windows XP, Tablet Edition issue. I'd like to know if anyone else has experienced anything similar?
    FYI, this programs works quite well on Windows 98, Windows XP Home and Professtional, Windows 2000, and Windows ME.
    Any help would be most appreciated.
    Regards

    Hi all,
    I am trying to develop a Java application on the Tablet PC. I am new to this platform and could not find much information about Java related Tablet PC development .So I am posting this question here
    Details
    I have developed a Swing Application in Java (J2SDK 1.4.2) for a Client, which currently runs on Windows XP on the Standard Laptop. The application uses the following
    1) Menus
    2) Panels
    3) Dialogs
    It consists of an entry form, which is saved as an XML file on the user's computer. Also it uses an Access Database.
    The other thing that the application uses is a Signature Capture Device to capture a user's signature
    I would like to move this application to the Tablet PC.
    I have the following questions
    1) What SDK do I use for the Tablet PC? Also what version of Java web start and Run time?
    2) What kind of changes do I need to make in my application?
    3) Can I make use of the "Ink" feature, which is provided with a Tablet PC in Java?
    4) Where can I find user samples if any for Java Tablet PC development?
    BTW I am using Toshiba Prot�g� 3500 for my project.
    Thanks,
    Raja

  • GUI Components & Graphical drawings

    Hi,
    I�m new to Swing (haven�t done much GUI since Motif!) and I�m a little confused about the relationship between GUI components and �drawn� graphics.
    In my application I have two JPanels � an upper and a lower � that display two views of the same data,
    In both of these JPanels I do my graph drawing using g.drawXXX() or g.fillXXX().
    I label the displays using g.drawString()
    However, I want to add some checkboxes to one of the JPanel displays that will trigger actions in the other JPanel. I�m not sure how to get the checkboxes to show up in the right place. It feels like the GUI components work in Layout mode whereas the graphics are in x,y coordinate space.
    I see that JComponent has setLoaction / setBounds methods � but I�ve not had any joy with these so far.
    I can see that I could create my own JComponent subclass that has the GUI and the graphics area and this could use a Layout to line things up.
    Basically � can I draw GUI components at an x,y coordinate on a JPanel?
    If this sounds like bad practice I�d welcome any sources of reference.
    Many thanks.

    Hi,
    My question probably sounds more complicated than it is owing to my inexperience with Swing. I'm sure what I'm after is done thousands of time in other apps.
    Bascially I have two set of graphs -
    One is pure graphical (plotting stock prices etc.).
    The other contains horizontal "bar" format data that lines up below the stock price graph
    (Again see latest posting here : http://www.chriswardsweblog.blogspot.com/)
    What I'm after is to have some controls at the right hand end of each bars. Presently I would imagine these to be a JCheckBox and maybe a JLabel to replace the g.drawString() rendered label in the screenshot.
    The reason I want this is that the upper graph area shows a plotted view of the bar data. I want to be able to check/uncheck the box to see the plotted quote lines turn on/off.
    I am pretty sure that I need to divide that lower JPanel into a "Graphical" panel for the bars and a "Component" panel for the controls. That feels like the correct thing to do - I just wanted someone to confirm I wasn't getting the wrong end of ths stick.
    If this is the case - I think I need to sort out what Layout I should use that will allow me to get the JCheckbox & JLabel to line up with the bars. I have been look at the Box layout which would seem to allow me to do that.
    I have another open question in this forum about how to toggle the visibilty of the upper panel quote lines - maybe that's where I need a Glass Panel?
    Does this clarify things?
    Thanks for all help.

  • It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is

    It's simple... I want the Illustrator pen tool to ALWAYS make corner annchor points and NEVER smooth.  Right now I have to convert every single one of them, or I have to do a work around every time I draw a line and make one of the handles disappear.  Is there some simple setting out there that will just "make it so?"@

    The video I am watching this guy is just dragging every line to make curves.  And every anchor point is a corner.  He is not switching back and forth between the pen and the anchor points tool, and he is not using the convert points tool.  He draws a curved line and starts another straight line only to curve it with a click and a drag.  It is super efficient, and I could save a world of time if I could figure out what he is doing.

  • I have a mac osX 10.5.8 and i could always make photo books with iphoto , now all of a sudden i cant because i have iphoto version 7.1.5 i have tried countless updates and nothing is working ? help ?

    i have a mac osX 10.5.8 and i could always make photo books with iphoto , now all of a sudden i cant because i have iphoto version 7.1.5 i have tried countless updates and nothing is working ? help ?

    Books are no longer supported with iPhoto '08 (a roughly six yeal old product) - you can purchase an iLife '09 DVD from someplace like Amazon or eBay and install it - iPhoto '09 is still supported this year
    LN

  • SAPgui.exe is running even after closing the GUI components

    Hello All,
    Even after closing the SAP GUI components like Bex, WAD or RSA1 etc... i am able to see these processes are running under the Task Manager--> Processes....
    even if i try to restart the system, error messages are occuring...saying that SAP is still opend...
    Why it is happening, any ideas?
    Thanks,
    Ravi

    Hi Dirk,
    Thanks for your infomation. Infact, apart from this problem, i have the problem with saving the webtemplate. As it is taking much time to save a template after modifications, i had to terminate the wad process. It seems above 2 problems are related....any ideas?
    Thanks
    ravi
    Message was edited by: Ravi Pasumarty

  • Customer gui components needed?

    I require to build a program with which allows the user to add representations of objects onto the main GUI by adding a seperate square for each object. each square should be capable of being moved, resized, deleted as well as have text displayed in it, and another object associated with it (but I'm currently just dealing with the GUI side of things). Each square will also need to be connected to others by means of an arrow from one square to another. Any suggestions as to where to start as there does not seem to be any appropriate widgets provided by java for this and I am having trouble finding stuff on the net about it. Will creating my own custom GUI components be the best option? If so any tips on how to do this?
    Regards

    Hello Ravi,
    Create a Variable for 0CALMONTH, and use this code,
    ' Declare this in the top
    data : v_startmon(6) type n,
    v_endmon(6) type n,
    ' Include this in the case statement
    when 'VarName'.
    ' Step 2 will execute after the user Input
    if i_step = 2.
    v_year = sy-datum(4).
    v_mon = sy-datum+4(2) - 1.
    ' If the month is Jan
    IF v_mon = '00'.
    CONCATENATE v_year '01' INTO v_startmon.
    CONCATENATE v_year '01' INTO v_endmon.
    ELSE.
    CONCATENATE v_year '01' INTO v_startmon.
    CONCATENATE v_year v_mon INTO v_endmon.
    EndIF.
    clear l_s_range.
    l_s_range-low = v_startmon.
    l_s_range-high = v_endmon.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    append l_s_range to e_t_range.
    Endif.
    Please see this for
    [User Exits in SAP BW|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/23f2f094-0501-0010-b29b-c5605dbdaa45]
    [User Exit Examples|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6378ef94-0501-0010-19a5-972687ddc9ef]
    Also see this
    [Dependencies for Variables of Type Customer Exit |http://help.sap.com/saphelp_nw04/helpdata/en/1d/ca10d858c2e949ba4a152c44f8128a/content.htm]
    Thanks
    Chandran
    Edited by: Chandran Ganesan on Mar 17, 2008 1:57 PM

  • Unique GUI Components

    How do I go about creating my own Unique GUI Components.
    For instance I would like to create a volume knob, that turns clockwise and couterclockwise.
    Best regards,

    Start off with extending JComponent, add methods for turning the knob, and have paintComponent show the turning knob. Add methods to be able to add listeners that you want. That should get you started.

  • Flyweight Pattern use with multiple GUI components

    Hi,
    I am creating a simple application and I would like your advice on wether I should use the flyweight pattern or not.
    My application is essentially a GUI front to a repository of small images. The GUI (in its simplest form) is a single window that will display all the images with their names in a clickable thumbnail format. The user will be able to select an thumbnail icon, drag it and move it around pretty much like the icons on your computer desktop.
    The easiest way to do that is probably to load each image and its name into a JLabel, add it in a JFrame and write just few lines of code (say by extending the JLabel class) to handle mouse pressed/dragged events in order to move the label around. The rest will be taken care of by the swing functinality (e.g. painting etc).
    However, I am considering using the flyweight pattern for efficiency but I am not sure if it is appropriate. So far I have seen simplistic examples of its use (apart from JTree) where the pattern is used to paint dozens of lines on the screen or the borders of components. But what happens if instead of lines or borders the objects in question are interactive GUI components such as my thumbnails? how does the flyweight pattern work in this case?
    For example if I create just a single JLabel and use it to paint all my icons that's great! but what happens with mouse events? what happens when I want to drag a thumbnail over another one and how the partial repainting of the thumbnail below should be handled?
    Am I missing something here, or in order to implement the flyiweight pattern in this case I will have to write endless lines of code to replicate the functionality that swing arleady provides in each JComponent? (e.g. targetting of mouse events, repainting etc)
    Cheers,
    Kyri

    I don't think Flyweight applies, because you really don't want to share any UI component that generates events unless the response is the same for all of them.
    If you read Flyweight, I think it was intended for things like caching the first 128 Integers, etc. - think finite, countable, immutable things. I don't think UI elements apply.
    %

  • Save GUI components in a XML format

    I am looking for a technoology that can help to create a my own file format using java. That mean currently im working with implementing a mind mapping tool (like mindjet) which will help to do basic mind mapping actions like add, edit, delete topics.
    But I have faced for a ig problem when im saving a created map. because it should save as a new file format and should be able to re-open for editing.
    What I planned is to retrive the GUI component's(elements of the map) properties from the map and write those values to the XML file(using XML DOM or SAX). Then read those saved values and create the GUI components under retrieved data.
    what I want to know is that. Is my approach is correct? or is there any better solution for this matter?
    please clarify me and I would really appreciate your help?
    Regards
    Lakshitha Ranasinghe

    You presumably have some state, in memory, that you want to persist. From your post, though I must confess that the terms you use are not really clear in terms of what type of data you actually want to say, my guess is that you have some graph of objects in memory that you have parsed that you want to serialize and persist and then later deserialize and restore for reuse in a subsequent execution of your program.
    If yes, then your goal is really simple: how do I save the state of my application and then restore it?
    Go to the filesystem: store as a properties file (key-value pairs), Java's default serialization, XML or a totally custom format
    Go do the database: map your object to a proper database table and column (via JDBC or an O/R mapper ala Hibernate), or store what you would have stored in the filesystem in a databaseXML is a valid option. So is a simple properties file. It depends on your requirements. If you are reading from and writing to a Java application, and frequent versioning is not an issue, then Java's default serialization could be a possibility. Going to the database would be the 'enterprise' solution, but requires testing and the successful functioning and communication between two technologies and machines. It depends on your requirements.
    - Saish

Maybe you are looking for

  • Building a desktop app - use AIR or not?

    Hello, I'm guessing that the keyword "desktop" would make you recommend I use Adobe AIR if I'm building with Flex.  Basically, we're building a desktop application that will occasionally sync with the server where a separate but related application r

  • How to promote Free User to a Team User License on Flash Builder v4.7?

    Hi, Recently, we brought CC Team License. At present whatever the Flash builder 4.7 we installed is a standalone setup i.e; not installed using Creative Cloud. However, later I installed the CC (as a Free User ID) and the same Flash builder 4.7 is re

  • Self assigned IP Address, wireless doesn't work

    After upgrading to Leopard I keep getting "AirPort has a self-assigned IP address and may not be able to connect to the Internet." when I try to connect to the wireless network. Thus, wifi does not work at all. I've researched it best I can and it se

  • Hyperlinks become awkward to use in viewer

    We have created a hyperlink in a EUL by making a FILE item based on a column with URLs. "Alternative display value" is set to "Document". When a workbook with this item is opened in Viewer we get the word "Document" in the cell, with a small blue tri

  • Weblogic portal 10.3.2 sample domain admin console question

    I'm using the sample domain shipped with WebLogic Portal 10.3.2 for some testing. I'm trying to access the admin console, could someone tell me how to find the user name and password to access the console? I thought weblogic/welcome1 was the default.