Making GUI in Swing

hello frends,
I am new to java , i make instant messenger, But it is console based
i want to add gui to it , But i don't know any technology(Applet ,Swing)
So please help me how to make gui for instant messenger, I tried to start but i have no good tutorial, But i got problem in Taking on line user list, sush that when i click the name new dialog will appear, will you please tell me how to do it, and also suggest some good books,and link that help me to make my messenger gui.
Thank you
alok

hi
am also doing same kind of program...
by using jtree we can list all the users...
its very easy ...
u can use sun tutorial itself

Similar Messages

  • How to use annotation with GUI in swing

    hi,
    i am new to annotation. I know how to use this with classes, methods and java elements. I am developing a tool in applet to post comment on my notepad, but unable to find that how to use this with GUI of swing. I have gone through most of forums and tutorials but got no idea. Anyone could give me little idea.
    Thanks

    >
    i need to use the applet mousedown function in swing..>There is no such class as 'applet' in the JRE, Swing has an upper case 1st letter, functions in Java are generally referred to as methods, and there is no 'mousedown' method in the JRE.
    OTOH a Swing JApplet inherits the mouseDown method from Component, and it was deprecated in Java 1.1. The documentation (JavaDocs) provides instructions on what to use instead.
    >
    is there any way to use it or any other alternative is available for this?
    if can provide me a sample code.>If can provide me cash. Short of that, you might actually need to do some research/coding of your own.
    As an aside. What does any of this have to do with Java 2D?

  • I need good gui in swings for a library management system

    i need good gui in swing. i need to develope a small application of library management system where a librarian and manager access the database. librarian take care of add,del,modify the records of customer and books. with good login screens. and the manager is to generate reports

    Yup, create one. Good exercise.
    Doing it myself right now, am loosing track of my own collection ;)
    Don't have the multi-user part in place yet, it's no priority for me (I'll be creating a readonly web interface as an alternative to the read/write Swing interface for remote access).

  • Need Help to update the labels in the GUI syncronously - Swing application

    Hello everyone,
    I need some help regarding a swing application. I am not able to syncronously update the counters and labels that display on my Swing GUI as the application runs in the background. But when the running of application is completed, then the labels on the GUI are getting updated, But I want update the labels and counters on the GUI syncronously as the code executes... below I am giving the format of the code I have written..............
    public class SwingApp extends JFrame{
            // here i have declared the label and component varibles like...
                      private JTextField startTextField;
           private JComboBox maxComboBox;
           private JTextField logTextField;
           private JTextField searchTextField;
           private JLabel imagesDownloaded1;
           private JLabel imagesDownloaded2;
           private JLabel imagesDidnotDownload1;
           private JLabel imagesDidnotDownload2;
                      private JButton startButton;
    //now in the constructer.............
    public Swing(){
    //I used gridbaglayout and wrote the code for the GUI to appear....
    startButton = new JButton("Start Downloading");
        startButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try{
                 actionSearch();   //actionSearch will contain all the code and the function calls of my application...........
            }catch(Exception e1){
                 System.out.println(e1);
        constraints = new GridBagConstraints();
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 5, 5);
        layout.setConstraints(startButton, constraints);
        searchPanel.add(startButton);
    //update is a function which initiates a thread which updates the GUI. this function will be called to pass the required variables in the application
    public void update(final int count_hits, final int counter_image_download1, final int didnot_download1) throws Exception{
         Thread thread = new Thread(new Runnable() {
             public void run() {
                  System.out.println("entered into thread");
                  System.out.println("the variable that has to be set is " + count_hits);
                  server_hits_count.repaint(count_hits);
                  server_hits_count.setText( " "+ Integer.toString(count_hits));
                  imagesDownloaded2.setText(" " + Integer.toString(counter_image_download1));
                  imagesDidnotDownload2.setText(" " + Integer.toString(didnot_download1));
                  repaint();
         //this.update(count_hits);
         thread.start();
    //Now in main............................
    public static void main(String[] args){
    Swing s = new Swing();
    s.setVisible(true);
    }//end of main
    }//end of class SwingAbove I have given the skeleton code of my application........ Please tell me how to update the GUI syncronously...
    Please its a bit urgent...............
    Thank you very much in advance
    chaitanya

    First off, note that this question should have been posted in the Swing section.
    GUI events run in a separate thread (the AWT / Event Dispatch Thread) than your program.
    You should be invoking AWT/Swing events via SwingUtilities.invokeLater().
    If for whatever reason you want to have the program thread wait for the event to process
    you can use invokeAndWait().
    http://java.sun.com/javase/6/docs/api/javax/swing/SwingUtilities.html

  • Making GUI update at correct time

    I'm creating an engine that can display experimental stimuli for my lab working with kids with reading disabilities. I have a GUI which can display the next stimuli in the test. Once the stimuli are displayed, the program does nothing until the user presses a button and a key event is called.
    I'm now trying to get my GUI to play recorded words to the user. Because it's the responsibility of the GUI to display stimuli, the GUI will be the one playing the sound (even though that's not typically thought of as a GUI responsibility). Unfortunately, even though the commands to update the GUI display are placed before the command to play the sound, the GUI does not update until it has finished playing the sound.
    This has nothing to do with the sound itself: if I replace the clip.play() line with a loop that wastes time and spins around for five seconds, the GUI does not update for those five seconds.
    The GUI updates itself the moment the program leaves the setStimuli() method. How can I get it to update itself before then? Commands such as this.repaint() don't appear to work.
    Any thoughts on how to get the GUI to update itself before exiting the method?
    public class TestingEngine {
    public void setStimuli(String[] values) {
       gui.setStimuli(values);
    public class GUI extends javax.swing.JFrame {
    public void setStimuli(String[] values){
           switch (testType){
             case SOUND:
                   String soundImageFile = "Headphones.jpg";
                   ImageIcon soundImage = new ImageIcon(soundImageFile);
                   JLabel soundImageLabel = new JLabel(soundImage);
                   SoundImageJPanel.removeAll();
                   SoundImageJPanel.repaint();
                   SoundImageJPanel.add(soundImageLabel);
                   soundImageLabel.setVisible(true);
                   label_S_Option1.setText(values[1]);
                   label_S_Option2.setText(values[2]);           // <-- nothing has updated yet
                   SoundClip clip = new SoundClip(values[0]);
                   if (clip.isInitialized())                     // <-- this section could also be replaced
                       clip.play();                             // by a time-wasting loop
                   break;
        }      // <-- once program reaches here, GUI finally updates
    }

    Ok, so just for the sake of it, I tried using the Timer method as suggested in the thread you pointed me to. This doesn't do anything, but thinking about it, I don't see why it would. Timer calls repaint() every 50 ms, but, after all, the setStimuli() method also called repaint() before playing the soundclip. If the original call of repaint() didn't do anything, then I don't think that calling it more often would.
    Is there another command that I should be using? In other words, how can I tell my JFrame and JLabels to "UPDATE RIGHT NOW, NOT IN A MINUTE!"? (It would be easier if I were the JFrame's mother...)
    Current version of code, with Timer class:
    public class GUI extends javax.swing.JFrame {
       private Thread refresh;
       public GUI() {
           initComponents();
           refresh = new Timer(this);
           refresh.start();
       public void setStimuli(String[] values){
           switch (testType){
             case SOUND:
                   String soundImageFile = "Headphones.jpg";
                   ImageIcon soundImage = new ImageIcon(soundImageFile);
                   JLabel soundImageLabel = new JLabel(soundImage);
                   SoundImageJPanel.removeAll();
                   SoundImageJPanel.repaint();
                   SoundImageJPanel.add(soundImageLabel);
                   soundImageLabel.setVisible(true);
                   label_S_Option1.setText(values[1]);
                   label_S_Option2.setText(values[2]);           // <-- nothing has updated yet
                   SoundClip clip = new SoundClip(values[0]);
                   if (clip.isInitialized())                     // <-- this section could also be replaced
                       clip.play();                              // by a time-wasting loop (same problem)
                   break;
       }      // <-- once program reaches here, GUI finally updates
       public void callback(){
           repaint();
    class Timer extends Thread
         private Gui parent;
         public Timer(Gui g) {
              parent = g;
         synchronized public void run() {
              while(true) {
                   try{
                       wait(50);
                   }catch(InterruptedException ie) {return;}
                   parent.callBack();
    }

  • XML document describing the application's GUI in SWING

    Hii Javaites
    Can i build Swing GUI from a XML document.
    If yes , can anybody tell me how 2 go abt it.
    Which parser will i need ?

    I would avoid it, only my opinion:
    http://forum.java.sun.com/thread.jspa?threadID=725055
    Jim

  • GUI Calculator (Swing, BorderLayout, etc.)

    I am a bit of a crossroads and am needing some advice. I am trying to create a Calculator in a Window (GUI) that looks similar to a keypad. I have three files that I am working on but cannot get any of them to compile without errors. I am confused as to what I have left out and/or where I have taken a wrong turn. I will post them below and would greatly appreciate any insight and/or direction as to how to make this work! Also, I have heard from a "birdie" that there may be some problems that occur if the files are compiled out of order....does this make sense to anyone? Thank you in
    advance for any help--Christle
    Constants.java file
    //Christle Chumney
    import java.awt.*;
    public interface Constants
      Color FUNCTION_COLOR = Color.red;
      Color OPERATOR_COLOR = Color.blue;
      Color NUMBER_COLOR = Color.black;
    }calculator.java file
    //Christle Chumney
    import java.awt.*;
    public class Calculator  {
      public static void main(String[] args){
         theApp = new Calculator();
         theApp.init();
      public void init() {
        aWindow = new CalculatorFrame("My Calculator");
        aWindow.setBounds(10, 10, 250, 250);
        aWindow.setVisible(true); }
      private static CalculatorFrame aWindow;
      private static Calculator theApp;
    }calculatorFrame.java file
    //Christle Chumney
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.border.*;
    import java.util.*;
    public class CalculatorFrame extends JFrame implements Constants //, ActionListener
      private Calculator theApp;
      JPanel top, bottom;
      JTextField display;
      JButton button;
      // Constructor
      public CalculatorFrame(String title)
        setTitle(title);  // Set the window title
        this.theApp = theApp;
        JMenuBar swingMenuBar = new JMenuBar();
        JMenu swingMenu = new JMenu("swingMenu");
        JMenuItem swingMenuItem1, swingMenuItem2, swingMenuItem3;
         swingMenuBar.add(swingMenu);
         setJMenuBar(swingMenuBar);
        JMenu applicationMenu = new JMenu("Function");    // Create Application menu
        applicationMenu.setMnemonic('A');                    // Create shortcut
        // Construct the application pull down menu
        exitItem = applicationMenu.add("Exit");                // Add exit item
        exitItem.setAccelerator(KeyStroke.getKeyStroke('X',Event.CTRL_MASK ));
        applicationMenu.add(exitItem);
        menuBar.add(applicationMenu);                        // Add the file menu   
        makeButtons();
      public void makeButtons() {
        BorderLayout border = new BorderLayout();
        Container content = getContentPane();
        content.setLayout(border);
        top = new JPanel(new BorderLayout());
        display = new JTextField("");
        display.setEditable(false);
        display.setBackground(Color.white);
        display.setHorizontalAlignment(display.RIGHT);
        top.add(display);
        bottom = new JPanel();
        GridLayout grid = new GridLayout(5,4,5,5);
        bottom.setLayout(grid);
        bottom.add(button = new JButton("C"));
        button.setForeground(FUNCTION_COLOR);
        bottom.add(button = new JButton("<=="));
        button.setForeground(FUNCTION_COLOR);
        bottom.add(button = new JButton("%"));
        button.setForeground(OPERATOR_COLOR);
        bottom.add(button = new JButton("/"));
        button.setForeground(OPERATOR_COLOR);
        bottom.add(button = new JButton("7"));
        bottom.add(button = new JButton("8"));
        bottom.add(button = new JButton("9"));
        bottom.add(button = new JButton("*"));
        button.setForeground(OPERATOR_COLOR);
        bottom.add(button = new JButton("4"));
        bottom.add(button = new JButton("5"));
        bottom.add(button = new JButton("6"));
        bottom.add(button = new JButton("-"));
        button.setForeground(OPERATOR_COLOR);
        bottom.add(button = new JButton("1"));
        bottom.add(button = new JButton("2"));
        bottom.add(button = new JButton("3"));
        bottom.add(button = new JButton("+"));
        button.setForeground(OPERATOR_COLOR);
        bottom.add(button = new JButton("0"));
        bottom.add(button = new JButton("+/-"));
        bottom.add(button = new JButton("."));
        bottom.add(button = new JButton("="));
        button.setForeground(OPERATOR_COLOR);
         Container content = aWindow.getContentPane();
         content.setLayout(new BorderLayout());
         content.add(top, BorderLayout, NORTH);
         content.add(bottom, BorderLayout, CENTER);
      private JMenuBar menuBar = new JMenuBar();      // Window menu bar
      private JMenuItem exitItem;                       // application menu item 
    }Thanks in advance (again)-
    Christle

    HERE R U .JAVA FILES AND THEY WORK FINE NOW NO ERRORS NOTHING JUST THAT U HAVE TO CODE THE EVENTS OF UR APPLICATION
    ANYOTHER HELP U NEED UR MOST WELCOME
    VIJAY
    // CALCULATORFRAME.JAVA
    //Christle Chumney
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.border.*;
    import java.util.*;
    public class CalculatorFrame extends JFrame implements Constants //,ActionListener
         private Calculator theApp;
         JPanel top, bottom;
         JTextField display;
         JButton button;
    // Constructor
         public CalculatorFrame(String title)
              setTitle(title);
    // Set the window title
              this.theApp = theApp;
              JMenuBar swingMenuBar = new JMenuBar();
              JMenu swingMenu = new JMenu("swingMenu");
              JMenuItem swingMenuItem1, swingMenuItem2, swingMenuItem3;     
              swingMenuBar.add(swingMenu);     
              setJMenuBar(swingMenuBar);
              JMenu applicationMenu = new JMenu("Function");
    // Create Application menu
              applicationMenu.setMnemonic('A');
    // Create shortcut
    // Construct the application pull down menu
              exitItem = applicationMenu.add("Exit");
    // Add exit item           exitItem.setAccelerator(KeyStroke.getKeyStroke('X',Event.CTRL_MASK ));           applicationMenu.add(exitItem);
              menuBar.add(applicationMenu);
    // Add the file menu
              makeButtons();
    public void makeButtons()
         BorderLayout border = new BorderLayout();
         Container content = getContentPane();
         content.setLayout(border);
         top = new JPanel(new BorderLayout());
         display = new JTextField("");
         display.setEditable(false);
         display.setBackground(Color.white);
         display.setHorizontalAlignment(display.RIGHT);
         top.add(display);
         bottom = new JPanel();
         GridLayout grid = new GridLayout(5,4,5,5);
         bottom.setLayout(grid);
         bottom.add(button = new JButton("C"));
         button.setForeground(FUNCTION_COLOR);
    bottom.add(button = new JButton("<=="));
         button.setForeground(FUNCTION_COLOR);
         bottom.add(button = new JButton("%"));
         button.setForeground(OPERATOR_COLOR);
         bottom.add(button = new JButton("/"));
         button.setForeground(OPERATOR_COLOR);
         bottom.add(button = new JButton("7"));
         bottom.add(button = new JButton("8"));
         bottom.add(button = new JButton("9"));
         bottom.add(button = new JButton("*"));
         button.setForeground(OPERATOR_COLOR);
         bottom.add(button = new JButton("4"));
         bottom.add(button = new JButton("5"));
         bottom.add(button = new JButton("6"));
         bottom.add(button = new JButton("-"));
         button.setForeground(OPERATOR_COLOR);
         bottom.add(button = new JButton("1"));
         bottom.add(button = new JButton("2"));
         bottom.add(button = new JButton("3"));
         bottom.add(button = new JButton("+"));
         button.setForeground(OPERATOR_COLOR);
         bottom.add(button = new JButton("0"));
         bottom.add(button = new JButton("+/-"));
         bottom.add(button = new JButton("."));
         bottom.add(button = new JButton("="));
         button.setForeground(OPERATOR_COLOR);     
         Container content1 = this.getContentPane();     
         content.setLayout(new BorderLayout());
         content1.add(top, BorderLayout.NORTH);
         content1.add(bottom, BorderLayout.CENTER);
         private JMenuBar menuBar = new JMenuBar();
    // Window menu bar
         private JMenuItem exitItem;
    // application menu item
    // CALCULATOR.JAVA
    import java.awt.*;
    public class Calculator
    public static void main(String[] args)
    {     theApp = new Calculator();
         theApp.init();
    public void init()
    aWindow = new CalculatorFrame("My Calculator");
    aWindow.setBounds(10, 10, 250, 250);
    aWindow.setVisible(true);
    private static CalculatorFrame aWindow;
    private static Calculator theApp;
    // CONSTANTS.JAVA
    import java.awt.*;
    public interface Constants
    Color FUNCTION_COLOR = Color.red;
    Color OPERATOR_COLOR = Color.blue;
    Color NUMBER_COLOR = Color.black;

  • JSF with Rich GUI Renderers - Swing

    Has any one developed a renderer for a Thick Client/GUI such as swing. I know JSF is for web-based applications but with a suitable renderer it could be made to work with a non browser frontend, no ?

    You are right.
    Don't known about Swing implementation but other interesting ones are available. Have a look at XULFACES for example: http://xulfaces.sourceforge.net/getting-started.html
    Anyway AJAX looks to be the "future" of rich JSF implementations. For example MyFaces Tomahawk is working to make a Dojo -http://dojotoolkit.org/- JSF implementation.
    I don't known of other JSF implementations for devices like blackberry or Nokia S6x, but would be great too.

  • How can I use the function keys in a GUI with swing?

    I'm wondering how do you declare you want an action to happen when a user uses a function key or any key for that matter. How can you specify something frame wide or for that matter for a specific jtextbox?

    you need to use an accelerator
    setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)

  • Making GUI in servlet

    i have made an application and its GUI using JFrames. The GUI is somewhat like a text editor PLUS option to execute my program on the text entered by the user. also, it has a window which shows the output/error messages. now, i want to web enable it. i.e. when the page is loaded, the user sees a similar GUI (as described above) on the page. and he shud be able to do similar things also. can somebody suggest, how can we achieve this using servlet or jsp
    tia

    hi
    am also doing same kind of program...
    by using jtree we can list all the users...
    its very easy ...
    u can use sun tutorial itself

  • How should I cread my GUI in Swing?

    I need to write a GUI with which I can connect different kinds of components together (2-Dimensional). The components must be represented by images and they should be turned in 8 directions, clockwise or counterclockwise.
    The graphical components should be moved with the mouse, dragging and dropping them. When released, the components should dock to another graphical component (if compatible and close enough). Maybe I would like to use a grid.
    I never did dragging and dropping or rotating or docking or programming a grid. Can someone help me a little bit? Is there a framework for this existing? Or what classes or Java technologies should I use?

    I postet my question now to the 2D forum. Please reply here: http://forum.java.sun.com/thread.jsp?forum=20&thread=337601

  • GUI Problem (Swing JFrame/JPanel). HELP!

    Hi,
    I made an small application for calculate some things.
    I download i piece of code for creating bar chart and i icluded in my code. But i have problem when i am trying to show the chart in the Frame. All the buttons, textfields, labels goes to left and half are hiding.
    If i open the chart on a new frame i dont have problem.
    the problem apears when after i put the panel in the frame i try to put the chart in the frame. Look the code:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!that command mades me the problem!
    Here are 2 screenshots
    1. When i put the chart in the Frame (the problem)
    http://www.iweb.gr/images/InFrame.jpg
    2. When i put the chart on new frame (works fine)
    http://www.iweb.gr/images/NewFrame.jpg
    Hopes someone can help. Thanks
    The code List:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    //The main class of the program
    public class PlantFertilizer  extends JFrame{//The main class is a subclass of Frame
         private Label lN, lP,lK;//These show the value of the observable
         public TextField tN, tP, tK;
         private MyData thedata;//The observable we are going to watch
         private double[] values=new double[3];
        private String[] names=new String[3];
        private String title;
    public PlantFertilizer(){
         thedata=new MyData();// create the observable
         addWindowListener(new WindowAdapter(){//if user closes the Frame, quit
              public void windowClosing(WindowEvent e){
                   System.exit(0);
         setSize(400,500);//Set size
         setTitle(getClass().getName()+" By Pantelis Stoumpis");
         JPanel p = new JPanel();    //Make a panel for buttons and output
         //Input Data Area
         p.add(new Label("-------------------------Input Data Area--------------------------",Label.CENTER));
         p.add(new Label("Nitrogen (N)"));
         tN = new TextField();p.add(tN);
         p.add(new Label("Phosphorus (P)"));
         tP = new TextField();p.add(tP);
         p.add(new Label("Potassium (K)"));
         tK = new TextField();p.add(tK);
         lN=new Label("N = %", Label.CENTER);
         p.add(lN);     //Put the N label in the panel
         lP=new Label("P = %", Label.CENTER);
         p.add(lP);          //Put the P label in the panel
         lK=new Label("K = %", Label.CENTER);
         p.add(lK);          //Put the K label in the panel
         addButton(p,"Apply",          //Apply new Values
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              int iNt = Integer.parseInt(tN.getText());
              int iPt = Integer.parseInt(tP.getText());
              int iKt = Integer.parseInt(tK.getText());
              thedata.addOne(iNt,iPt,iKt);          //which adds one to the observable
              JFrame f = new JFrame();
             f.setSize(400, 300);
              values[0] = 40;
             names[0] = "N";
             values[1] = 20;
             names[1] = "P";
             values[2] = 30;
             names[2] = "K";
             f.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));
              f.setVisible(true);
         addButton(p,"Close",          //add a close button to quit the program
         new ActionListener(){
         public void actionPerformed(ActionEvent evt){
              System.exit(0);
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!
    //A utility function to add a button with a given title and action
    public void addButton(Container c, String title,ActionListener a)
              Button b=new Button(title);
              c.add(b);
              b.addActionListener(a);
    public class ChartPanel extends JPanel {
      private double[] values;
      private String[] names;
      private String title;
      public ChartPanel(double[] v, String[] n, String t) {
        names = n;
        values = v;
        title = t;
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (values == null || values.length == 0)
          return;
        double minValue = 0;
        double maxValue = 0;
        for (int i = 0; i < values.length; i++) {
          if (minValue > values)
    minValue = values[i];
    if (maxValue < values[i])
    maxValue = values[i];
    //Dimension d = getSize();
    //int clientWidth = d.width;
    //int clientHeight = d.height;
    //int barWidth = clientWidth / values.length;
    //Dimension d = 100;
         int clientWidth = 100;
         int clientHeight = 150;
    int barWidth = clientWidth / values.length;
    Font titleFont = new Font("SansSerif", Font.BOLD, 12);
    FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
    Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
    FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);
    int titleWidth = titleFontMetrics.stringWidth(title);
    int y = titleFontMetrics.getAscent();
    int x = (clientWidth - titleWidth) / 2;
    g.setFont(titleFont);
    g.drawString(title, 10, 300);
    int top = titleFontMetrics.getHeight();
    int bottom = labelFontMetrics.getHeight();
    if (maxValue == minValue)
    return;
    double scale = (clientHeight - top - bottom) / (maxValue - minValue);
    y = clientHeight - labelFontMetrics.getDescent();
    g.setFont(labelFont);
    for (int i = 0; i < values.length; i++) {
    int valueX = i * barWidth + 1;
    int valueY = top;
    int height = (int) (values[i] * scale);
    if (values[i] >= 0)
    valueY += (int) ((maxValue - values[i]) * scale);
    else {
    valueY += (int) (maxValue * scale);
    height = -height;
    g.setColor(Color.red);
    g.fillRect(valueX, valueY, barWidth - 2, height);
    g.setColor(Color.black);
    g.drawRect(valueX, valueY, barWidth - 2, height);
    int labelWidth = labelFontMetrics.stringWidth(names[i]);
    x = i * barWidth + (barWidth - labelWidth) / 2;
    g.drawString(names[i], x, y);
    //main is called when we start the application
    public static void main(String[]args){
                   PlantFertilizer od = new PlantFertilizer();//make an observationsDemo frame
                   NWatcher watchitN = new NWatcher(od.lN);//make an observer
                   od.thedata.addObserver(watchitN);//register observer with the observable
                   PWatcher watchitP = new PWatcher(od.lP);//make an observer
                   od.thedata.addObserver(watchitP);//register observer with the observable
                   KWatcher watchitK = new KWatcher(od.lK);//make an observer
                   od.thedata.addObserver(watchitK);//register observer with the observable
                   od.setVisible(true);//show the frame on the screen

    Why are you putting Labels and TextFields (heavyweight AWT components) into a lightweight JPanels?
    What's the first rule of Swing? DO NOT MIX heavyweight AWT components and lightweight Swing components. Period. Never.
    There's Swing equivalents for every single AWT component, and then some. There's no excuse for not using them.
    However, if this chart library code is AWT based, then you should make a completely AWT based UI. Or find a different library based on Swing (like JFreeChart).
    And finally:
    add(p);     //Put the panel in the Frame
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant")); // <-- The problem!!is wrong....
    add(p);      // <-- The problem!!
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"));You don't call add on JFrame or JDialog to add things to it, unless you know what you're doing. And you clearly don't, else you wouldn't have done it. What you probably want to do is this:
    this.getContentPane().add(p, BorderLayout.SOUTH);
    this.getContentPane().add(new ChartPanel(values, names, "Fertilizer Plant"), BorderLayout.CENTER);

  • Help needed regarding GUI in swings

    I have n application which extratcs .ear (say abc.ear) in temporary folder. then from there a vector is created from that temporary folder containg the name of contents of .ear
    That vector is used to populate the JSCrollPane and then this scroll pane is set on JSplitPane.
    The problem is it is working fine in jdk1.4. but in jdk1.5 the GUI is not visible.
    Can anyone give some suggestion for that.

    The problem is it is working fine in jdk1.4. but in jdk1.5 the GUI is not visible.Then you have a coding problem. Simply displaying the GUI will not be a problem between versions.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program" that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • How to Read/Write to PS registry, tools for making GUI

    Hi Folks,
    We have several plugins that we would like to make available to our users by the Photoshop panel (made with Adobe Configurator).
    Plugins are scripting aware, and also use reading and writing to Photoshop registry.
    We also want that user can define settings for the plugin and to be able to call it by clicking on a button.
    Only way that I could  find is as follows:
    User click on a settings button, and that calls java script that display dialog with settings.
    There user can make choices and save them.
    When user click on a run button script read settings from registry and calls plugin
    or just call plugin (plugin can read from registry himself).
    Now the questions:
    What are the tools that are using to make dialogs in JS when you make java scripts to automate Photoshop?
    How to read and write Photoshop registry with java script?
    I am experienced plugin developer but until now all work was in PS SDK and C++.
    I have no experience in scripting Photoshop trough java script.
    Plugins are Win 32/64 platform that are supported is Windows XP or later.
    Thank you in advance.
    Regards,
    Momir Zecevic

    Well, as someone has said, pefs should work, but if not, it is quite easy to figure out the syntax of the .reg files, so why wouldn't you create the one you need and than import it? I think you can add reg keys with
    REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f]or
    REGEDIT /S pathnamecommands, so call that in an external process (see ProcessBuilder class).

  • [SOLVED] making GUI look pretty

    I know I can just browse through xfce-look and stuff like that
    but I want to hear what the community likes... any suggestions for themes, launch bars, or just flat out "neat" stuff... etc... for
    gnome .... xfce4 .....kde
    Thanks
    Last edited by BarefootSoul83 (2009-10-20 15:30:10)

    RetroX wrote:
    It all depends on the desktop you choose, really.
    GNOME is the best all-around desktop.
    /ignores flame bait.
    just kidding - I know you didn't intend it that way.
    KDE is the feature-full desktop with tons of appearance options and tons of features you may or may not want.  Performance-wise, it's a lot slower.
    as others have said, that's not necessarily the case. 
    If you have the hard drive space, you can make a separate partition (no more than 15 GiB is needed) and make a separate installation of Arch, where you can mess around with the various desktops.  Then, once you decide what you want, install it on the partition you're actually going to be using.
    You could do that, but imo it's not really necessary to go to such extremes. You can easily install and remove any desktop/wm on a single installation. If you're really concerned about keeping your testing separate from your active install, creating a separate user should be sufficient. Besides, if you have that extra diskspace to make a new install, you could just leave gnome/kde installed. It's not going to hurt anything to have them sitting there unused.

Maybe you are looking for