JLabel setText() immediately

Hi,
I have a status bar (JPanel) at the bottom of my GUI that only consists of a JLabel. I am executing external commands via a TranslateId utility class to perform tasks such as translating from host name to IP address, IP address to host name, MAC to IP, IP to MAC, etc. These tasks may take a while, and I want the status bar to say "Please Wait..." while the task is processing. I have the following snipet of code that attempts to do that.
statusBar.setMsg("Please Wait...Resolving machine name.");
try
  nameToAdd = TranslateId.IpToName(ipAddrToAdd);
catch(IOException e){}
if(nameToAdd.length() == 0 || nameToAdd.equals(ipAddrToAdd))
  JOptionPane.showMessageDialog(null,
    "The machine name was unable to be resolved from the provided " +
    "information.  Please specify the machine name.",
    "Machine Name Unknown",
    JOptionPane.ERROR_MESSAGE);
  statusBar.setMsg("");
  return;
statusBar.setMsg("");The problem is that the first line of code statusBar.setMsg(...) (this simply calls label.setText()) does not actually set the StatusBar text until after the external command is executed. The reason I know this is because if I pass an invalid IP address, and the JOptionPane error dialog is displayed, the status bar text does not get displayed until the JOptionPane is shown. There is a noticable passage of time when the external command is being processed where the StatusBar text is not displayed.
It may be worth mentioning that all this code is within an actionPerformed() routine.
Any ideas on how I can get the status text to display before the external command is run?
Thanks,
Geoff Wilson

you can try to use the SwingWorker class to run the external command, freeing up the event dispatch thread (which both actionPerformed and the repaint by setText use) to process the new text..

Similar Messages

  • GUI resizes when calling JLabel.setText()

    Case:
    I have a GUI with a GridbagLayout.
    This is the code for building the GUI.
    Important bits:
    please note the scrollConsole and adding it way at the end, because that's getting bigger:
    NOTE: KwartoButtons are a selfmade class that behaves like a button.
         setSize(600,600);
              Container p1 = getContentPane();
              p1.setLayout(new GridBagLayout());
                        GridBagConstraints c = new GridBagConstraints();
                        c.gridx = 0;
                        c.insets.set(5,8,5,8);
                   p1.setBackground(Color.DARK_GRAY);
                          panelVeld = new JPanel(new GridLayout(4,4));
                          panelStukken = new JPanel(new GridLayout(4,4));
                          labelVeld = new JLabel("Speelveld");
                          labelOngespeeld = new JLabel("Ongespeelde Stukken");
                        buttonStop = new JButton("Stop");
                          buttonConsole = new JButton("Hide/Show Console");
                          buttonStart = new JButton("Start");
                   textAreaConsole = new JTextArea("");
                   buttonPanel = new JPanel(new FlowLayout());
                   textAreaConsole.setFont(new Font("Courier",Font.PLAIN, 12));
                   aanZet = new JLabel("Niemand aan zet");
                          labelVeld.setForeground(Color.LIGHT_GRAY);
                          labelOngespeeld.setForeground(Color.LIGHT_GRAY);   
                       aanZet.setForeground(Color.LIGHT_GRAY);
                       scrollConsole = new JScrollPane(textAreaConsole,                   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                      buttonPanel.add(buttonStart);
                      buttonPanel.add(buttonStop);
                      buttonPanel.setBackground(Color.DARK_GRAY);
                     for(int i=0; i < veld.length; i++)
                          veld[i] = new KwartoButton(null, i, true);
                          veld.addMouseListener(this);
                   veld[i].setEnabled(false);
                   panelVeld.add(veld[i]);
              Set<Stuk> stukkenSet = spel.getOngespeeld();
              int i=0;
              for(Stuk stuk: stukkenSet)
                   stukken[i] = new KwartoButton(stuk, i, false);
                   stukken[i].addMouseListener(this);
                   stukken[i].setEnabled(false);
                   panelStukken.add(stukken[i]);
                   i++;
              c.fill = GridBagConstraints.NONE;     
              c.gridx = 0;
                   p1.add(labelVeld, c);
              c.gridx = 1;
                   p1.add(labelOngespeeld, c);
              c.weightx = 0.5;
              c.weighty = 0.9;
              c.fill = GridBagConstraints.BOTH;     
              c.gridx = 0;
                   p1.add(panelVeld, c);
              c.gridx = 1;
                   p1.add(panelStukken, c);
              c.fill = GridBagConstraints.VERTICAL;
              c.gridx=0;
              c.gridwidth=2;
              c.weightx=0;
              c.weighty=0;
              p1.add(aanZet,c);
              c.fill = GridBagConstraints.VERTICAL;     
              c.weighty = 0.0;               
              c.gridy=3;
              c.gridwidth=1;
              c.gridx=0;
                   p1.add(buttonPanel, c);
              c.gridx=1;
                   p1.add(buttonConsole, c);
              c.gridwidth = GridBagConstraints.REMAINDER;     
              c.gridx=0;
              c.gridy=4;
              c.weightx = 1.0;
    c.weighty = 0.1;     
                   c.fill = GridBagConstraints.BOTH;
              p1.add(scrollConsole, c);          
    This is the code I run when the resize happens:
    public void setMessage(String s)  {
    String message =""
    message =s
                  if(!message.equals("")) {
                       addToConsole(message);
                       aanZet.setText(message);
    public void addToConsole(String s)  {
                   // Determine whether the scrollbar is currently at the very bottom position.
                   JScrollBar vbar = scrollConsole.getVerticalScrollBar();
                   boolean autoScroll = ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum());
                   // append to the JTextArea (that's wrapped in a JScrollPane named 'scrollPane'
                   textAreaConsole.append(s+"\n");
                   // now scroll if we were already at the bottom.
                   if( autoScroll ) textAreaConsole.setCaretPosition( textAreaConsole.getDocument().getLength() );
         }What my GUI does: When I invoke setMessage(), my scrollConsole grows about one line, until it overpowers the entire GUI (except the buttons).
    If I remove the 'auto-scrolldown' functionality of addToConsole, it still resizes, so I reckon that's not the problem.

    Here you go.
    Thanks in advance.
    import java.awt.*;
    import javax.swing.*;
    * SSCCE Class for my problem.
    * Problem: GUI Resizes after calling the update method.
    public class TestingClass extends JFrame {
                   private JTextArea textAreaConsole;
                   private JLabel aanZet;
                   private JScrollPane scrollConsole;
         public void update(String s) {          //the problematic method
                       addToConsole(s);                         
                       aanZet.setText(s);
       public void addToConsole(String s) { //adds text to console
                   // Determine whether the scrollbar is currently at the very bottom position.
                   JScrollBar vbar = scrollConsole.getVerticalScrollBar();
                   boolean autoScroll = ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum());
                   // append to the JTextArea (that's wrapped in a JScrollPane named 'scrollPane'
                   textAreaConsole.append(s+"\n");
                   // now scroll if we were already at the bottom.
                   if( autoScroll ) textAreaConsole.setCaretPosition( textAreaConsole.getDocument().getLength() );
         public TestingClass() {
              super("Test");
              buildGUI();
              setVisible(true);
              update("a");
              update("b");
              update("c");
                   update("d");
                        update("e");
                             update("f");
                                  update("g");
                                       update("h");
                                            update("i");
                                                 update("j");
                                                      update("k");
                                                           update("l");
                                                                update("m");
                                                                     update("n");
                                                                          update("o"); //add more to see more effect, remove to kill problem
         public void buildGUI() { //building the gui
              setSize(600,600);
              Container p1 = getContentPane();
              p1.setLayout(new GridBagLayout());
                        GridBagConstraints c = new GridBagConstraints();
                        c.gridx = 0;
                        c.insets.set(5,8,5,8);
                        JPanel panelVeld = new JPanel(new GridLayout(4,4));
                JPanel panelStukken = new JPanel(new GridLayout(4,4));
                        textAreaConsole = new JTextArea("");
                        textAreaConsole.setFont(new Font("Courier",Font.PLAIN, 12));
                        aanZet = new JLabel("Test!");
                      scrollConsole = new JScrollPane(textAreaConsole, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                 for(int i=0; i < 16; i++)
                          panelVeld.add(new JButton("x"));
                          panelStukken.add(new JButton("y"));
          c.weightx = 0.5;
          c.weighty = 0.9;
          c.fill = GridBagConstraints.BOTH;     
          c.gridx = 0;
                p1.add(panelVeld, c);
          c.gridx = 1;
                   p1.add(panelStukken, c);
                 c.fill = GridBagConstraints.VERTICAL;
                 c.gridx=0;
                 c.gridwidth=2;
                 c.weightx=0;
                 c.weighty=0;
                      p1.add(aanZet,c);
                 c.gridwidth = GridBagConstraints.REMAINDER;     
                 c.gridx=0;
                 c.gridy=4;
                 c.weightx = 1.0;
          c.weighty = 0.1;                    
                   c.fill = GridBagConstraints.BOTH;            
                      p1.add(scrollConsole, c);
    public static void main(String[] args) { //starting up!
              new TestingClass();
    }

  • Status bar or jlabel

    hi all,
    how can i create a status bar on my java app
    that shows a message if it is connected on the internet or not.
    i already have an application that checks for internet connection
    every 6seconds, and has a getter method that returns a
    message.
    also is this possible?
    JLabel.setText(CheckConnection.getMessage())
    where CheckConnection.getMessage() returns a String value.
    how can i make my JLabel act like it was refreshing when the string passed to it changed?
    so that my JLabel notifies my application that it is disconnected.
    thanks.

    Hi,
    Create a thread that calls checkConnection.getMessage(), and sets the message on the JLabel.
    Kaj

  • Updating a JLabel Too Fast Crashes Program

    I have a recursive method that runs for 80 seconds (in a thread
    outside the GUI). The recursive method is probably being called
    20,000 times in this 80 seconds.
    I am calling myJlabel.setText("" + someVariable) every call to this recursive method.
    About half the time I run this program it crashes with the following error.
    Does anybody know why this is happening?
    I believe it has something to do with the speed of the calls because
    when I slow the method considerably (10x) I never get the error.
    I dont just want to wrap the call in try/catch without knowing the cause.
    Thanks!
    Exception in thread "Thread-2" java.lang.NullPointerException
            at javax.swing.text.View.setParent(View.java:322)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.FlowView.setParent(FlowView.java:272)
            at javax.swing.text.html.ParagraphView.setParent(ParagraphView.java:58)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.html.BlockView.setParent(BlockView.java:55)
            at javax.swing.text.html.HTMLEditorKit$HTMLFactory$BodyBlockView.setParent(HTMLEditorKit.java:1277)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.html.BlockView.setParent(BlockView.java:55)
            at javax.swing.plaf.basic.BasicHTML.updateRenderer(BasicHTML.java:194)
            at javax.swing.plaf.basic.BasicLabelUI.propertyChange(BasicLabelUI.java:409)
            at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
            at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
            at java.awt.Component.firePropertyChange(Component.java:7865)
            at javax.swing.JLabel.setText(JLabel.java:311)
            at LoadFrame.setInfo(LoadFrame.java:44)
            at LoadHandler.update(LoadHandler.java:67)
            at FilesLoader.recurseProcess(FilesLoader.java:69)
            at FilesLoader.recurseProcess(FilesLoader.java:93)
            at FilesLoader.run(FilesLoader.java:42)
            at java.lang.Thread.run(Thread.java:619)

    Are you updating the label in the Event Dispatch
    Thread (EDT)?I dont believe so. I spawn off a new thread to do the
    recursive file loading and that calls the JLabel.setText(...)
    The loading takes 80 secs and I can still use the GUI so I
    wouldnt think anything is happening in the EDT.
    Another bizarre glitch is that my JLabel has 4 lines of text like this:
    bold: plain
    bold: plain
    bold: plain
    And the bold and plain text are randomly glitching out.
    Sometimes a whole line will be bold, all not bold, all bold, plain
    ones bold, vice versa. Just random-ness.
    This is the code for setting the text:
    public void setText(String path, long folderCount, long fileCount, long ms){
    String time = (ms / 1000) + " seconds";
    infoLabel.setText("<html><b>Current Folder:</b> " + path +
    "<br><b>Folders:</b> " + folderCount +
    "<br><b>Files:</b> " + fileCount +
    "<br><b>Time:</b> " + time + "</html>");
    }

  • JLabel updating text

    Hi,
    I have a panel called BottomPanel that is used in three frames.
    The same instance of BottomPanel is always used.
    I want the BottomPanel to do the following, every 10 seconds to change the text of a JLabel to "current time is XX".
    The issue I have is that when the JLabels.setText is invoked within the panel with the new text is not be shown in the panel.
    I have tried calling revaliate and repaint and no luck.
    I want the panel to handle this itself as it will be called from a number of frames.
    A BottomPanelManager is called by the frames to get the BottomPanel (always the same instance).
    Any help would be much appreciated
    Cheers

    You need to emulate Swing by creating a non-GUI model object to underlie the logic of this JPanel. Then create 3 new JPanels and have them all share the same model.
    edit: for instance:
    BottomPanelModel.java
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import javax.swing.Timer;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class BottomPanelModel
      private static final int DELAY = 1000;
      private SimpleDateFormat sdFormat = new SimpleDateFormat("hh:mm:ss a");
      private int delay = DELAY;
      private Timer swingTimer = new Timer(delay, new TimerListener());
      private List<ChangeListener> changeListenerList = new ArrayList<ChangeListener>();
      public BottomPanelModel(int delay)
        this.delay = delay;
        swingTimer.setDelay(delay);
        swingTimer.start();
      public BottomPanelModel()
        this(DELAY);
      public void addChangeListener(ChangeListener cl)
        changeListenerList.add(cl);
      public String getTimeString()
        Date date = new Date(System.currentTimeMillis());
        return sdFormat.format(date);
      private class TimerListener implements ActionListener
        public void actionPerformed(ActionEvent arg0)
          ChangeEvent changeEvent = new ChangeEvent(BottomPanelModel.this);
          for (ChangeListener listener : changeListenerList)
            listener.stateChanged(changeEvent);
    }BottomPanel.java
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class BottomPanel extends JPanel
      private BottomPanelModel model;
      private JLabel timeLabel = new JLabel();
      public BottomPanel(BottomPanelModel model)
        this.model = model;
        add(timeLabel);
        model.addChangeListener(new ChangeListener()
          public void stateChanged(ChangeEvent arg0)
            timeLabel.setText(BottomPanel.this.model.getTimeString());
    }BottomPanelTest.java
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class BottomPanelTest
      private static final Dimension MAIN_SIZE = new Dimension(400, 600);
      private static final int BOTTOM_COUNT = 8;
      private JPanel mainPanel = new JPanel();
      public BottomPanelTest()
        mainPanel.setLayout(new GridLayout(0, 1));
        mainPanel.setPreferredSize(MAIN_SIZE);
        BottomPanelModel bpModel = new BottomPanelModel();
        for (int i = 0; i < BOTTOM_COUNT; i++)
          BottomPanel bPanel = new BottomPanel(bpModel);
          mainPanel.add(bPanel);
      public JComponent getPanel()
        return mainPanel;
      private static void createAndShowGUI()
        JFrame frame = new JFrame("BottomPanelTest Application");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new BottomPanelTest().getPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
          public void run()
            createAndShowGUI();
    }Edited by: Encephalopathic on Jan 12, 2009 3:24 PM

  • Refreshing JLabels

    im making a grid that has jlabels which are based on a 2d array of integers..
    if i were to change the order of the elements i want the labels to swap too..
    how could i write over the old jlabel which has been set already?

    Use JLabels setText( String text ) Method
    Set up all your labels, then when you do whatever it is you are doing, change the text on the JLabels to match it.

  • Update jLabel in between Thread.sleep()'s

    I have multiple Thread.sleep()'s in my code under a jButton actionevent evt.
    In between these, I need to be able to update a jLabel, but for some reason it waits until the last thread.sleep() before it updates the jLabel.
    Any ideas why?
    private void jButtonActionPerformed(java.awt.event.ActionEvent evt) {
       try {
          Thread.sleep(1000);
          jLabel.setText("Change Text To This");
          Thread.sleep(1000);
       } catch (InterruptedException ex) {}
    }So rather than waiting 1000ms, then update label, then wait another 1000ms, it just waits 2000ms, then updates the label
    Please help!
    Thanks

    Edward9 wrote:
    I am new to Java and I just cannot work out the tutorials,Hard luck then.
    the code behind my applet doesn't matter as long as it works,Which it will, of you code it correctly after learning from the tutorials.
    I have spend 6 months on this appletWould have taken much less time to learn to do it correctly.
    and everything worksBy your definition of "works"
    apart from this one problem --> jLabel to update between thread.sleep()'s.Easy when you know how.
    Its all I need to do and my project will be over and I can get away from Java.I have a suggestion: why don't you get away from Java right now, take the failing grade you've earned, and get on with your life. Really.
    Is there absolutely no way it can be done?Already covered above and in previous responses.
    I was told the jLabel will not update until the thread is free to do so, so i will need to look up on multiple threads,No, you need to go through the Swing tutorials.
    i have tried to but none of it makes sense to what i need done.Give up. Now.
    db

  • Can some one help me with this problem with my frame???

    i have gt a veri strange problem with my program,that is teh graphic changes only when i resize the the frame,if i dun resize,it will remain the same.However what i intended is that when i click on the radio button,it will change immediately to the respective pages.A simple version of my code is below,can someone helpl me solve it??(there is 3 different class)
    import java.awt.event.*;
    import javax.swing.*;
    public class MainPg extends JFrame implements ActionListener{
         private javax.swing.JPanel jContentPane = null;
         private javax.swing.JPanel buttons = null;
         private javax.swing.JRadioButton one = null;
         private javax.swing.JRadioButton two = null;
         private javax.swing.JPanel change = null;
         public MainPg() {
              super();
              initialize();
         private void initialize() {
              this.setSize(300, 200);
              this.setContentPane(getJContentPane());
              this.setName("mainClass");
              this.setVisible(true);
         private javax.swing.JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(new java.awt.BorderLayout());
                   jContentPane.add(getButtons(), java.awt.BorderLayout.WEST);
                   jContentPane.add(getChange(), java.awt.BorderLayout.CENTER);
              return jContentPane;
         private javax.swing.JPanel getButtons() {
              if(buttons == null) {
                   buttons = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout1 = new java.awt.GridLayout();
                   layGridLayout1.setRows(2);
                   layGridLayout1.setColumns(1);
                   ButtonGroup group=new ButtonGroup();
                   group.add(getOne());
                   group.add(getTwo());
                   buttons.setLayout(layGridLayout1);
                   buttons.add(getOne(), null);
                   buttons.add(getTwo(), null);
              return buttons;
         private javax.swing.JRadioButton getOne() {
              if(one == null) {
                   one = new javax.swing.JRadioButton();
                   one.setText("One");
                   one.setSelected(true);
                   one.addActionListener(this);
                   one.setActionCommand("one");
              return one;
         private javax.swing.JRadioButton getTwo() {
              if(two == null) {
                   two = new javax.swing.JRadioButton();
                   two.setText("Two");
                   two.addActionListener(this);
                   two.setActionCommand("two");
              return two;
         private javax.swing.JPanel getChange() {
              if(change == null) {
                   change = new javax.swing.JPanel();
              change.add(new One());
              return change;
         public static void main(String[] args){
              new MainPg();
         public void actionPerformed(ActionEvent e) {
              change.removeAll();
              if("one".equals(e.getActionCommand())){
                   change.add(new One());
              else{
                   change.add(new Two());
              change.repaint();
    import javax.swing.*;
    public class One extends JPanel {
         private javax.swing.JPanel jPanel = null;
         private javax.swing.JLabel jLabel = null;
         private javax.swing.JPanel jPanel1 = null;
         private javax.swing.JLabel jLabel1 = null;
         private javax.swing.JLabel jLabel2 = null;
         public One() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.BorderLayout());
              this.add(getJPanel(), java.awt.BorderLayout.NORTH);
              this.add(getJPanel1(), java.awt.BorderLayout.WEST);
              this.setSize(300, 200);
         * This method initializes jPanel
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel() {
              if(jPanel == null) {
                   jPanel = new javax.swing.JPanel();
                   jPanel.add(getJLabel(), null);
              return jPanel;
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("one");
              return jLabel;
         * This method initializes jPanel1
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel1() {
              if(jPanel1 == null) {
                   jPanel1 = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout2 = new java.awt.GridLayout();
                   layGridLayout2.setRows(2);
                   layGridLayout2.setColumns(1);
                   jPanel1.setLayout(layGridLayout2);
                   jPanel1.add(getJLabel2(), null);
                   jPanel1.add(getJLabel1(), null);
              return jPanel1;
         * This method initializes jLabel1
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel1() {
              if(jLabel1 == null) {
                   jLabel1 = new javax.swing.JLabel();
                   jLabel1.setText("one");
              return jLabel1;
         * This method initializes jLabel2
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel2() {
              if(jLabel2 == null) {
                   jLabel2 = new javax.swing.JLabel();
                   jLabel2.setText("one");
              return jLabel2;
    import javax.swing.*;
    public class Two extends JPanel {
         private javax.swing.JLabel jLabel = null;
         public Two() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.FlowLayout());
              this.add(getJLabel(), null);
              this.setSize(300, 200);
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("two");
              return jLabel;
    }

    //change.repaint();
    change.revalidate();

  • How to do the multiple-line String at JList? help!

    i need some code to multiple-line String at JList.
    i know that it is can be done by html code.
    example:
    <p>line1</p><p>line2</p>
    but if i use that html code...
    i face another problem to my JList..
    it cannot set the font use the ListCellRenderer..
    like:
    public Component getListCellRendererComponent(
    JList list,
    Object value,
    int index,
    boolean isSelected,
    boolean cellHasFocus)
    Color newColor = new Color(230, 230, 230);
    setIcon(((DisplayItem)value).getIcon());
    setText(((DisplayItem)value).getChat());
    setFont(((DisplayItem)value).getFont());
    setBackground(isSelected ? newColor : Color.white);
    setForeground(isSelected ? Color.black : Color.black);
    if (isSelected) {
    setBorder(
    BorderFactory.createLineBorder(
    Color.red, 2));
    } else {
    setBorder(
    BorderFactory.createLineBorder(
    list.getBackground(), 2));
    return this;
    all my JList will be html type...
    i don't want that happen..can be another method to do that multiple-line String in JList??
    i also need to set a icon image between string in the JList. anyone get idea??
    i need ur help!
    thank you.

    I think you should create/override several methods like setText(String), setIcons(Icon[]), paintComponent(Graphics), getMinimumSize(), getPreferredSize(), etc.
    I would like to code like below...:class MultilineLabel extends JLabel {
        private String[] text = null;
        private ImageIcon[] icons = null;
        public void setText( String newText ) {
            // It overrides JLabel.setText( String )
            // Tokenize newText with line-separator
            // and put each text into the 'text' array.
        public void setIcons( Icon[] newIcon ) {
            // It is similar to JLabel.setIcon( Icon ) method,
            // but it receives an array of Icon-s. Set these icons to 'icons' variable.
        public void paintComponent( Graphics g ) {
            // It overrides JComponent.paintComponent( Graphics ) method.
            super.paintComponent( g );
            if ( text != null && icons != null ) {
                int icon_x = 0;
                int text_x = 0;
                int y = 0;
                // draw customized content..
                for ( int i=0; i<text.length; i++ ) {
                    // compute x and y locations
                    // icon_x = ...
                    // text_x = ...
                    // y = ...
                    // and draw it!
                    g.drawString( text[ i ], text_x, y );
                    icon[ i ].paintIcon( this, g, icon_x, y );
        public Dimension getMinimumSize() {
            int width = super.getMinimumSize().width;
            int height = ... // I think you must compute it with 'text' and 'icons'' arrays.
            return new Dimension( width, height );
        public Dimension getPreferredSize() {
            int width = super.getPreferredSize().width;
            int height = ...
            return new Dimension( width, height );
    }I think that code-structure above is the minimum to implement your requirements. (Of course if you want to implement it :)
    Good luck and let me know it works or not. :)

  • How to get the size of 'MyComponent'  when it is used in another place ?

    'My component' is JPanel based ( for example)
    I find problems to use the real size of MyComponent ( the size it has at the destiny)
    In 'Initialize' this.getheight gives me the size of the component by itself
    Must I use 'paintComponent' to know the real size or where ?
    By other side, must I count 2 paintComponent() ( the first 2 times paintCompnent is called by the 'system' , one for width and one for height ) to make sure the component is already drawed ?
    Thank you

    Yes, very simply :
    import javax.swing.JPanel;
    import java.awt.Rectangle;
    import javax.swing.JLabel;
    public class Wdes extends JPanel {
         private static final long serialVersionUID = 1L;
         private JLabel jLabel = null;
         public Wdes() {
              super();
              initialize();
         private void initialize() {
              jLabel = new JLabel();
              jLabel.setBounds(new Rectangle(8, 45, 268, 24));
              jLabel.setText("hello : mi size at destiny container is :");
              this.setLayout(null);
              this.setSize(300, 117);
              this.add(jLabel, null);     
              public void paint(Graphics g) {
              System.out.println("paint"+this.getWidth()+ " "+ this.getHeight());
         public void paintComponent(Graphics g) {
              System.out.println("paintcomponent"+this.getWidth()+ " "+ this.getHeight());
    }As you can see I have A Jlabel : jLabel.setText("hello : mi size at destiny container is :");
    Ok, I put this bean onto my application and I give it the size desired.
    I can use paint or paintcomponent to know my real size , isn't it ? ( and please forget my initial condition of 2 paint events ... -simply I come from VB ...- )
    Is there another way ?
    And, I dont know what is happen but in this example only work paint ( paintComponent does not )
    ( If i want to use paintcomponent I have to delete paint , isn't it ? )
    Thanks

  • How to use object of class in Label?

    I have defined a class "time" which runs time for 30 minutes.Now, I want to use this time in Label so that it keep running for 30mins but I am not able to pass the object in Label.

    Of course being aware that this may cause other
    difficulties if you are running a multi-threadedapp.
    SwingUtilities.invokeLater() may be required inthat
    case.I've never really been clear on which of these update
    routines should, or should not be on the dispatcher
    thread. A quick look at the source of JLabel.setText,
    for example, shows that it calls repaint on itself to
    change the presentation of text, and repaint
    shouldn't require to be on the dispatcher thread,
    since it simply adds the paint request to the TODO
    list.That makes sense, but experience doesn't bear it out... I've had deadlocks where the only thing being updated was the text of a label. Perhaps there is something else going on.

  • Java Applets and multiple classes not working.

    I have tested my JApplet class alone to view its layout and to make sure it actually works. But once I add in my other classes, compile, jar, and test I get the error:
    java.lang.NoClassDefFoundError: AlakApp (wrong name: alak/codeFiles/AlakApp)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:155)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
            at sun.applet.AppletPanel.createApplet(AppletPanel.java:779)
            at sun.applet.AppletPanel.runLoader(AppletPanel.java:708)
            at sun.applet.AppletPanel.run(AppletPanel.java:362)
            at java.lang.Thread.run(Thread.java:619)My Directory contains these and only these:
    F:\alak\codeFiles:
      AlakApp.java
      Game.java
      Board.java
      Space.java
      index.html
      AlakGame.jarAll my classes are in the package alak.codeFiles.
    My .html file contains this:
    <HTML>
    <HEAD>
      <TITLE>ALAK</TITLE>
    </HEAD>
    <BODY>
      <applet code="AlakApp.class" archive="AlakGame.jar" width=400 height=200>
      Please use a Java compatible browser to see this.
      </applet>
      <br>
    </BODY>
    </HTML>These are they commands I am issuing:
    F:\alak\codeFiles>javac *.java
    F:\alak\codeFiles>jar -cvf AlakGame.jar *.class
    F:\alak\codeFiles>appletviewer index.htmlI've been trying many different things to narrow down what is going on. If you need to see my code let me know, but I've tested everything with a text-based user interface and they work.
    So does anyone know the cause of this error?

    Ok i rared the test and uploaded to rapidshare.. here is the link:
    http://rapidshare.com/files/76860865/test.rar.html
    But here is the code. They are in the directory /test/files/
    ADigit.java
    package test.files;
    public class ADigit
      private int value;
      public ADigit( int val )
       this.value = val;
      public String toString()
       return "" + this.value;
    }ADigitApp.java
    package test.files;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ADigitApp extends JApplet implements ActionListener
      private ADigit numeroUno;
      private int currentNum;
      private Container container;
      private javax.swing.JLabel jLabel;
      private javax.swing.JTextArea jTextArea;
      private javax.swing.JButton jButton;
      public void init()
        currentNum = 1;
        numeroUno = new ADigit( currentNum );
         container = getContentPane();
        container.setLayout( new BorderLayout() );
         jLabel = new javax.swing.JLabel();
         jTextArea = new javax.swing.JTextArea();
         jLabel.setText( "The Number is: " );
         jTextArea.setText( numeroUno.toString() );
         jButton = new javax.swing.JButton();
         jButton.setText( "New Number" );
        jButton.addActionListener( this );
         container.add( jLabel, BorderLayout.WEST );
         container.add( jTextArea, BorderLayout.CENTER );
         container.add( jButton, BorderLayout.EAST );
        setSize( 200, 200 );
      public void actionPerformed( ActionEvent e )
        this.currentNum++;
         numeroUno = new ADigit( this.currentNum );
         jTextArea.setText( numeroUno.toString() );
    }index.html
    <HTML>
    <HEAD>
      <TITLE>NUMBERSSSS</TITLE>
    </HEAD>
    <BODY>
      <applet code="ADigitApp.class" archive="NumberFun.jar" width=200 height=200>
      Please use a Java compatible browser to see this.
      </applet>
      <br>
    </BODY>
    </HTML>Commands:
    /test/files>javac *.java
    /test/files>jar -cvf NumberFun.jar *.class
    /test/files>appletviewer index.htmlThis example produces the same style of error.

  • Runtime in JNLP

    When I run below code as standalone, the notepad is coming up successfully.
    but when i run through jnlp i could only see the frame with OK button. but the note pad is not popping up.
    I run this example in eclipse.
    Example.java
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    * An Example Application
    * "Hello JNLP!"
    public class Example extends JDialog {
      JPanel panel1 = new JPanel();
      BorderLayout borderLayout1 = new BorderLayout();
      JLabel jLabel = new JLabel();
      JPanel southPanel = new JPanel();
      JButton okButton = new JButton();
      public Example(Frame frame, String title, boolean modal) {
        super(frame, title, modal);
        try {
            initUI();
            pack();
        } catch(Exception ex) {
          ex.printStackTrace();
      public Example() {
        this(null, "", true);
      void initUI() throws Exception {
           try{
                  Runtime rt = Runtime.getRuntime();
                  Process p = rt.exec("notepad");
                  }catch(Exception ex){System.out.println(ex.toString());}
        panel1.setLayout(borderLayout1);
        jLabel.setHorizontalAlignment(SwingConstants.CENTER);
        jLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        jLabel.setLabelFor(okButton);
        jLabel.setText("<html><body><h1>Hello JNLP!");
        okButton.setToolTipText("close the example dialog");
        okButton.setText("<html><body><tt>OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dismiss();
        setTitle("Example Dialog");
          addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              dismiss();
        getContentPane().add(panel1);
        panel1.add(jLabel, BorderLayout.NORTH);
        panel1.add(southPanel, BorderLayout.SOUTH);
        southPanel.add(okButton, null);
        pack();
        setVisible(true);
       * the Main method
      static public void main(String[] args) {
        Example e = new Example();
       * dismiss the dialog
      void dismiss() {
        System.exit(0);
    }Example.jnlp (/WebContent)
    <?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for SwingSet2 Demo Application -->
    <jnlp
      spec="1.0+"
      codebase="http://localhost:8080/JnlpDemo"
      href="example.jnlp">
      <information>
        <title>Demo Application</title>
        <vendor>Sun Microsystems, Inc.</vendor>
        <description>This is a Demo Application</description>
        <description kind="short">A demo.</description>
        <icon href="images/demologo.gif"/>
        <offline-allowed/>
      </information>
      <security>
      </security>
      <resources>
        <j2se version="1.3+"/>
        <jar href="example.jar"/>
      </resources>
      <application-desc main-class="Example"/>
    </jnlp>

    >
    also I have set the permissions as <all-permissions />>When did you do that? It wasn't in the original JNLP file. If you mean since then, note that JWS can be terrible with caching JNLP files (it is hard to update the JNLP). Try establishing a new location(1) for the Java cache and try it again.
    >
    But I dont see notepad running when run in browser. >I am not sure what that means. Especially with the mention of ..
    >
    I kept the jnlp jar in the lib folder of my web application ..>..'web application'. Do you mean you are launching the JNLP from a link in a web page? Or something else?
    (1) Another poster mentioned making sure you see the Java Console when you launch the app., and I have mentioned changing the cache location. Both of these are configured in the [Java Control Panel|http://java.sun.com/docs/books/tutorial/information/player.jnlp] (JCP).
    Set cache location
    After clicking that link, the JCP should be open, probably pointing to the Java Cache Viewer. Close the cache viewer and click 'Settings' in the Temporary Internet Files section to Change the cache location.
    Configure the console to pop up
    Navigate to the Advanced tab of the JCP. Expand the Settings tree to show the Java Console group, and ensure the Show Console option is selected.
    Note that your original code should have been dumping the Exception.toString() to the System.out, but I recommend you change that to dump the exception stacktrace instead. It is more informative.
    I also have some example build/source for doing a trusted project, but I think it is more productive to get this one working.
    But just to check one thing. Are you being prompted to run the digitally signed code?

  • Displaying a JFrame at the centre of the screen

    Hi,
    I ve developed a GUI,
    i want it to display at center of the screen each time i run the application,
    i ve tried several options, but none of them works..
    first i set the location of jframe..didnt work!!
    {color:#ff0000}
    this.setLocation(500,500);{color}
    then i used this.. not working..
    {color:#ff0000}
    this.setLocationRelativeTo(null);{color}
    then i wrote separate method n call it in my initialize().. still not working
    {color:#ff0000}
    Toolkit tk = Toolkit.getDefaultToolkit ();
    Dimension screen = tk.getScreenSize ();
    int lx = (int) (screen.getWidth () * 3/8);
    int ly = (int) (screen.getHeight () * 3/8);
    f.setLocation (lx,ly);{color}
    if anyone can help me, pls reply..
    thanks,
    dush

    hi,
    here is the complete code,
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JSplitPane;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import java.awt.Rectangle;
    import javax.swing.ImageIcon;
    import java.awt.Dimension;
    import java.awt.*;
    public class index extends JFrame {
         private static final long serialVersionUID = 1L;
         private JSplitPane jSplitPane = null;
         private JSplitPane jSplitPane1 = null;
         private JPanel jPanel = null;
         private JButton jButton = null;
         private JButton jButton1 = null;
         private JLabel jLabel = null;
         public index() {
              super();
              initialize();
         private void initialize() {
              this.setLocation(500,500);
              this.setContentPane(getJSplitPane());
              this.setLocationRelativeTo(null);
              this.setBounds(new Rectangle(500, 500, 462, 305));
              this.setTitle("GUI");
              this.setSize(new Dimension(462, 305));
              this.setResizable(false);
              this.setPreferredSize(new Dimension(350, 500));
              this.setVisible(true);
              centerFrame (this);
         private JSplitPane getJSplitPane() {
              if (jSplitPane == null) {
                   jSplitPane = new JSplitPane();
                   jSplitPane.setDividerLocation(150);
                   jSplitPane.setDividerSize(0);
                   jSplitPane.setRightComponent(getJSplitPane1());
              return jSplitPane;
         private JSplitPane getJSplitPane1() {
              if (jSplitPane1 == null) {
                   jSplitPane1 = new JSplitPane();
                   jSplitPane1.setDividerLocation(250);
                   jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
                   jSplitPane1.setTopComponent(getJPanel());
                   jSplitPane1.setDividerSize(0);
              return jSplitPane1;
         private JPanel getJPanel() {
              if (jPanel == null) {
                   jLabel = new JLabel();
                   jLabel.setBounds(new Rectangle(66, 39, 179, 38));
                   jLabel.setText("  GUI ");
                   jPanel = new JPanel();
                   jPanel.setLayout(null);
                   jPanel.add(getJButton(), null);
                   jPanel.add(getJButton1(), null);
                   jPanel.add(jLabel, null);
              return jPanel;
         private JButton getJButton() {
              if (jButton == null) {
                   jButton = new JButton();
                   jButton.setBounds(new Rectangle(98, 92, 104, 50));
                   jButton.setIcon(new ImageIcon(getClass().getResource("/images/mail.jpg")));
                   jButton.setText("GUI");
                   jButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             first ff=new first();
                             ff.setVisible(true);
                             dispose();
              return jButton;
         private JButton getJButton1() {
              if (jButton1 == null) {
                   jButton1 = new JButton();
                   jButton1.setText("Exit");
                   jButton1.setBounds(new Rectangle(134, 184, 55, 26));
                   jButton1.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             System.exit(0);
              return jButton1;
          void centerFrame (JFrame f) {
                  // Need the toolkit to get info on system.
                  Toolkit tk = Toolkit.getDefaultToolkit ();
                  // Get the screen dimensions.
                  Dimension screen = tk.getScreenSize ();
                  // Make the frame 1/4th size of screen.
                  int fw =  (int) (screen.getWidth ()/3);
                  int fh =  (int) (screen.getWidth ()/4);
                  f.setSize (fw,fh);
                  // And place it in center of screen.
                  int lx =  (int) (screen.getWidth ()  * 3/8);
                  int ly =  (int) (screen.getHeight () * 3/8);
                  f.setLocation (lx,ly);
                } // centerFrame
    }  //  @jve:decl-index=0:visual-constraint="56,39"Edited by: dush82 on Oct 3, 2007 11:02 PM
    Edited by: dush82 on Oct 3, 2007 11:10 PM

  • Is it a bug in 1.4.2_04

    public class MainFrame extends JFrame implements ActionListener
    JLabel jLable = new JLabel();
    static int i = 0;
    public MainFrame()
    jLabel.setText("sometext");
    //some button defined here and added actionlistener.
    public void actionPerformed(ActionEvent e)
    jLabel.setText(++i);
    I click on the button, the text on the jLable is 0, but at the second and also the following clicks on the button to triggle the actionPerformed method, the text on the jLabel doesn't change, still remaining 0. I'm confused, so I changed javax.swing.JLabel to java.awt.Label, everything appears just as I expected. Eaching clicking makes the number on the label increase by 1. Is it a bug of javax.swing.JLabel of 1.4.2_04?

    Thank you very much for your advice, and below is my real codes. I'm sorry the JLabel in my real codes was added to a panel, not the JFrame. I didn't believe it was a bug until I compared it with in java.awt.Label.
    * Created on 2004-6-5
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.jpdragon.product;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.FlowLayout;
    //import java.awt.Label;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Properties;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JLabel;
    * @author elgs
    * TODO To change the template for this generated type comment go to Window -
    * Preferences - Java - Code Style - Code Templates
    public class MainFrame extends JFrame implements ActionListener
         Connection               connection;
         PreparedStatement     pstatement;
         ResultSet               rs;
         Container               content               = getContentPane();
         JPanel                    pn                    = new JPanel();
         JPanel                    pc                    = new JPanel();
         JPanel                    ps                    = new JPanel();
         JPanel                    pt                    = new JPanel();
         (J)Label                    lr                    = new Label();
         LabelPanel               labelPanel          = new LabelPanel("No.&#65289;",
                                                                "0000000000", 7);
         JButton                    addButton          = new JButton("Add *");
         JButton                    removeButton     = new JButton("Remove *");
         Properties               p                    = new Properties();
         JTable                    t                    = new JTable();
         JScrollPane               s                    = new JScrollPane();
         String[]               names               =
                                                      {"code", "name"};
         TableModel               tableModel          = new TableModel();
         public MainFrame() throws ClassNotFoundException, FileNotFoundException,
                   IOException, SQLException
              p.load(new FileInputStream("star.properties"));
              Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
              labelPanel.getTheField().selectAll();
              setTitle("2004-06-06");
              content.setLayout(new BorderLayout());
              pc.setLayout(new BorderLayout());
              ps.setLayout(new FlowLayout());
              content.add(pn, BorderLayout.NORTH);
              content.add(pc, BorderLayout.CENTER);
              content.add(ps, BorderLayout.SOUTH);
              addButton.addActionListener(this);
              removeButton.addActionListener(this);
              pn.add(labelPanel);
              ps.add(addButton);
              ps.add(removeButton);
              s.setViewportView(t);
              pt.add(s);
              lr.setText("Total: " + 0);
              pc.add(pt, BorderLayout.CENTER);
              pc.add(lr, BorderLayout.SOUTH);
              String url = p.getProperty("url");
              String username = p.getProperty("username");
              String password = p.getProperty("password");
              connection = DriverManager.getConnection(url, username, password);
              pstatement = connection
                        .prepareStatement("select max(num) from prcadj where cls='lprice'");
              ResultSet rs = pstatement.executeQuery();
              if (rs.next())
                   labelPanel.setField(rs.getString(1).trim());
              pstatement.close();
              pack();
         * (non-Javadoc)
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         public void actionPerformed(ActionEvent e)
              addButton.setEnabled(false);
              removeButton.setEnabled(false);
              String sql_view = "";
              String sql_exe = "";
              String title = "";
              String msg_view = "";
              String msg_exe = "";
              String no = labelPanel.getText().trim();
              Component src = (Component) e.getSource();
              if (src == addButton)
                   sql_view = "select g.code,g.name from prcadjdtl p,goods g "
                             + "where num = ? and cls ='lprice' "
                             + "and p.gdgid = g.gid and g.name not like '*%'";
                   title = "Add *";
                   msg_view = "Are you sure to add *?";
                   msg_exe = "items have been added with *";
                   sql_exe = "update goods set name = '*'+ name from prcadjdtl p,goods g "
                             + "where num = ? and cls ='lprice' "
                             + "and p.gdgid = g.gid "
                             + "and g.name not like '*%'";
              if (src == removeButton)
                   sql_view = "select g.code,g.name from prcadjdtl p,goods g "
                             + "where num = ? and cls ='lprice' "
                             + "and p.gdgid = g.gid and g.name like '*%'";
                   title = "Remove *";
                   msg_view = "Are you sure to remove *?";
                   msg_exe = "items have been removed *";
                   sql_exe = "update goods set name = substring(name,2,len(name)-1) from prcadjdtl p,goods g "
                             + "where num = ? and cls ='lprice' "
                             + "and p.gdgid = g.gid "
                             + "and g.name like '*%'";
              try
                   pstatement = connection.prepareStatement(sql_view,
                             ResultSet.TYPE_SCROLL_INSENSITIVE,
                             ResultSet.CONCUR_READ_ONLY);
                   pstatement.setString(1, no);
                   rs = pstatement.executeQuery();
                   tableModel.set(rs);
                   tableModel.setName(names);
                   t.setModel(tableModel);
                   s.setViewportView(t);
                   pt.add(s);
                   lr.setText("total: " + tableModel.getRowCount());
                   pstatement.close();
                   pack();
                   int answer = JOptionPane.showConfirmDialog((Component) content,
                             msg_view, title, JOptionPane.YES_NO_OPTION);
                   if (answer == JOptionPane.YES_OPTION)
                        pstatement = connection.prepareStatement(sql_exe);
                        pstatement.setString(1, no);
                        int rowsAffected = pstatement.executeUpdate();
                        t.setModel(new TableModel());
                        JOptionPane.showMessageDialog((Component) content, rowsAffected
                                  + msg_exe, title, JOptionPane.INFORMATION_MESSAGE);
                   addButton.setEnabled(true);
                   removeButton.setEnabled(true);
                   pack();
              catch (SQLException e1)
                   System.out.println(e1);
    }

Maybe you are looking for

  • Am unable to reset Pram anymore

    I have a 2010 intel iMac. I've always been able to reset my pram by holding down the command key, option key, P and R at startup. It has never failed. I went to resest it yesterday after noticing my mute key no longer works to find out that the comma

  • Copy Paragraph Style doesn't do its job all the time.

    If I have a paragraph style in pink, I will select that text, copy paragraph style and paste it onto another selection of text, turning it pink also. Usually, if I past the style onto a selection of text in the MIDDLE of a sentence, it will turn the

  • Zen Sleek Photo on Windows 98

    My 20GB Zen Sleek Photo arri'ved today, but my computer won't let me run the installation disc. It keeps giving me a message saying that the Windows operating system on my computer is not supported by the product. Is there any way of getting around t

  • IDVD menu buttons missing

    When I open the theme menu pages neither the "Play Film" or "Scene Selection" buttons appear. Anyone else have this problem? Any solutions? I've looked through the basic help pages and David Pogues iMovie&iDVD book. Nada... Is there any way to add th

  • Cant see my photos at facebook enymore

    when i open facebook the windows of photos are blanked!!ww