Repainting VI windows

Hallo LV'ers,
I'm running LV5.1.1. I have an application where I have a parent window
which stays the same all the time. Within this parent window I display
different child windows in a sequence. Each of the childs is docked to the
parent by means of some WinAPI functions like SetParent (I'm using the
G-Toolbox). It works fine. Now the problem: Every time a child is docked to
the parent, the entire parent window is repainted, even the parts of it
which are left unchanged. That causes the screen to flicker in a not very
nice way.
Is there a way to define the region of the parent window to be repainted, so
that only the region of the childs are repainted. I know of this commands in
the WinAPI, but how can I do this in LV ? Do I have t
o use WinAPI commands
to solve this problem?
Best thanks for your help!
Oliver Friedrich

Maybe the next time, I'll think about programming platform-independent.
I thought of your solution, but I've discarded it after considering a few
more constraints in my application.
1. I don't want the child window to be movable.
2. The child has neither menubar, nor frames or resizing or close buttons, I
want it not to be recognizable as a separate window.
3. I want to have the parent still capable of getting the focus.
So, there are quite some problems with modal windows. And further more, my
product requirement specifications tells me to develop for Win98, NT and so
on, so what ?
Anyway, thanks a lot for your help, I hope I can help you one of these days.
Best regards
Oliver
"Labviewguru" schrieb im Newsbeitrag
news:50650000000500000
[email protected]..
> Oliver,
>
> My recommendation is to change your methodology. Get away from MS
> native functions. This will solve your problems, and make your
> program platform independent.
>
> As an alternative, try calling the front panel either as visible using
> the server, or directly. Then you can set it to frontmost or dialog,
> as necessary, and even control it's location. This should (though I
> haven't researched it much) solve your problems. This also puts you
> back in the driver's seat instead of Microsoft. This is a good
> discipline to have, if you ever decide (or have it decided for you) to
> program outside of Microsoft.

Similar Messages

  • Problem repaint ( Refresh ) window

    Hi Friends,
    I have GUI JFrame window , in which i have added
    combo box and add button when i click add one new JFrame window
    opens and ask for name and when click OK, that is added to database.
    1) Main Window in which add button is there
    2) Secondary JFrame inputs the Username
    Now i want to show name should be added in Main Window's combo
    while clicking the Secondary windows OK button.
    How can I repaint thing ??
    I tried
    panel.updateUI( )but still it not showing me new added name.
    When i close application and restart it , it will showing me last added name , but it should not be the solution.
    HELP.

    MyExpenseTracker.java
    (Main Class)
    * MyExpenseTracker.java
    * Created on October 11, 2007, 6:10 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package app;
    import app.AddNewItem;
    import java.util.*;
    * @author Administrator
    public class MyExpenseTracker
        /** Creates a new instance of MyExpenseTracker */
        public MyExpenseTracker()
        public static void main(String args[])   
                ExpTracker t = new ExpTracker();
                MyExpenseTracker mymain = new MyExpenseTracker();
                //LoginForm loginf = new LoginForm();
                t.setVisible(true);
    }ExpTracker.java ( Main Window for project - no main method )
    * ExpTracker.java
    * Created on October 11, 2007, 1:39 PM
    package app;
    import app.AddNewItem;
    import app.AddNewName;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    * @author  Administrator
    public class ExpTracker extends javax.swing.JFrame
        /** Creates new form ExpTracker */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        //String user =loginf.getAuthenticatedUser();
        Calendar cal = Calendar.getInstance();
        int day = cal.get(Calendar.DATE);
        int month = cal.get(Calendar.MONTH)+1;
        int year = cal.get(Calendar.YEAR);
        public ExpTracker()
            super("Expense Tracker v1.0");
            initComponents();
            //System.out.println("User name got :"+user);
            //javax.swing.JOptionPane.showMessageDialog(this,"Username:"+ user);
            //System.out.println("user :"+user);
            loadNameCombo();
            cmbdate.setSelectedItem(day);
            cmbmonth.setSelectedIndex(month-1);
            cmbyear.setSelectedItem(year);
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jp1 = new javax.swing.JPanel();
            lbldate = new javax.swing.JLabel();
            cmbdate = new javax.swing.JComboBox();
            cmbmonth = new javax.swing.JComboBox();
            cmbyear = new javax.swing.JComboBox();
            lblfixdate = new javax.swing.JLabel();
            lblitem = new javax.swing.JLabel();
            cmbitem = new javax.swing.JComboBox();
            lblqty = new javax.swing.JLabel();
            tfqty = new javax.swing.JTextField();
            lblprice = new javax.swing.JLabel();
            tfprice = new javax.swing.JTextField();
            lblqtyfix = new javax.swing.JLabel();
            lblpricefix = new javax.swing.JLabel();
            btnAdd = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            lblname = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            ta = new javax.swing.JTextArea();
            btnReport = new javax.swing.JButton();
            btnAddRecord = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            cmbname = new javax.swing.JComboBox();
            btnAddname = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            menu1exit = new javax.swing.JMenuItem();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jp1.setBorder(javax.swing.BorderFactory.createTitledBorder("Expense Detail"));
            lbldate.setFont(new java.awt.Font("Tahoma", 0, 10));
            lbldate.setText("Date :");
            cmbdate.setFont(new java.awt.Font("Tahoma", 0, 10));
            for(int i=1; i<=31; i++)
                cmbdate.addItem(i);
            cmbmonth.setFont(new java.awt.Font("Tahoma", 0, 10));
            cmbmonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }));
            cmbyear.setFont(new java.awt.Font("Tahoma", 0, 10));
            for(int i=2006; i<=2050; i++)
                cmbyear.addItem(i);
            lblfixdate.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblfixdate.setText("*Format is dd-MM-yyyy");
            lblitem.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblitem.setText("Item :");
            cmbitem.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqty.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqty.setText("Quantity :");
            tfqty.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblprice.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblprice.setText("Price :");
            tfprice.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqtyfix.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblqtyfix.setText("*you can write like 2 ,3 or 300gm");
            lblpricefix.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblpricefix.setText("*ex. 300, 13.50 etc. no characters");
            btnAdd.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAdd.setText("Add");
            btnAdd.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddActionPerformed(evt);
            jLabel1.setFont(new java.awt.Font("Tahoma", 0, 10));
            jLabel1.setText("*if item is not in list, click Add button");
            org.jdesktop.layout.GroupLayout jp1Layout = new org.jdesktop.layout.GroupLayout(jp1);
            jp1.setLayout(jp1Layout);
            jp1Layout.setHorizontalGroup(
                jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jp1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jp1Layout.createSequentialGroup()
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, lblitem, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, lbldate, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jp1Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbmonth, 0, 59, Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmbyear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(jp1Layout.createSequentialGroup()
                                    .add(10, 10, 10)
                                    .add(lblfixdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(cmbitem, 0, 168, Short.MAX_VALUE)
                                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)))
                        .add(jp1Layout.createSequentialGroup()
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(lblqty)
                                .add(lblprice))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(tfprice, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                                .add(tfqty, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                                .add(lblqtyfix, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                                .add(lblpricefix, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(btnAdd, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addContainerGap())
            jp1Layout.setVerticalGroup(
                jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jp1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(lbldate)
                        .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(cmbyear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(cmbdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(cmbmonth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(5, 5, 5)
                    .add(lblfixdate)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblitem)
                        .add(cmbitem, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(btnAdd))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jLabel1)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblqty)
                        .add(tfqty, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(1, 1, 1)
                    .add(lblqtyfix)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jp1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblprice)
                        .add(tfprice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(lblpricefix)
                    .addContainerGap(41, Short.MAX_VALUE))
            lblname.setFont(new java.awt.Font("Tahoma", 0, 10));
            lblname.setText("Name :");
            ta.setColumns(20);
            ta.setLineWrap(true);
            ta.setRows(5);
            jScrollPane1.setViewportView(ta);
            btnReport.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnReport.setText("Report");
            btnAddRecord.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAddRecord.setText("Add New Expense");
            jLabel2.setFont(new java.awt.Font("Tahoma", 0, 10));
            jLabel2.setText("Comments :");
            cmbname.addFocusListener(new java.awt.event.FocusAdapter()
                public void focusGained(java.awt.event.FocusEvent evt)
                    cmbnameFocusGained(evt);
            btnAddname.setFont(new java.awt.Font("Tahoma", 0, 10));
            btnAddname.setText("Add");
            btnAddname.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddnameActionPerformed(evt);
            menu.setText("File");
            menu1exit.setText("Exit");
            menu1exit.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    menu1exitActionPerformed(evt);
            menu.add(menu1exit);
            jMenuBar1.add(menu);
            setJMenuBar(jMenuBar1);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jp1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .add(10, 10, 10)
                            .add(btnReport, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(28, 28, 28)
                            .add(btnAddRecord, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(layout.createSequentialGroup()
                            .add(lblname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(15, 15, 15)
                            .add(cmbname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 194, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(btnAddname, 0, 0, Short.MAX_VALUE)
                            .add(28, 28, 28)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 253, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                            .add(39, 39, 39)
                            .add(jLabel2)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jScrollPane1))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                            .add(20, 20, 20)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(lblname)
                                .add(cmbname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(btnAddname))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jp1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(btnReport)
                        .add(btnAddRecord))
                    .addContainerGap(15, Short.MAX_VALUE))
            pack();
        }// </editor-fold>                       
        private void cmbnameFocusGained(java.awt.event.FocusEvent evt)                                   
    // TODO add your handling code here:
           this.jp1.updateUI();
        public void loadNameCombo()
            doConnection();
            try{
                query ="select name from name_master";
                rs = stmt.executeQuery(query);
                while(rs.next())
                    cmbname.addItem(rs.getString("name"));
            }catch(Exception e){ e.printStackTrace(); }
             // this.repaint();    
        public void reloadComboName()
            cmbname.removeAllItems();
            loadNameCombo();
            this.repaint();
        public void loadItemCombo()
            doConnection();
            try{
                query ="select item_name from item_master";
                rs = stmt.executeQuery(query);
                while(rs.next())
                    cmbitem.addItem(rs.getString("item_name"));
            }catch(Exception e){ e.printStackTrace(); }
        private void btnAddnameActionPerformed(java.awt.event.ActionEvent evt)                                          
    // TODO add your handling code here:
            AddNewName n = new AddNewName();
            n.setVisible(true);
        private void btnAddActionPerformed(java.awt.event.ActionEvent evt)                                      
    // TODO add your handling code here:
            AddNewItem i = new AddNewItem();
            i.setVisible(true);
        private void menu1exitActionPerformed(java.awt.event.ActionEvent evt)                                         
            // TODO add your handling code here:
             System.out.println("Current :"+ day +":"+month+":"+year);
    }AddNewName.java
    * AddNewName.java
    * Created on October 13, 2007, 2:52 PM
    package app;
    import app.ExpTracker;
    import java.sql.*;
    import java.util.Vector;
    * @author  Administrator
    public class AddNewName extends javax.swing.JFrame
        /** Creates new form AddNewName */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        public AddNewName()
            initComponents();
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        public void doInsert()
            String name2add = tfnameadd.getText().trim();
            query = "INSERT INTO name_master(name) VALUES ('"+name2add+"')";
            System.out.println("QUERY:"+query);
            try
               status = stmt.executeUpdate(query);
               //System.out.println("Query Status :"+status);
               //con.commit();
            } catch (SQLException ex)
                ex.printStackTrace();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jPanel1 = new javax.swing.JPanel();
            lblnewname = new javax.swing.JLabel();
            tfnameadd = new javax.swing.JTextField();
            btnaddname = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Add New Name"));
            lblnewname.setText("Enter Name :");
            tfnameadd.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnaddname.setText("Add Name");
            btnaddname.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnaddname.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnaddnameActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(btnaddname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 108, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jPanel1Layout.createSequentialGroup()
                            .add(lblnewname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(37, 37, 37)
                            .add(tfnameadd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 218, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(20, Short.MAX_VALUE))
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(lblnewname)
                        .add(tfnameadd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(btnaddname, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                    .addContainerGap())
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        private void btnaddnameActionPerformed(java.awt.event.ActionEvent evt)                                          
    // TODO add your handling code here:
            ExpTracker et = new ExpTracker();
             doConnection();
             doInsert();
                if(status == 1)
                    javax.swing.JOptionPane.showMessageDialog(this,"Record Inserted Successfully.");
                    this.setVisible(false);
                    et.repaint();
                    et.reloadComboName();
                    //this.repaint();
                else
                    javax.swing.JOptionPane.showMessageDialog(this,"Record Failed to Insert.","Error",2);
         * @param args the command line arguments
        // Variables declaration - do not modify                    
        private javax.swing.JButton btnaddname;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JLabel lblnewname;
        private javax.swing.JTextField tfnameadd;
        // End of variables declaration                  
    }AddNewItem.java
    * AddNewItem.java
    * Created on October 13, 2007, 2:19 PM
    package app;
    import java.sql.*;
    import java.util.*;
    * @author  Administrator
    public class AddNewItem extends javax.swing.JFrame
        /** Creates new form AddNewItem */
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        String query;
        int status =0;
        String URL="jdbc:mysql://localhost:3306/exptracker";
        String DRIVER ="com.mysql.jdbc.Driver";
        public AddNewItem()
            super("Add New Item");
            initComponents();
        public void doConnection()
            //make connection
            try
                Class.forName(DRIVER).newInstance();
            catch(Exception e)
            { System.out.println("driver not found"+e.getMessage());     }
            //making query
            try
                con = DriverManager.getConnection(URL, "root", "");
                stmt = con.createStatement();
            catch(Exception e)
            { System.out.println("Connection Failure !"+ e.getMessage());  }
        public void doInsert()
            String item2add = tfadditem.getText().trim();
            query = "INSERT INTO item_master(item_name) VALUES ('"+item2add+"')";
            System.out.println("QUERY:"+query);
            try
               status = stmt.executeUpdate(query);
               //System.out.println("Query Status :"+status);
               //con.commit();
            } catch (SQLException ex)
                ex.printStackTrace();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents()
            jPanel1 = new javax.swing.JPanel();
            lblitemname = new javax.swing.JLabel();
            tfadditem = new javax.swing.JTextField();
            btnAddItem = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setAlwaysOnTop(true);
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Add New Item"));
            lblitemname.setText("Item to add :");
            tfadditem.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnAddItem.setText("Add Item");
            btnAddItem.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            btnAddItem.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(java.awt.event.ActionEvent evt)
                    btnAddItemActionPerformed(evt);
            org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jPanel1Layout.createSequentialGroup()
                    .add(18, 18, 18)
                    .add(jPanel1Layout.createParallelGroup(org.jd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • JFrames issues repainting dialog windows

    I have an application with a JFrame as the main window. In this window are several components (buttons and a table). Clicking on the buttons opens various dialogs one of the buttons opens another JFrame (was/is a separate application). Everything works fine until this second JFrame is closed. After it is closed all the other dialog windows that now open are "unpainted" until you mouse over each component.
    What am I doing wrong?
    -Tad

    Well originally I was having problems with frame 1 repainting after closing frame2. I fixed that by passing a reference of frame one to frame 2 and when frame 2 closes I update(g) on frame 1 and that fixed the problem. But I'm not adding any of the components to other frames. I don't understand how closing the frame could cause problems repainting dialogs in the other frame especially ones that are called as the static JOptionPane.showMessageDialog(....). I mean everytime you call that shouldn't it be creating an entirely new "window"? why would it paint ok the first time? but not after opening closing another frame?

  • Repainting the Window

    I have a loop that does some extensive calculations. While the calculation takes time I would like to show litle dialog informing the user about the calculation phase.
    So, I made a litle JWindow descendant with a progress bar and few JLabels.
    Before I enter the loop I set the window visible. During the loop I set the text of the labels and step up the progress bar. After the loop is terminated I close the window.
    The problem is that the content of the window is not visible, only a gray rectangle is painted in position of window.
    How can I force the window to proccess all pending messages from the message queue:?
    Thanks

    Hi Stojan,
    some hints for threads (relevant for Swing):
    - updating a Component should ONLY happen in the event-dispatching thread (AWT)
    - performing time consuming calculations should NOT happen in the AWT-Thread
    Information about threads and Swing you can get at
    http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html
    Here's a simple example:
    public void actionPerformed(..){
    if (source==calcButton){
    worker = new MyRun();
    SwingUtilities.invokeLater( worker);
    Runnable worker;
    class MyRun implements Runnable{
    boolean running;
    public void run(){
    running = true;
    // do your calculation here, but no GUI update
    running = false;
    To ask the status of calculation, you can use a timer and ask every second
    if worker.running is true.
    Hope this helps.
    Oliver

  • First Record is repeated twice in main window of script

    Dear All,
    I am developing a Script form, which contains 3 windows Header,Main and Footer. My Problem is that in Main window
    the first record is repeated twice and the remaining all records
    are ok. I am unable to solve this issue of stopping the duplicate
    first record. Your response might be helpfull to me.
    Regards,

    I came across this prob today too.
    I did some digging, maybe it is something with the window type, this prob only occurs when the type of the window is continuious, and it is only possible for the main window to be set to the continuious type.
    The only way, as far as I know, is that you can put those your wanna print in a text element. And by doing so, the prob is gone. But, do pay attention to those are not continuious type windows, and remember that they are variable. The content of the windows like those, are only kept until the next write_form is called to repaint the window content and any content of the ex-window would vanish without a trace. And if you also put the content of the variable windows in a text element, there will be some format confusion getting in the way.
    That is all I got, But I still have no idea about the course.

  • Multiple severe performance issues under Windows

    I own a Macbook Pro, and have used it happily for around a year. However, the hard drive was too small (no idea why I decided to go for the 80), and my music library kept growing. At the same time, I needed a Windows machine for various other purposes, so I bought a Dell with Vista. I successfully transferred all of my music over to it, and downloaded iTunes. It installed fine, and all of my music showed up, and plays.
    Here are the problems. Compared to OS X, iTunes on Windows *****. Unbelievably. It's incredibly sluggish (even basic things like scrolling through your library - smooth as silk on the Mac, but choppy on Windows. Resizing the window doesn't work well, either), and it has to have at least a few major memory leaks.
    I'll give you some specifics.
    Acting "Sluggish"
    - Scrolling through my library (with either the scroll wheel of the mouse or the scrollbar on the right) is very choppy. This is not the case with any other application on my computer - scrolling through a list of entries is smooth and works well.
    - Resizing the window frequently doesn't work. I'll grab the corner, and move the mouse over to another area. The mouse will be on a different part of the screen, but the iTunes window will not have resized at all. If I move the mouse, the window then resizes to where the mouse last was. In other words, if I want to resize the window, I have to grab the corner, drag to another size that I think I want, and then move the mouse a little to get it to go. This animation is also very choppy.
    - Coverflow is very slow and moves at a very low framerate, fullscreen or otherwise.
    - Oftentimes, the first keystroke (or two) will be completely ignored. So, for example, I'll hit Ctrl+L to get to the currently playing song, and have to press it 2 or 3 times in order for it to have any effect.
    Memory Issues
    - When I start iTunes (in the smallest window possible), it takes around 56 MB of memory, not playing anything. Once I start to play a song, it jumps a little, but ultimately doesn't change that much (now it's at 60 MB instead). I resized the window to be on most of the screen, and it's now at 66. Scrolling through my library on List View, while slow and choppy, doesn't take up any significant amount of memory. However, as soon as I change to either the "grouped with artwork" option or coverflow, bad things start happening.
    - Grouped with Artwork: At the beginning, iTunes is taking up 70 MB of memory. Every time I hit Page Down, another 3-4 MB of memory is added. This memory is never released. So now, having scrolled down from the top a little, iTunes is now sitting at twice what it was at the beginning, or 145 MB. It's now taking up more memory than Firefox.
    - Coverflow: Starting out at 145 MB from the earlier view, switching to coverflow immediately makes the memory jump to 170 MB. When I scroll through the albums, the memory then jumps anywhere from 40 - 50 MB. After a bit of clicking, iTunes is now taking up 1,106 MB of memory.
    I minimize iTunes, and 1 MB of memory is freed. iTunes is now at 1,105 MB.
    Moving out of CoverFlow view does a good job at cutting some memory use, but it's still at 540 MB. And at this point, I'm back to where I started (in terms of what iTune's doing: list mode, small window, not playing), only at 9 times the memory use. As far as I know, there's no way to reclaim that memory.
    Various Issues
    - iTunes will frequently disregard the first or even second keystroke, as mentioned above.
    - This scenario is a little harder to describe, but I'll do my best. iTunes is the foremost application. The focus is on song panel (the main part), so that pressing the Up and Down arrow keys cause the "currently selected" blue background thing behind a song to move up or down, enter plays the currently selected song, etc. I Alt-Tab to another application, and then Alt-Tab back. It looks like I'm in the same situation as before (the currently selected song is blue, instead of grey), but the up and down keystrokes do nothing. I'm apparently in a different section of iTunes. Pressing Tab brings me to the left panel of iTunes - the Music / Movies / Podcasts / Ringtones / etc. part, but the up and down keys don't do anything there either. Tabbing again takes me to the search field, and that works. And tabbing once more brings me back to where I should have been as soon as I Alt-Tabbed back to iTunes.
    - A variant situation: focus is as described at the beginning, and I Alt-Tab out and back into iTunes. Again, the up and down keys don't work, but then if I press Shift + Tab (to go to the previous field), it starts working again.
    This issue is much more of a pain than it sounds. If I'm in iTunes, and I'm chatting online, for example, I might need to switch out quickly to type a line in, and then switch back, but the workflow has been completely disrupted because I can't navigate with the keyboard anymore.
    - When editing a song title in iTunes, I select it first, and then press F2. This causes the title to become a "rename" field, which works mostly fine. With one exception. Generally, in these fields, you edit the title to your heart's desire, and then press Enter to signify that you are done. However, in iTunes, if I have a song title "blowin' in the wind", and I want to capitalize it, I'll hit F2, and then move the cursor over to the beginning of the title (in other words, to right before the "b"). My goal is to delete the lowercase b, and replace it with an uppercase B. So I press Delete, and then type B. However, as soon as I press the Delete key, iTunes deletes the character, and then closes the rename field. It's as though I pressed Delete and then Enter. If I then type B, I'm taken the first song starting with a B, which is not what I want at all.
    - iTunes doesn't work with Vista's window preview (Aero interface, Alt+Tab or hovering over the program in the tray at the bottom) when it's minimized.
    - When I have iTunes on in the background, and plug in an iPod, it all works fine, except for when I bring the window up. For whatever reason, iTunes doesn't repaint the window right at all. It's a horrific mixture of whatever songs were in the list view before and the iPod options.
    I'm sure I have more issues, but those are the ones that come to the top of my head. Note that I have none of these problems in iTunes on the Mac.
    Apple, if you're going to release software for Windows, please make it work.

    In article <[email protected]>, Javerkio wrote:
    > we are running GW 8.02 hp3 and recently moved our main post
    > office (~600 users) from Netware to Windows 2008 R2 (running under
    > Vsphere 4.1).
    >
    Windows is the lowest performing host for GroupWise, so that is a part
    of what you are hitting.
    How are you monitoring memory usage? I've found that the vCenter tools
    aren't a good indicator of that, where as the Windows tools are better
    in that respect. The biggy is that you don't want much paging to disk.
    How much do you have assigned to this VM?, how many cores? And are
    these ESX box(es) over committed on those two?
    Those settings on their own don't really mean a whole lot. What we need
    to see is what is actually being used, and if you are running out of
    them, then upping those specific numbers can help. The best way is to
    watch the POA web interface for the relevant settings.
    http://hostnameorIP:7181/
    Andy Konecny
    Knowledge Partner (voluntary SysOp)
    KonecnyConsulting.ca in Toronto
    Andy's Profile: http://forums.novell.com/member.php?userid=75037

  • JFileChooser repaint

    Hello,
    I am opening a JFileChooser from a menu FILE > OPEN. When I click OPEN, I want to change a status message being displayed, then open JFileChooser. Somehow the repaint doesn't happen: when JFileChooser finally opens, if I drag it to one side and look at the launching window underneath, yep, the message is displayed.
    Next, right after I select a file in JFileChooser, I first want to repaint the window underneath properly before I do something intensive with the file -- once again the refresh isn't happening correctly, the window greys out and is repainted only after the long task is done.
    Have tried super.repaint(), repaint(), repaint() in a try/catch, all with the same result.
    Have stripped down my code to demo my problem, will much appreciate guidance. Thanks in advance!
    //ChangeMessage.java
    //simplified code to demonstrate repaint problem right before
    //opening JFileChooser and right after selecting a file
    import java.io.File;
    import java.util.Locale;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.filechooser.FileFilter;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import javax.swing.border.EtchedBorder;
    public class ChangeMessage extends JFrame implements ActionListener
    private JMenuItem openItem;
    private JMenuItem exitItem;
    private JMenuItem aboutItem;
    private JTextField txtStatus;
    public String filename;
    public ChangeMessage()
              setTitle("ChangeMessage");
              setSize(430,145);
              setLocation(50,50);
              setResizable(false);
              Container contentPane = getContentPane();
              //Set up the window controls:
              GridBagLayout gbl = new GridBagLayout();
              contentPane.setLayout(gbl);
              //menu starts:
              JMenuBar mbar = new JMenuBar();
              JMenu m = new JMenu("File");
              openItem = new JMenuItem("Open");
              openItem.addActionListener(this);
              m.add(openItem);
              exitItem = new JMenuItem("Exit");
              exitItem.addActionListener(this);
              m.add(exitItem);
              mbar.add(m);
              JMenu n = new JMenu("Help");
              aboutItem = new JMenuItem("About");
              aboutItem.addActionListener(this);
              n.add(aboutItem);
              mbar.add(n);
              //menu ends
              GridBagConstraints gbc = new GridBagConstraints();
              gbc.fill = GridBagConstraints.BOTH;
              gbc.weightx = 200;
              gbc.weighty = 50;
              add(mbar,gbc,0,0,7,1);
              gbc.weightx = 20;
              txtStatus = new JTextField("Select a text file by doing menu FILE > OPEN",300);
              txtStatus.setEditable(false);
              txtStatus.setBorder(BorderFactory.createBevelBorder(1));
              txtStatus.setHorizontalAlignment(JTextField.CENTER);
              txtStatus.setForeground(Color.blue);
              gbc.weightx = 0;
              gbc.weighty = 15;
              add(txtStatus,gbc,0,1,7,1);
              gbc.weightx = 50;
              gbc.anchor = GridBagConstraints.EAST;
    public void actionPerformed(ActionEvent evt)
              Object source = evt.getSource();
         if (source == openItem)
                   //On my system, you click and wait for the File Chooser, so
                   //want to show an hourglass:
                   super.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   //PROBLEM: WANT TO SEE THE FOLLOWING WHILE WAITING:
                   txtStatus.setText("Opening file chooser window...");
                   repaint();
                   JFileChooser chooser = new JFileChooser();
                   chooser.setCurrentDirectory(new File("."));
                   chooser.setFileFilter(new FileFilter()
                        public boolean accept(File f)
                             return f.getName().toLowerCase().endsWith(".txt") || f.isDirectory();
                        public String getDescription()
                             return "Plain text file (.TXT)";
         int r = chooser.showOpenDialog(this);
                   super.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         if (r == JFileChooser.APPROVE_OPTION)
                   filename = chooser.getSelectedFile().getPath();
                   repaint();
                   //PROBLEM: DOING SOMETHING INTENSIVE HERE "BLANKS OUT" window
                   //do something with the file
         else if (source == aboutItem)
         else if (source == exitItem)
                   System.exit(0);
         public void add(Component c,GridBagConstraints gbc,int x,int y,int w,int h)
              gbc.gridx = x;
              gbc.gridy = y;
              gbc.gridwidth = w;
              gbc.gridheight = h;
              getContentPane().add(c,gbc);
    public static void main(String[] args)
              JFrame.setDefaultLookAndFeelDecorated(true);
              Frame f = new ChangeMessage();
              f.show();

    Hello,
    Just wanted to mention that I resolved this, using SwingWorker. So the answer is yes, I needed to launch another thread.
    The complete source code is available to anyone interested at:
    http://www.quadmore.com/babytalk/index.html
    Cheers,
    Bert Szoghy

  • Difference between manual resize and repaint, invalidate, validate etc etc?

    Using Jdk 1.5 and under windows XP I am drawing directly in a JPanel.
    And thus creating a drawing of my own when the system calls:
    public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D)g;
    Line2D lineInArrow =
    new Line2D.Double(. . . );
    g2.draw(lineInArrow);
    Ellipse2D ellipse = new Ellipse2D.Double(. . . );
    g2.draw(ellipse);
    The program of course has much more detail but that is the essence of it.
    Now, it turns out that my drawings sometimes become rather messed up and needs to be redrawn so I have tried calling. repaint(), invalidate(), validate(), paintImmediately() in many different combinations and several times.
    As the system is a more complex than just a JPanel - the JPanel is
    contained in a JScrollPane for instance and all is set in a JDialog - I have also tried calling the different parts with these methods and in many different combinations.
    Even calling the parts repeatedly from another Thread so that the methods get called every second or so does not help.
    NOTHING HAPPENS to the messed up drawing
    UNLES I DO A MANUAL RESIZE of the window. Then the drawing becomes OK!!!
    Yes, you guessed right, I have also tried resizing from the program
    by calls such as:
    Dimension currentSize = this.getSize();
    this.setSize(100, 100);
    this.setSize(currentSize);
    repaint();
    The window flickers - gets smaller and then gets back to its original size.
    But the drawing, if messed up, is still messed up in exactly the same way.
    SO WHAT IS HAPPENING WHEN I DO A MANUAL RESIZE BUT NEVER HAPPENS WHEN I DO ANY OF THE ABOVE?
    And, can I somehow initiate this - whatever it is - by programming rather than by a manual resizing of the window??

    With messed up I simply mean that it is not properly redrawn.
    For example a rectangle that should have been drawn is not shown - not drawn. Or a String is not drawn in its proper place.
    But when I do a manual resize (using the mouse) things are drawn correctly. Sometimes I have to do more than one resize to get everything drawn correctly.
    I might also add that I have tried some other more or less weird strategis to get this "manual resize like painting" activated such as:
    Calling the paintComponent method directly:
    Graphics g = this.mainDrawPanel.getGraphics();
    mainDrawPanel.paintComponent(g);
    Trying to make the system understand that something DO have changed:
    JButton aDummyButton = new JButton("Hi there - did you see me??");
    mainDrawPanel.add(aDummyButton);
    this.repaint();
    mainDrawPanel.remove(aDummyButton);
    this.repaint();
    Nothing makes anything happen - except the manual resize of the window.
    So what is so special about a manual resize of a window? What actually goes on when this happens? - That does NOT happen in all the other attempts?

  • Simulations, pixels and repainting

    Currently im trying to simulate a model of a few thousand objects (existing as species) and moving hunting etc as defined by code that i've already tested to work fine. My problem however comes to the GUI side of things, how for instance do you draw just 1 pixel? Does this become a Rectangle I need to fill which is 1*1 pixel in size? Or is there some kind of functionality to paint just one single pixel.
    Following from this is my use of the repaint method. How can I go about 'repainting' a window without having to make it invisible and just draw a whole new one? I read the API referring to how JLabel's inherit repaint from about 30 different locations and decided to test out the simplest one where I pass the label.repaint(label), after having change the foreground, background, etc but it doesn't actually repaint it.
    If someone could literally give me the code to draw a dot and then show me how they would move the dot to the right for instance (covering up the dot's tracks with the background colour) it would be massively appreciated.

    Here's a short sample app that will show you the basics of one way to do this.
    package com.sun.java.forums;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.List;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    public class LifePanel extends JPanel
         List<Point> pointsToPaint;
         public LifePanel()
              super();
              pointsToPaint = new Vector<Point>();
         public void setPoints(List<Point> points)
              this.pointsToPaint = points;
         @Override
         protected void paintComponent(Graphics g)
              Graphics2D g2d = (Graphics2D)g;
              // fill in the background
              g2d.setColor(getBackground());
              g2d.fill(g2d.getClip());
              // fill in the pixels
              g2d.setColor(getForeground());
              for (Point p: pointsToPaint)
                   g2d.fillRect(p.x, p.y, 1, 1);
         public static void main(String args[])
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setLayout(new BorderLayout());
              final LifePanel lp = new LifePanel();
              lp.setBackground(Color.WHITE);
              lp.setForeground(Color.BLACK);
              final Point singlePoint = new Point(0,0);
              List<Point> points = new Vector<Point>();
              points.add(singlePoint);
              lp.setPoints(points);
              f.add(lp,BorderLayout.CENTER);
              f.setSize(400,400);
              f.setVisible(true);
              // move the point every second
              Timer timer = new Timer(250,new ActionListener()
                   public void actionPerformed(ActionEvent ae)
                        // move the point 1 to the right and 1 down
                        singlePoint.translate(1, 1);
                        lp.repaint();
              timer.setRepeats(true);
              timer.start();
    }This will create a 400 by 400 white area with a little black pixel on it. 4 times per second, the pixel will move to the southeast.
    Your app will have much more interesting motion of points, I hope.

  • Trying to write a Listener on a CheckBox to change the Model of a ComboBox

    I am trying to change the list that appears in a ComboBox dynamically based on if a CheckBox is selected or not. I have multiple CheckBoxes and ComboBoxes being created in a loop based on a variable assigned at creation. Every tutorial i have seen writes out a listener that explicitly defines the checkbox instance but in my case i don't acctually know. My checkboxes are in an array of checkboxes as are the comboboxes as they are being created at runtime. Any help would be much apreciated this issue has been with me for two days now.

    here is a snippit of my code in how i was implementing this:
    int numButton = 17; //this is for testing only, this variable is set from another class normally
    // these variables are defined private elsewhere in the class
    JCheckBox PlayerByeCheck[] = new JCheckBox[numButton + 1];
    JCheckBox PlayerHomeCheck[] = new JCheckBox[numButton + 1];
    boolean PlayerOnBye[] = new boolean[numButton + 1];
    for (int i = 1; i <= numButton; i++) {
             PlayerByeCheck[i] = new JCheckBox();
         PlayerHomeCheck[i] = new JCheckBox();
         PlayerOnBye[i] = false;
    // more code here for building the gui it is not important for this problem
    // code to build the list starts here
    for (int i = 1; i <= numButton; i++) {
         ((TableLayout)PlayerRosterPanel.getLayout()).insertRow(1, TableLayout.PREFERRED);
             PlayerByeCheck.setOpaque(false);
         PlayerByeCheck[i].addItemListener(this);
         PlayerByeCheck[i].setName("PlayerByeCheck" + i);
         PlayerRosterPanel.add(PlayerByeCheck[i], new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstraints.CENTER, TableLayoutConstraints.FULL));
    //the comboox that i want to change
    //---- PlayerTeamSelect1 ----
         if (PlayerOnBye[i] = true) {
              PlayerTeamSelect[i].setModel(new DefaultComboBoxModel(new String[] {
                   "ARI",
                   "ATL",
                   "BAL",
              "BUF",
         "BYE"
              PlayerTeamSelect[i].setSelectedItem("BYE");
         } else {
              PlayerTeamSelect[i].setModel(new DefaultComboBoxModel(new String[] {
                   "ARI",
                   "ATL",
                   "BAL",
                   "BUF",
                   "CAR",
              "BYE"
         PlayerTeamSelect[i].setOpaque(false);
         PlayerRosterPanel.add(PlayerTeamSelect[i], new TableLayoutConstraints(4, 1, 4, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
    //more gui code here method gets closed
    //Item Action Listener starts here this is where i am having the problem                         
    public void itemStateChanged(ItemEvent e) {
         Object source = e.getItem();
         if (source == PlayerByeCheck[1])
         int select = e.getStateChange();
              if (select == ItemEvent.SELECTED)
              PlayerOnBye[1] = true;
    PlayerRosterPanel.repaint();
    //repaint the window i think can't get the listener to work to see if this is the right way to do this
    //i doubt it is
    I have tried several different ways to write the listener, the example in the code above is following the java swing tutorial by explicitly defining the checkbox. I have tried to write the listener as i am creating the checkbox, which doesn't seem to work or i am wrting it wrong, which is entirely possible. Once the listener sets the value i think it should repaint the screen but i am sure that that is wrong right now as well. As my hunch is the repaint will reset the checkbox to DESELCTED the default value. I will come to that issue once i figure out how to get the listener working. Ideally i want to be able to set the listener for the checkboxes regardless as to how many there are. As stated above i am generating a list of checkboxes, comboboxes and other fields based on a variable that is defined in one of my objects. If the user selects checkbox 3 than combobox 3 should be changed, and the others should not. if the user selects all the checkboxes than all the comboboxes change.
    thanks for any help. Still plugging along on it trying to figure this one out.

  • Objects in a GUI

    When I run my GUI which has buttons, textareas and textfield I have to adjust my frame to make the objects appear, this is not because of the size of the frame . It just makes them appear wen i slightly adjust the frame size.
    Could this be to do with wrong code? or is it a graphical problem?

    Could this be to do with wrong code? or is it a
    graphical problem?hi,
    This problem is faced by most of GUI developers. This is bcoz at times wen u only repaint the window the componets would appear properly. To solve this you can explicitly call the repaint on window load. Remeber you can also made a some mistake on ur code..!!

  • Application Paint() Help

    Hi, I am making a game, but sometimes when I activate it, I will get a nullpointerexception (varies greatly). Also, when I try to have the About class paint, it only works the second time through. I would greatly appriciate any help!
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    public class RPGMain extends Frame implements ActionListener, KeyListener, WindowListener, WindowStateListener, WindowFocusListener
         Image back;
         Graphics draw;
         MenuItem New, Open, Save, Quit, ttl, Directions, About;
         String gameState;
         Toolkit toolkit = Toolkit.getDefaultToolkit();
         newGame newGame;
         loadGame loadGame;
         saveGame saveGame;
         Directions dir;
         About about;
         Chara hero = new Chara();
         public static void main(String args[])
              System.out.println(" ");
              System.out.println("|        Cowboy  Bebop        |");
              System.out.println("|            Naruto           |");
              System.out.println("|            Trigun           |");
              System.out.println("|   Neon Genesis Evangelion   |");
              System.out.println("|           Inuyasha          |");
              System.out.println(" ");
              new RPGMain();
         public RPGMain()
              setTitle("RPG Main");
              setLayout(new FlowLayout());
              setSize(500, 500);
              setResizable(false);//This makes it so that the frame is always 500 x 500 pixels
              MenuBar menu = new MenuBar();
              Menu file = new Menu("File");
              Menu help = new Menu("Help");
              New = new MenuItem("New");
              Open = new MenuItem("Open");
              Save = new MenuItem("Save");
              Quit = new MenuItem("Quit");
              Directions = new MenuItem("Directions");
              About = new MenuItem("About");
              New.addActionListener(this);
              Open.addActionListener(this);
              Save.addActionListener(this);
              Quit.addActionListener(this);
              Directions.addActionListener(this);
              About.addActionListener(this);
              addWindowListener(this);
              addWindowStateListener(this);
              addWindowFocusListener(this);
              file.add(New);
              file.add(Open);
              file.add(Save);
              file.addSeparator();
              file.add(Quit);
              help.add(Directions);
              help.add(About);
              menu.add(file);
              menu.add(help);
              setMenuBar(menu);
              setVisible(true);
              back = createImage(500, 500);
              if (back == null)
                   System.out.println("\n|       Back is null...       |\n");
              draw = back.getGraphics();//The frame (or whatever) must be visible for this to work!!!
              newGame = new newGame();//creates an instance of *** and then gives it the varibles it needs
              newGame.set(back, draw, toolkit);
              loadGame = new loadGame();
              loadGame.set(back, draw, toolkit);
              saveGame = new saveGame();
              saveGame.set(back, draw, toolkit);
              about = new About();
              about.set(back, draw, toolkit);
              dir = new Directions();
              dir.set(back, draw, toolkit);
              gameState = "Title Screen";
              repaint();
         public void paint(Graphics g){}//leave empty to negate flashes
         public void update(Graphics g)
              if(gameState == "Title Screen"){draw.drawImage((toolkit.getImage("images/titleScreen.gif")), 0, 0, this);}
              else if(gameState == "New Game"){newGame.draw();}
              else if(gameState == "Load Game"){loadGame.draw();}
              else if(gameState == "Save Game"){saveGame.draw();}
              else if(gameState == "Dir"){dir.draw();}
              else if(gameState == "About"){about.draw();}
              try
                   g.drawImage(back,0,0,this);
              catch(NullPointerException e)
                   System.out.println("\n|NullPointerException in Paint|\n");
                   repaint();
    //Begin Window Event Block
         public void windowClosing(WindowEvent e)
              System.out.println("|       Window  Closing       |");
              System.exit(0);
         public void windowActivated(WindowEvent e)
              repaint();
              System.out.println("|      Window  Activated      |");
         public void windowDeactivated(WindowEvent e){System.out.println("|     Window  Deactivated     |");}
         public void windowOpened(WindowEvent e)
              repaint();
              System.out.println("|        Window Opened        |");
         public void windowClosed(WindowEvent e){System.out.println("|        Window Closed        |");}
         public void windowDeiconified(WindowEvent e)
              repaint();
              System.out.println("|     Window  Deiconified     |");
         public void windowIconified(WindowEvent e){System.out.println("|      Window  Iconified      |");}
         public void windowGainedFocus(WindowEvent e)
              repaint();
              System.out.println("|     Window Gained Focus     |");
         public void windowLostFocus(WindowEvent e){System.out.println("|      Window Lost Focus      |");}
         public void windowStateChanged(WindowEvent e)
              repaint();
              System.out.println("|     Window State Change     |");
    //End Window Event Block
    //Begin Action Performed Block
         public void actionPerformed(ActionEvent e)
              if(e.getSource() == New)
                   gameState = "New Game";
                   repaint();
              if(e.getSource() == Open)
                   gameState = "Load Game";
                   repaint();
              if(e.getSource() == Save)
                   gameState = "Save Game";
                   repaint();
              if(e.getSource() == Quit)
                   System.out.println("|     User closing window     |\n");
                   System.exit(0);
              if(e.getSource() == Directions)
                   gameState = "Dir";
                   repaint();
              if(e.getSource() == About)
                   gameState = "About";
                   repaint();
    //End Action Performed Block
    //Begin Key Input Block
         public void keyTyped(KeyEvent e)
         public void keyPressed(KeyEvent e)
         public void keyReleased(KeyEvent e)
    //End Key Input Block
    import java.awt.*;
    import java.awt.event.*;
    public class About extends Panel
         Graphics draw;
         Image back;
         Toolkit toolkit;
         public void set(Image a, Graphics b, Toolkit tool)
              back = a;
              draw = b;
              toolkit = tool;
         public void draw()
              System.out.println("|            About            |");
              draw.setColor(Color.black);
              draw.fillRect(0,0,500,500);
              draw.setColor(Color.white);
              draw.drawImage(toolkit.getImage("images/chaos.gif"), 205, 150, this);
              Font foo = new Font("Courier", Font.PLAIN, 24);
              draw.setFont(foo);
              draw.drawString("Choas Programming", 125, 300);
              draw.drawString("-----------------", 125, 320);
              draw.drawString("Head Programmer", 140, 340);
              foo = new Font("Arial", Font.PLAIN, 12);
              draw.setFont(foo);
    public class Chara
         String name;//Character's name
         String property;//Character's elemental property
         String race;//Character's type
         String job;//Character's job
         String status;//Character's status
         String equipe[];//Character's equipement
         String items[][];//Character's items {Useables, Equipes, Other}
         int hp[];//Min/Max HP
         int mp[];//Min/Max SP
         int strength[];//Current/Normal/Race Bonus
         int agility[];//Current/Normal/Race Bonus
         int vitality[];//Current/Normal/Race Bonus
         int intelligence[];//Current/Normal/Race Bonus
         int dexterity[];//Current/Normal/Race Bonus
         int luck[];//Current/Normal/Race Bonus
    import java.awt.*;
    import java.awt.event.*;
    public class Directions extends Panel
         Graphics draw;
         Image back;
         Toolkit toolkit;
         public void set(Image a, Graphics b, Toolkit tool)
              back = a;
              draw = b;
              toolkit = tool;
         public void draw()
              System.out.println("|          Direction          |");
              draw.setColor(Color.green);
              draw.fillRect(0,0,500,500);
              draw.setColor(Color.black);
              draw.drawString("|        Directions           |", 100, 150);
    import java.awt.*;
    import java.awt.event.*;
    public class loadGame extends Panel
         Graphics draw;
         Image back;
         Toolkit toolkit;
         public void set(Image a, Graphics b, Toolkit tool)
              back = a;
              draw = b;
              toolkit = tool;
         public void draw()
              System.out.println("|     User loading a game     |");
              draw.setColor(Color.black);
              draw.fillRect(0,0,500,500);
              draw.setColor(Color.green);
              draw.drawString("|     User loading a game     |", 100, 150);
    import java.awt.*;
    import java.awt.event.*;
    public class newGame extends Panel
         Graphics draw;
         Image back;
         Toolkit toolkit;
         public void set(Image a, Graphics b, Toolkit tool)
              back = a;
              draw = b;
              toolkit = tool;
         public void draw()
              System.out.println("|     User starting a game    |");
              draw.setColor(Color.white);
              draw.fillRect(0,0,500,500);
              draw.setColor(Color.black);
              draw.drawString("|   User starting a new game  |", 100, 150);
    import java.awt.*;
    import java.awt.event.*;
    public class saveGame extends Panel
         Graphics draw;
         Image back;
         Toolkit toolkit;
         public void set(Image a, Graphics b, Toolkit tool)
              back = a;
              draw = b;
              toolkit = tool;
         public void draw()
              System.out.println("|      User saving a game     |");
              draw.setColor(Color.red);
              draw.fillRect(0,0,500,500);
              draw.setColor(Color.black);
              draw.drawString("|     User saving a game      |", 100, 150);
    }

    Just a guess: instead of storing a reference to a Graphics object and using it to paint at whatever location in the code, move painting code into an object's paint() method and use the Graphics object passed into paint().
    i'm also currently writing a game, and got NullPointerExceptions galore when i tried storing a Graphics reference. Also, this approach helps separate game-state-manipulation code from display code.

  • Can anyone explain the odd behaviour of the CVI Operator Interface?

    This is probably really related to CVI in general, but I think people should be aware of this behaviour. If tracing is enabled and a program executing, moving the mouse cursor over the Menu bar area of the Operator Interface program increases the execution of the test program dramatically. Anywhere else slows it down! Could this have any effect during critical test runs? Is there a way to force the fast execution. (i.e. to disable whatever message processing is going on when the mouse cursor is over the rest of the window?)

    Brian,
    You did not mention what is the CVI operator interface that you are using. In the Simple CVI OI, which is located at \Examples\OperatorInterfaces, the behavior you mentioned may occur.
    It is mainly because it uses a CVI timer to poll UIMessages, and the Timer Control runs in the same thread as the User Interface (CVI Panels). Because they both run in the same thread, when you move your mouse Windows handles the mouse move and repaint any window if necessary. While doing this, it stops all the other tasks that is running in the same thread, which means, the timer stops to tick and UIMessages are not handled for some time. In addition, the TestStand Engine executes synchronously with UIMessage handling, so if msg
    s are not handled the Engine pauses the execution.
    Finally, there is an example that ships with CVI under
    \Samples\Toolbox\AsyncDem.prj that shows how to use asynchronous timers. In other words, a timer that runs in a different thread different than User Interface. I also modified the Simple CVI OI to use this asynchronous timer, check the attached zip file.
    Regards,
    Roberto P.
    Applications Engineer
    National Instruments
    www.ni.com/support
    Attachments:
    Simple_CVIAsync.zip ‏176 KB

  • WS_EX_LAYERED from bitmap uses black as transparency mask

    I'm trying to display a transparent 32bit bitmap on a WS_EX_LAYERED hwnd and set the per-pixel transparency with it, but somehow it looks that the transparency is decided by black pixels instead of the bitmap's alpha value.
    Here's the result with a black bitmap with few colored circles over it :
    Code :
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    LPCWSTR szWindowClass = L"TransparentClass";
    WNDCLASSEX wcex = { 0 };
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.lpfnWndProc = DefWindowProc;
    wcex.hInstance = hInstance;
    wcex.lpszClassName = szWindowClass;
    RegisterClassEx(&wcex);
    HWND hWnd = CreateWindowEx(WS_EX_LAYERED, szWindowClass, 0, WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    HBITMAP hbmp = (HBITMAP)LoadImage(GetModuleHandle(NULL), L"C:\\Users\\Domenico\\Desktop\\mask.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    //LPBYTE bits = (LPBYTE)hbmp;
    //int sizet = 500 * 500;
    //for (int pixel = 0; pixel != sizet; ++pixel)
    // bits[0] = bits[0] * bits[3] / 255;
    // bits[1] = bits[1] * bits[3] / 255;
    // bits[2] = bits[2] * bits[3] / 255;
    // bits += 4;
    HDC hdcScreen = GetDC(0);
    HDC hdc = CreateCompatibleDC(hdcScreen);
    ReleaseDC(0, hdcScreen);
    HBITMAP hbmpold = (HBITMAP)SelectObject(hdc, hbmp);
    POINT dcOffset = { 0, 0 };
    SIZE size = { 500, 500 };
    BLENDFUNCTION bf;
    bf.BlendOp = AC_SRC_OVER;
    bf.BlendFlags = 0;
    bf.SourceConstantAlpha = 255;
    bf.AlphaFormat = AC_SRC_ALPHA;
    UpdateLayeredWindow(hWnd, 0, 0, &size, hdc, &dcOffset, 0, &bf, ULW_ALPHA);
    SelectObject(hdc, hbmpold);
    DeleteDC(hdc);
    DeleteObject(hbmp);
    ShowWindow(hWnd, SW_SHOW);
    MSG msg;
    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    return (int)msg.wParam;
    Is it this the default behaviour to check for transparency ? I need black pixels to recreate a custom shadow-like effect.
    I tried to multiply every bitmap's pixel as suggested in MDSN doc but I'm getting access violation while trying to do so.
    Last question : Is it possible to repaint the whole window with a new bitmap at runtime ? Since you have call the updatelayeredwindow function before showing the window I'm thinking it should be impossible, right ?

    I'm trying to display a transparent 32bit bitmap on a WS_EX_LAYERED hwnd and set the per-pixel transparency with it, but somehow it looks that the transparency is decided by black pixels instead of the bitmap's alpha value.
    Here's the result with a black bitmap with few colored circles over it :
    Code :
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    LPCWSTR szWindowClass = L"TransparentClass";
    WNDCLASSEX wcex = { 0 };
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.lpfnWndProc = DefWindowProc;
    wcex.hInstance = hInstance;
    wcex.lpszClassName = szWindowClass;
    RegisterClassEx(&wcex);
    HWND hWnd = CreateWindowEx(WS_EX_LAYERED, szWindowClass, 0, WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
    HBITMAP hbmp = (HBITMAP)LoadImage(GetModuleHandle(NULL), L"C:\\Users\\Domenico\\Desktop\\mask.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    //LPBYTE bits = (LPBYTE)hbmp;
    //int sizet = 500 * 500;
    //for (int pixel = 0; pixel != sizet; ++pixel)
    // bits[0] = bits[0] * bits[3] / 255;
    // bits[1] = bits[1] * bits[3] / 255;
    // bits[2] = bits[2] * bits[3] / 255;
    // bits += 4;
    HDC hdcScreen = GetDC(0);
    HDC hdc = CreateCompatibleDC(hdcScreen);
    ReleaseDC(0, hdcScreen);
    HBITMAP hbmpold = (HBITMAP)SelectObject(hdc, hbmp);
    POINT dcOffset = { 0, 0 };
    SIZE size = { 500, 500 };
    BLENDFUNCTION bf;
    bf.BlendOp = AC_SRC_OVER;
    bf.BlendFlags = 0;
    bf.SourceConstantAlpha = 255;
    bf.AlphaFormat = AC_SRC_ALPHA;
    UpdateLayeredWindow(hWnd, 0, 0, &size, hdc, &dcOffset, 0, &bf, ULW_ALPHA);
    SelectObject(hdc, hbmpold);
    DeleteDC(hdc);
    DeleteObject(hbmp);
    ShowWindow(hWnd, SW_SHOW);
    MSG msg;
    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    return (int)msg.wParam;
    Is it this the default behaviour to check for transparency ? I need black pixels to recreate a custom shadow-like effect.
    I tried to multiply every bitmap's pixel as suggested in MDSN doc but I'm getting access violation while trying to do so.
    Last question : Is it possible to repaint the whole window with a new bitmap at runtime ? Since you have call the updatelayeredwindow function before showing the window I'm thinking it should be impossible, right ?
    1. Transparency in BGRA (32 bpp) bitmaps is controlled by the Alpha byte. When A is 0 the pixel is completely transparent, when A is 255 the pixel is completely opaque.
    2. HBITMAP doesn't point to the pixels. Given an HBITMAP, there are APIs to get and set the pixels: GetDIBits, SetDIBits.
    3. To repaint the window, call UpdateLayeredWindow again.

  • Re: Diffs between Win 3.11 & NT 4.0

    Elias Fayyad wrote:
    >
    Greetings,
    I have recently come across an issue that I am not sure how to go about
    solving...:
    We have a Fort&eacute; application whose windows were developed/painted on
    Windows 3.11. Our client is now switching to NT 4.0, and suddenly our
    windows look bigger on the new operating system... The problem becomes
    pretty painful in windows where the client has fixed size window
    requirement.
    For example, if a window is 512x512 pixels (fixed), and it contains a
    nested
    window, the contents of this nested window are now partially not visible
    because this nested window is now bigger than the panel in which it is
    supposed to reside.
    The windows were all developed on Windows 3.11, running at 1024x768
    resolution, using large fonts. Moreover, all the Fort&eacute; windows were
    painted
    using the portable font IconLabel, size 8, bold, which is provided as part
    of
    Fort&eacute;.
    We are now trying to run the application (same exact windows) on NT 4.0,
    using the same resolution and font size as those on 3.11, but everything
    looks BIGGER! Has anyone encountered this problem? How have you dealt
    with it? How do you get around these differences? And repainting the
    windows
    is NOT an option here... ;-)
    Your help is GREATLY appreciated in this matter.
    Thanks.
    Elias.We saw the same sort of sizing problems moving from Windows 95 to NT
    3.51. Part of the problem is that when you use fonts such as "Icon
    Font" or "System Default" you can't guarentee that one OS' default fonts
    are going to be the same as another's. And as you know, that's one of
    the big changes in the interface from Win 3.1 / NT 3.x to Win 95 / NT
    4.x. That fact that "Icon Font" is "portable" simply means that the OS
    will have SOMETHING called an icon font - what that font actually is or
    how big it appears isn't assured. Fortunately in our case we discovered
    the problem early on and avoided it by avoiding multiple versions of
    Windows; obviously that's not an option for you since you're upgrading
    after the fact. Sorry I can't be of more help.....

    Thanks for those of you who responded to my questions.
    All of our windows ARE gridded. But the common thing that you all
    suggested which we didn't have was using the Default Font. We
    used IconLabel instead. The reason behind that decision was our
    impression that IconLabel is a font that is provided by Fort&eacute; and that
    would ensure that all Client machines will ultimately have it. Was that
    an incorrect assumption?
    We thought that since our windows are gridded and they all used a
    Fort&eacute; provided portable font, we should NOT run into these problems.
    The reason we did not use the Default Font was because this font
    may differ from one machine to another. A user can actually have
    their machine use a different font than the default...
    We have come to the conclusion that we'll have to change the fonts
    on our windows. But I'd like a clarification on my 2 assumptions above:
    1) Shouldn't IconLabel (a Fort&eacute; provided portable font) not cause this
    problem?
    2) Can't the Default Font be different from one machine to another?
    Thanks for your help!
    Elias.
    Original Posting...
    Greetings,
    I have recently come across an issue that I am not sure how to go about
    solving...:
    We have a Fort&eacute; application whose windows were developed/painted on
    Windows 3.11. Our client is now switching to NT 4.0, and suddenly our
    windows look bigger on the new operating system... The problem
    becomes pretty painful in windows where the client has fixed size window
    requirement.
    For example, if a window is 512x512 pixels (fixed), and it contains a
    nested window, the contents of this nested window are now partially not
    visible because this nested window is now bigger than the panel in which
    it is supposed to reside.
    The windows were all developed on Windows 3.11, running at 1024x768
    resolution, using large fonts. Moreover, all the Fort&eacute; windows were
    painted using the portable font IconLabel, size 8, bold, which is provided
    as part of Fort&eacute;.
    We are now trying to run the application (same exact windows) on NT 4.0,
    using the same resolution and font size as those on 3.11, but everything
    looks BIGGER! Has anyone encountered this problem? How have you dealt
    with it? How do you get around these differences? And repainting the
    windows is NOT an option here... ;-)
    Your help is GREATLY appreciated in this matter.
    Thanks.
    Elias.

Maybe you are looking for

  • Error while accessing the Oracle iProcurement Page

    Hi, While accessing the iProcurement page, I am encountering the error "oracle.apps.fnd.framework.OAException: oracle.adf.mds.exception.MDSRuntimeException: Unable to find component with absolute reference = /oracle/apps/icx/icatalog/shopping/webui/S

  • Code page of the receiver system could not be found".

    Hi, We are getting an error in IDOC-XI-IDOC scenario that the "code page of the receiver system could not be found". What could be the reason for this error? Because of this error all IDocs are getting stuck in XI. Kindly help. Thanks, John

  • AE CS6 Crashes on Quit

    Every time I exit AE CS6 it crashes.  This is the prompt I get upon crash: Last log message was: <140735152419200> <ae.blitpipe> <2> HardwareBlitpipe Disengaged Please help.

  • MBP and final cut studio 2?

    I have the latest MBP 2.66 with 4 gb of ram and im buying final cut studio 2 and was wondering if it will run fine? I also was wondering if 4 gb of ram is enough? Or should i upgrade to 6 gb of ram? thank you! Can i also edit FULL HD video and still

  • CS3 will not install on Leopard

    Please see my previous thread of the disaster that is installing CS3 on Leopard 10.5.4 If anyone is still out there that has followed my 5 days of agony--I was finally sent a new dvd. SAME FAILED INSTALLATION MESSAGE, which is "Component Installation