JComboBox is not visible on JPanel

I have a class that extends JPanel. Within this class I have added several different components; JLabels, JTextFields, JButtons and a JComboBox.
All of the added components are visible and working except for the JComboBox. I can see the white background of the box and the popup and its list when I click on the area where the JComboBox is located, but I cannot see the selected text in the box. This seems strange since all the other components surrounding the JComboBox display correctly.
The background is set to white and the foreground is set to black. It has three options in the popup which are displayed using the foreground color, as it should. When I select an option from the popup, it seems to be working because the next time I display the popup, that selection is highlighted. But the selected text never shows in the box.
If I create a JComboBox in a JPanel, not an extended class, everything seems to work correctly. I can select from the popup and the selection appears in the box.
Could you please give me some suggestions as to how to make the selected text in the JComboBox visible?
Thanks
Bob

My layout manager is set to null. I don't think that there is anything obscuring it because the backgroud is visible. The only thing that I can't see it the selected text and the combo box down arrow. I am using VisualCafe to generate this code.
The extended class is loaded from the following class:
public class TheSchedule extends javax.swing.JFrame
using the following code:
     void JButtonGenTimeUnits_actionPerformed(java.awt.event.ActionEvent event)
          JPanelMainPanel.add(new TimeUnitDefinition((Frame)this));
          JPanelMainPanel.repaint();
The actual code of the TimeUnitDefinition is as follows:
package com.klawuhn.schedule;
import javax.swing.*;
import java.beans.*;
import java.awt.*;
import com.symantec.itools.javax.swing.models.StringComboBoxModel;
import symantec.itools.awt.util.Calendar;
import com.symantec.itools.javax.swing.borders.LineBorder;
public class TimeUnitDefinition extends javax.swing.JPanel {
private Frame parentFrame = null;
     public TimeUnitDefinition(Frame parentFrame)
     this.parentFrame = parentFrame; // Needed when displaying the calendars
          //{{INIT_CONTROLS
          setAlignmentY(1.0F);
          setAlignmentX(1.0F);
          setOpaque(false);
          setLayout(null);
          setSize(457,283);
          JLabelStartDate.setText("Start Date:");
          add(JLabelStartDate);
          JLabelStartDate.setBounds(12,12,156,24);
          JTextFieldStartDate.setDisabledTextColor(java.awt.Color.white);
          JTextFieldStartDate.setToolTipText("This is the date to start generating time units.");
          JTextFieldStartDate.setEditable(false);
          add(JTextFieldStartDate);
          JTextFieldStartDate.setBackground(java.awt.Color.white);
          JTextFieldStartDate.setBounds(168,12,216,24);
          JButtonCalendar1.setText("-");
          JButtonCalendar1.setActionCommand("-");
          add(JButtonCalendar1);
          JButtonCalendar1.setBounds(384,12,24,24);
          JLabelEndDate.setText("End Date:");
          add(JLabelEndDate);
          JLabelEndDate.setBackground(java.awt.Color.cyan);
          JLabelEndDate.setBounds(12,48,156,24);
          JTextFieldEndDate.setDisabledTextColor(java.awt.Color.white);
          JTextFieldEndDate.setToolTipText("This is the date to start generating time units.");
          JTextFieldEndDate.setEditable(false);
          add(JTextFieldEndDate);
          JTextFieldEndDate.setBackground(java.awt.Color.white);
          JTextFieldEndDate.setBounds(168,48,216,24);
          JButtonCalendar2.setText("-");
          JButtonCalendar2.setActionCommand("-");
          add(JButtonCalendar2);
          JButtonCalendar2.setBounds(384,48,24,24);
          JLabelStartTime.setText("Start Time:");
          add(JLabelStartTime);
          JLabelStartTime.setBounds(12,84,156,24);
          JTextFieldStartTime.setToolTipText("This is the time of day to start generating time units.");
          add(JTextFieldStartTime);
          JTextFieldStartTime.setBounds(168,84,240,24);
          JLabelEndTime.setText("End Time:");
          add(JLabelEndTime);
          JLabelEndTime.setBounds(12,120,156,24);
          JTextFieldEndTime.setToolTipText("This is the time of day to end generating time units.");
          add(JTextFieldEndTime);
          JTextFieldEndTime.setBounds(168,120,240,24);
          JLabelUnitOfMeasure.setText("Unit of Measure:");
          add(JLabelUnitOfMeasure);
          JLabelUnitOfMeasure.setBounds(12,156,156,24);
          JComboBoxUnitOfMeasure.setModel(stringComboBoxModel1);
          JComboBoxUnitOfMeasure.setToolTipText("This is the unit of measure used when generating the time units.");
          add(JComboBoxUnitOfMeasure);
          JComboBoxUnitOfMeasure.setBackground(java.awt.Color.white);
          JComboBoxUnitOfMeasure.setForeground(java.awt.Color.black);
          JComboBoxUnitOfMeasure.setBounds(168,156,240,24);
          JLabelBlockSize.setText("Block Size:");
          add(JLabelBlockSize);
          JLabelBlockSize.setBounds(12,192,156,24);
          JTextFieldBlockSize.setText("45");
          JTextFieldBlockSize.setToolTipText("This is the size of the time unit in Unit of Measures.");
          add(JTextFieldBlockSize);
          JTextFieldBlockSize.setBounds(168,192,240,24);
          JButtonSubmit.setText("Submit");
          JButtonSubmit.setActionCommand("Submit");
          JButtonSubmit.setToolTipText("This button will generate the time units.");
          add(JButtonSubmit);
          JButtonSubmit.setBounds(36,228,108,40);
          JButtonCancel.setText("Cancel");
          JButtonCancel.setActionCommand("Cancel");
          JButtonCancel.setToolTipText("This button will discard any changes.");
          add(JButtonCancel);
          JButtonCancel.setBounds(288,228,108,40);
               String[] tempString = new String[3];
               tempString[0] = "Days";
               tempString[1] = "Hours";
               tempString[2] = "Minutes";
               stringComboBoxModel1.setItems(tempString);
          //$$ stringComboBoxModel1.move(0,288);
          JComboBoxUnitOfMeasure.setSelectedIndex(2);
          //{{REGISTER_LISTENERS
          SymAction lSymAction = new SymAction();
          JButtonSubmit.addActionListener(lSymAction);
          JButtonCalendar1.addActionListener(lSymAction);
          JButtonCalendar2.addActionListener(lSymAction);
     //{{DECLARE_CONTROLS
     javax.swing.JLabel JLabelStartDate = new javax.swing.JLabel();
     javax.swing.JTextField JTextFieldStartDate = new javax.swing.JTextField();
     javax.swing.JButton JButtonCalendar1 = new javax.swing.JButton();
     javax.swing.JLabel JLabelEndDate = new javax.swing.JLabel();
     javax.swing.JTextField JTextFieldEndDate = new javax.swing.JTextField();
     javax.swing.JButton JButtonCalendar2 = new javax.swing.JButton();
     javax.swing.JLabel JLabelStartTime = new javax.swing.JLabel();
     javax.swing.JTextField JTextFieldStartTime = new javax.swing.JTextField();
     javax.swing.JLabel JLabelEndTime = new javax.swing.JLabel();
     javax.swing.JTextField JTextFieldEndTime = new javax.swing.JTextField();
     javax.swing.JLabel JLabelUnitOfMeasure = new javax.swing.JLabel();
     javax.swing.JComboBox JComboBoxUnitOfMeasure = new javax.swing.JComboBox();
     javax.swing.JLabel JLabelBlockSize = new javax.swing.JLabel();
     javax.swing.JTextField JTextFieldBlockSize = new javax.swing.JTextField();
     javax.swing.JButton JButtonSubmit = new javax.swing.JButton();
     javax.swing.JButton JButtonCancel = new javax.swing.JButton();
     com.symantec.itools.javax.swing.models.StringComboBoxModel stringComboBoxModel1 = new com.symantec.itools.javax.swing.models.StringComboBoxModel();
     class SymAction implements java.awt.event.ActionListener
          public void actionPerformed(java.awt.event.ActionEvent event)
               Object object = event.getSource();
               if (object == JButtonSubmit)
                    JButtonSubmit_actionPerformed(event);
               else if (object == JButtonCalendar1)
                    JButtonCalendar1_actionPerformed(event);
               else if (object == JButtonCalendar2)
                    JButtonCalendar2_actionPerformed(event);
     void JButtonSubmit_actionPerformed(java.awt.event.ActionEvent event)
          System.out.println("See Submit button");
          TimeUnitCreate timeUnitCreate = new TimeUnitCreate(
          JTextFieldStartDate.getText(),
          JTextFieldEndDate.getText(),
          JTextFieldStartTime.getText(),
          JTextFieldEndTime.getText(),
          (String)JComboBoxUnitOfMeasure.getSelectedItem(),
          JTextFieldBlockSize.getText()
          timeUnitCreate.createTimeUnits();
          this.setVisible(false);
System.out.println("Done creating Time Units.");
// (new TimeUnitDefinition()).setVisible(true);
     void JButtonCalendar1_actionPerformed(java.awt.event.ActionEvent event)
     CalendarDialog calendarDialog = new CalendarDialog(parentFrame,"Date",true);
     calendarDialog.show();
     JTextFieldStartDate.setText(calendarDialog.getSelectedDate());
     void JButtonCalendar2_actionPerformed(java.awt.event.ActionEvent event)
     CalendarDialog calendarDialog = new CalendarDialog(parentFrame,"Date",true);
     calendarDialog.show();
     JTextFieldEndDate.setText(calendarDialog.getSelectedDate());
}

Similar Messages

  • JComboBox - Bottom border is not visible for the first time

    JComboBox - Bottom border is not visible for the first time i click on the arrow to drop the list down.
    This happens because the list when dropped down goes out of the frame.
    If have the increased the size of the Frame then i am able to see it,but i dont want to do this.
    I am using jdk1.3.1_02.
    Any Help would be great.
    Please find the code below.
    Thanks,
    Sridhar.
    //file: Lister.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Lister {
        public static void main(String[] args) {
            JFrame frame = new JFrame("Lister v1.0");
            // create a combo box
            String [] items = { "uno", "due", "tre", "quattro", "cinque",
            "sei", "sette", "otto", "nove", "deici",
            "undici", "dodici" };
            JComboBox comboBox = new JComboBox(items);
            comboBox.setEditable(true);
            // put the controls the content pane
            Container c = frame.getContentPane( );
            JPanel comboPanel = new JPanel( );
            comboPanel.add(comboBox);
            c.add(comboPanel, BorderLayout.NORTH);
            c.setBackground(Color.white);
            comboBox.setBackground(Color.white);
            comboPanel.setBackground(Color.white);
            frame.setBackground(Color.white);
            frame.setResizable(false);
            frame.setSize(200, 200);
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.setVisible(true);
    }

    Hello,
    try this:JPanel comboPanel = new JPanel(new BorderLayout());Regards,
    Tim

  • Drop down list(JComboBox) - Bottom border is not visible for the first time

    Drop down list(Combo-box) JComboBox - Bottom border is not visible for the first time i click on the arrow to drop the list down.
    I am using jdk1.3.1_02.
    Did any one face this issue.
    Please let me know.
    Thanks,
    Sridhar.

    I must be a little confused regarding your question.
    You can simply change your code frame.setSize(200, 200); to frame.setSize(400, 400);When you say you are unable to see the border are you specifically talking about the border of the frame or the border of the combo box?
    Lance

  • Jcombobox not visible in unix using JRE 1.6

    There is a Java based admin tool in our project which is implemented using java swing. This admin tool works fine on Windows with all the JRE’s. But when I run it on Sun Solaris with Sun JRE 1.6.0_12, the drop down feature of jcombobox fails. It opens the list and quickly closes the same without giving an opportunity to select the value. This looks like an issue to me as it used to work before when we had Sun JRE 1.4.2_13 on this machine.
    The jcombobox is placed on a jpanel which in-turn is added on a jinternalframe. I have tested this admin tool on other flavours of Unix and faced similar issue with the jcombobox. I have also tested this on AIX and HPUX and the issue is reproducible there also using JRE 6.
    Any help on this would be appreciated.
    Edited by: deeps2009 on Jun 8, 2009 10:40 PM

    >
    Actually, adding a componentlistener to the JInternalFrame is causing the problem.>I doubt that very much. Or at least, I doubt that the simple combination of a ComponentListener on a JInternalFrame would cause a JComboBox to disappear. Why don't you show us how it happens, with an SSCCE?
    And in reply to something you said earlier "Sorry, but I can't post the code over here.". Note that nobody in this thread has asked for you to post 'the code', what was requested was an SSCCE. An SSCCE involving the above 3 classes would probably only take 30-40 lines of code. I doubt you will get this resolved (here) short of preparing an SSCCE.

  • JScrollPane scroll setting first column is not visible?

    Hi All,
    i am using jtable and jscrollpane. in this my first column of 70 pixal width and rest 125 pixal width.set focus is on 1 cell(1 row, 1 column) in table. but due to this scrollbar is slightly on right side whice coz first column not visible.(need to drag for visibility). i am trying to make it visible without dragging.
    how to do this? HELP.
    i tried with tableScroll.scrollRectToVisible(table.getCellRect(0,0,true )); & -1,-1
    but it didnt worked.
    Code is like this..........
    table = new JTable(64,65){
    table.setName("Table");
    ((DefaultTableModel)table.getModel()).setColumnIdentifiers(vectName.getColumnIdentifiers());
              for(int i = 0;i<table.getRowCount();i++) {
                   table.setValueAt((i+1)+"",i,0);
              table.setGridColor(Color.black);
              table.setSelectionBackground(new Color(125,255,144));
              table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              table.setCellSelectionEnabled(true);          
              table.addKeyListener(listener);
              table.addMouseListener(listener);
              table.getSelectionModel().addListSelectionListener(this);
              table.getColumnModel().addColumnModelListener(this);
              table.getColumnModel().getColumn(0).setResizable(false);
              table.getColumnModel().getColumn(0).setMinWidth(70);
              table.getColumnModel().getColumn(0).setMaxWidth(70);
    JScrollPane tableScroll = new JScrollPane(table);
    Dimension minimumSize = new Dimension(100,25);
    tableScroll.setMinimumSize(minimumSize);          
    add(tableScroll);

    Hi weebib ,
    pls find some working code which shous my problame .
    you can see its coming to column 'B'. but i want it to show from column 'A' .
    sample working code : =
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.table.*;
    import java.util.*;
    public class myTable extends JFrame{
    JTable table;
    JScrollPane jsp;
    JPanel p1;
    int NO_OF_ROWS = 64;
    int NO_OF_COLUMNS = 65;
    Vector vColumnNames ;
    myTable(){
         Container con = getContentPane();
         p1 = new JPanel();
         table = new JTable(NO_OF_ROWS,NO_OF_COLUMNS){
              public boolean isCellEditable(int row, int column) {
                                  if(column == 0){
                                       return false;
                                  else{
                                       return true;
         setTableProperties();
         jsp = new JScrollPane(table);
         p1.add(jsp);
         con.add(p1);
         setSize(400,500);
         show();
         //System.out.println("Hello there");
    public Vector getColumnIdentifiers(){
         vColumnNames = new Vector();
                   for(int i=65;i<129;i++) {
                        vColumnNames.add(new String((char)i+""));// setting the alphabets for the column names //orig
         return vColumnNames ;
    public void setTableProperties(){
         ((DefaultTableModel)table.getModel()).setColumnIdentifiers(getColumnIdentifiers());
         for(int i = 0;i<table.getRowCount();i++) {
                        table.setValueAt((i+1)+"",i,0);// Set the names of the row
         table.setGridColor(Color.black);
         table.setSelectionBackground( Color.RED);
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         table.setCellSelectionEnabled(true);
         table.addMouseListener(new myMouseListener());
         table.addKeyListener(new myKeyListener());
    //     table.getColumnModel().getColumn(0).setPreferredWidth(125);
    //     table.getColumnModel().getColumn(0).setResizable(false);
    //     table.getColumnModel().getColumn(0).setMinWidth(70);
    //     table.getColumnModel().getColumn(0).setMaxWidth(70);
         for(int u =0 ;u<64;u++){
              if(u==0){
                   table.getColumnModel().getColumn(u).setPreferredWidth(70);
              else{
                   table.getColumnModel().getColumn(u).setPreferredWidth(200);
         table.changeSelection(0,1,false,false);
    static public void main(String[] args){
              myTable test = new myTable();
              test.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){System.exit(0);}
    public class myMouseListener extends MouseAdapter{
         public void mousePressed(MouseEvent me){
                   table.repaint();
    public class myKeyListener extends KeyAdapter{
         public void keyPressed(KeyEvent ke){
                   if(table.getSelectedColumn() == 0){
                        ke.consume();
    ================
    pls do reply back if i am doing something wrong.
    == Gavin

  • Content OF  Panel Is Not Visible. Need Help

    Hi Guys,
    Can someone tell me why the contents of the "VisPanel" (JPanel) class is not showing up in the main window. I just don't understand why it is not visible after i add it to the main window.
    Here is the code. You can test it. Only the button shows up. The contents of "VisPanel" class is not visible.
    Replace the images in the "VisPanel" class with any image of your choice. I made them 130 X 130. I would have like to add the images in the post but i don't think it is possible to add images to post in this forum.
    public class TilesImage extends JFrame{
         private static final long serialVersionUID = 1L;
         public TilesImage(){
                this.setLayout(new GridLayout(2,1));
                this.setSize(600,600);
                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                VisPanel vis = new VisPanel();
                JPanel pana = new JPanel();
                pana.add(vis);
                BufferedImage sub = vis.getImg().getSubimage(261, 260, 129, 129);
               JButton but = new JButton(new ImageIcon(sub));
               pana.add(but);
               this.add(pana);
               this.setContentPane(pana);
               this.setVisible(true);
               repaint();
           public static void main( String[] args ) {
                 new TilesImage();
                 //new VisPanel();
    class VisPanel extends JPanel{
          private static final int IMAGE_TYPE = BufferedImage.TYPE_INT_ARGB;
           private BufferedImage img;
          public VisPanel() {
                 // here you should create a compatible BufferedImage
                 //img = new BufferedImage( 450, 350, IMAGE_TYPE ); 
                 img = new BufferedImage( 525, 500, IMAGE_TYPE );
                     this.setSize(img.getWidth(), img.getHeight());    
                 final int NB_TILES = 4;
                 BufferedImage[] tiles = new BufferedImage[NB_TILES];
                 tiles[0] = createHorizontalRail( new Color( 255, 255, 255 ) );
                 tiles[1] = createVerticalRail( new Color( 255, 255, 255 ) );
                 tiles[2] = createCrossing( new Color( 255,   0, 255 ) );
                 final int[][] map = new int[][] {
                             {4, 4, 1},    
                               {4, 4, 1},
                               {0, 0, 2},
                               {4, 4, 4}, 
                 for (int i = 0; i < map[0].length; i++) {
                       BufferedImage tile = null;
                     for (int j = 0; j < map.length; j++) {
                          if(map[j] == 0){
                   tile = tiles[0];
                   for (int x = 0; x < tile.getWidth(); x++) {
              for (int y = 0; y < tile.getHeight(); y++) {
              img.setRGB( x + i * 130, y + j * 130, tile.getRGB(x,y) );
                   //img.setRGB( x + i * 45, y + j * 32, tile.getRGB(x,y) );
              } if(map[j][i] == 1){
                   tile = tiles[1];
                   for (int x = 0; x < tile.getWidth(); x++) {
              for (int y = 0; y < tile.getHeight(); y++) {
              img.setRGB( x + i * 130, y + j * 130, tile.getRGB(x,y) );
              if(map[j][i] == 2){
                   tile = tiles[2];
                   for (int x = 0; x < tile.getWidth(); x++) {
              for (int y = 0; y < tile.getHeight(); y++) {
              img.setRGB( x + i * 130, y + j * 130, tile.getRGB(x,y) );
         this.setVisible( true );
         private BufferedImage createHorizontalRail( final Color c ) {
         final Random r = new Random();
         BufferedImage img = null;
         try {
         img = ImageIO.read(new File("images/crossingsHorizontal.JPG"));
         } catch (IOException e) {
         return img;
         private BufferedImage createVerticalRail( final Color c ) {
         final Random r = new Random();
         BufferedImage img = null;
         try {
         img = ImageIO.read(new File("images/crossingsVertical2.JPG"));
         } catch (IOException e) {
         return img;
         private BufferedImage createCrossing( final Color c ) {
         final Random r = new Random();
         BufferedImage img = null;
         try {
         img = ImageIO.read(new File("images/railCrossing2.JPG"));
         } catch (IOException e) {
         return img;
         public void paintComponent(Graphics g) {
         g.drawImage(img, 0, 0, null);
              public BufferedImage getImg() {
                   return img;
              public void setImg(BufferedImage img) {
                   this.img = img;
    Thanks for your help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    kap wrote:
    The "pana" panel must contain both the contents of the "VisPanel" panel and the button i created. So it is correct to set the contenPane to the "pana" panel. I tried to set the content pane to the "VisPanel" panel. It is visible but the button i added to the "pana" panel cannot be visible.
    I hope you understand what i mean here.He understands exactly what you mean and has pointed out your mistake and offered a decent solution. I suggest you take his advice and set the layout of pana not the JFrame.

  • Components are not visible in the beginning..

    Hai ..
    The contents(TextFields Labels and Buttons) of my application are displayed only after i resize the frame manually.. Why is it so.. Is there any way to make them visible as soon as i run the application..
    This happens only for the first time(ie immediately after running the application..).. I guess its because of the Focus not being given to the Frame in the beginning(I may be wrong.. Correct me if i am wrong).. Any one with any solution??
    Thanks in advance!!

    /* This program is meant for opening the internet explorer on typing the search text in the TextField and pressing enter*/
    public Search()
    f=new Frame();
    maxwidth=Toolkit.getDefaultToolkit().getScreenSize().width;
    maxheight=Toolkit.getDefaultToolkit().getScreenSize().height;
    f.setBounds(maxwidth-200,0,200,maxheight);
    f.setVisible(true);
    f.setLayout(null);
    f.setBackground(Color.BLACK);
    f.setForeground(Color.RED);
    st=new JTextField();
    sl=new JLabel("Search");
    sl.setBounds(25,525,150,25);
    st.setBounds(25,565,150,25);
    sl.setForeground(Color.RED);
    f.add(sl);f.add(st);
    /* On pressing Enter i try to convert the contents in the textbox in a search string to be used in google*/
    st.addKeyListener(new KeyAdapter()
    public void keyPressed(KeyEvent ke)
    if(ke.getKeyCode()==KeyEvent.VK_ENTER)
    searchstring=st.getText();
    char ss[]=searchstring.toCharArray();
    for(int i=0;i<ss.length;i++)
    if(ss==' ')
    ss[i]='+';
    searchstring=new String(ss);
    try
    p=Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe www.google.co.in/search?hl=en&q="++searchstring++"&meta=");
    catch(Exception e1)
    System.out.println("Internet Explorer not found in C drive");
    try
    p=Runtime.getRuntime().exec("E:\\Program Files\\Internet Explorer\\iexplore.exe www.google.co.in/search?hl=en&q=+"+searchstring++"&meta=");
    catch(Exception e2)
    System.out.println("Internet Explorer not found in E drive");
    f.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent we)
    f.setVisible(false);
    /* This imgpanel is used to display an image in the JPanel*/
    imgpanel=new JPanel();
    imgpanel.setLayout(new GridLayout(1,1));
    f.add(imgpanel);
    imgpanel.setBounds(25,50,150,150);
    img=Toolkit.getDefaultToolkit().getImage("sample.jpg");
    img=img.getScaledInstance(150,150,Image.SCALE_SMOOTH);
    imgicon=new ImageIcon(img);
    imglabel=new JLabel(imgicon);
    imglabel.setVisible(false);
    imgpanel.add(imglabel);
    On executin the code i get the frame visible .. The JPanel is also visible but the image is not present.. Its visible once I resize the frame.. Also the TextField(for getting the search text)and the associated JLabels are sometimes not visible.. They are visible only if i bring some other window in front of it or if i resize the Frame..
    Thanks!!
    Edited by: s.baalajee on Jan 7, 2009 9:44 AM
    Edited by: s.baalajee on Jan 7, 2009 9:45 AM

  • How to know if a scrollbar is been drawn if the JScrollPane is not visible.

    I have a JTabbedPane with one JPanel in each tab. Each of these panels contains one JLabel with a JTextBox on the top and under it the rest is filled with a JScrollPane containing a JTable. I am using a GridBagLayout.
    Now, the requirement is that the JTextBox must have the same length as the content of the JScrollPane; it means that if the JScrollPane has a vertical scroll, the JText has to be shorter on the right side by whatever the scroll width is, but if there's no vertical scroll then the JTextBox must be extended to the top of the right side.
    Now, this that looks so simple is becoming a nightmare...
    The main problem here is that this check to look if the JScrollPane has a scroll or not is done in tabs that are not visible, so i cannot use just a simple isVerticalScrollVisible() because the answer is always NO. I have been trying to catch all the events i could think may help but no luck and sometimes a refresh in one of the tabs produces the JTextField in another tab gets a wrong width.
    One posible approach is the length of the total rows of the JTable, multiply it by the row height and compare it with... with what because the scroll is not visible and the heigh is 0.
    Any ideas? Any one knows how can i know if the the silly scrollbar is visible or not in a non visible tab?
    Thanks in advance.

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

  • Somebody help me-Why button is not visible??

    button on AircraftCockpitPanel is not visible, plz somebody help me
    and if possible help me to make AircraftCockPit Panel transparent
    import java.awt.Color;
    import java.awt.GraphicsEnvironment;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    public class RBStrategy implements Runnable
         private JFrame frame;
         static boolean onlyScreen = true;
         static Screen screen;
         static AircraftCockPit aircraftCockPit;
         public RBStrategy(JFrame frame, Screen screen)
              this.frame = frame;
              this.screen = screen;
         public static void main(String[] args)
              JFrame frame = new JFrame();
              screen = new Screen();
              frame.setUndecorated(true);
              frame.getContentPane().add(screen);
              GraphicsEnvironment.getLocalGraphicsEnvironment().
                   getDefaultScreenDevice().setFullScreenWindow(frame);
              screen.setLayout(null);
              aircraftCockPit = new AircraftCockPit(screen);
              new RBStrategy(frame, screen).run();
         public void run()
              do
                   String output;
                   try
                        Thread.sleep(1000);
                   catch (InterruptedException ie)
                        ie.printStackTrace(System.err);
              while (true);
    class Screen
         extends JPanel
         implements
              Runnable {
                   boolean progressing = true;
                   Thread t;
                   Screen()     {
                        this.add(new JButton("ButtonScreen"));
                        this.setBackground(Color.BLACK);
                        this.start();
                 public void stop()     {
                      progressing = false;
                      t.stop();
                 public void start()     {
                      progressing = true;
                      t = new Thread(this);
                      t.start();
                 protected void paintComponent(Graphics g)     {
                           super.paintComponent(g);
                           g.setColor(Color.red);
                           for(int i=0;i<this.getHeight();i=i+10)     {
                                     g.drawLine(0,i,this.getWidth(),i);
                   public void run()     {
                        try     {
                             while(progressing)     {
                                  this.repaint();
                                  Thread.sleep(1);
                        }catch     (InterruptedException e)     {
                             System.out.println("Interrupted");
    class AircraftCockPit
         extends JPanel
         implements  Runnable {
              boolean progressing=true;     
              Thread t;
              JButton jButton;
              Screen screen;
              AircraftCockPit(Screen s)     {
                   screen = s;
                   jButton=new JButton("ButtonCockPit");
                   jButton.setBounds(30,30,40,40);
                   this.setBackground(Color.GRAY);
                   this.setBounds(s.getWidth()*3/4,s.getHeight()>>2,s.getWidth()>>2,s.getHeight()*9/20);
                   s.add(this);
                   this.start();
              public void stop()     {
                   progressing = false;
                   t.stop();
              public void start()     {
                   progressing = true;
                   t = new Thread(this);
                   t.start();
              protected void paintComponent(Graphics g)     {
                        super.paintComponent(g);
              public void run()     {
                   try     {
                        while(progressing)     {
                             this.repaint();
                             Thread.sleep(2);
                   }catch     (InterruptedException e)     {
                        System.out.println("Interrupted");
    }

    Quit multi-posting you are wasting peoples time. I gave you the answer yesterday:
    http://forum.java.sun.com/thread.jspa?threadID=5230919&start=4

  • Semitransparent Panel & jComponent not visible

    Problem:jButton is not visible & CockPitPanel should be semitransparent import java.awt.Color;
    import java.awt.GraphicsEnvironment;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    public class RBStrategy implements Runnable
         private JFrame frame;
         static boolean onlyScreen = true;
         static Screen screen;
         static AircraftCockPit aircraftCockPit;
         public RBStrategy(JFrame frame, Screen screen)
              this.frame = frame;
              this.screen = screen;
         public static void main(String[] args)
              JFrame frame = new JFrame();
              screen = new Screen();
              frame.setUndecorated(true);
              frame.getContentPane().add(screen);
              GraphicsEnvironment.getLocalGraphicsEnvironment().
                   getDefaultScreenDevice().setFullScreenWindow(frame);
              screen.setLayout(null);
              aircraftCockPit = new AircraftCockPit(screen);
              new RBStrategy(frame, screen).run();
         public void run()
              do
                   String output;
                   try
                        Thread.sleep(1000);
                   catch (InterruptedException ie)
                        ie.printStackTrace(System.err);
              while (true);
    class Screen
         extends JPanel
         implements
              Runnable {
                   boolean progressing = true;
                   Thread t;
                   Screen()     {
                        this.add(new JButton("ButtonScreen"));
                        this.setBackground(Color.BLACK);
                        this.start();
                 public void stop()     {
                      progressing = false;
                      t.stop();
                 public void start()     {
                      progressing = true;
                      t = new Thread(this);
                      t.start();
                 protected void paintComponent(Graphics g)     {
                           super.paintComponent(g);
                           g.setColor(Color.red);
                           for(int i=0;i<this.getHeight();i=i+10)     {
                                     g.drawLine(0,i,this.getWidth(),i);
                   public void run()     {
                        try     {
                             while(progressing)     {
                                  this.repaint();
                                  Thread.sleep(1);
                        }catch     (InterruptedException e)     {
                             System.out.println("Interrupted");
    class AircraftCockPit
         extends JPanel
         implements  Runnable {
              boolean progressing=true;     
              Thread t;
              JButton jButton;
              Screen screen;
              AircraftCockPit(Screen s)     {
                   screen = s;
                   jButton=new JButton("ButtonCockPit");
                   jButton.setBounds(30,30,40,40);
                   this.setBackground(Color.GRAY);
                   this.setBounds(s.getWidth()*3/4,s.getHeight()>>2,s.getWidth()>>2,s.getHeight()*9/20);
                   s.add(this);
                   this.start();
              public void stop()     {
                   progressing = false;
                   t.stop();
              public void start()     {
                   progressing = true;
                   t = new Thread(this);
                   t.start();
              protected void paintComponent(Graphics g)     {
                        super.paintComponent(g);
              public void run()     {
                   try     {
                        while(progressing)     {
                             this.repaint();
                             Thread.sleep(2);
                   }catch     (InterruptedException e)     {
                        System.out.println("Interrupted");
    }

    As I suggested in your last posting, the size of the Screen panel is (0, 0). Since the size of the AircraftCockpit is based on the size of the Screen it is also (0, 0). So there is nothing to paint.
    Did you add a few System.out.println(...) statements to verify this?

  • JComboBox is not displaying the down arrow..

    jComboBox is not displaying the down arrow..
    I was first using the "choice" component but was having problems with the size only on Unix. So I changed it to a jComboBox and I'm having problems on both NT and UNIX. First the down arrow doesn't show up on NT....and the drop down doesn't even show up on UNIX.
    Any ideas?
    Thanks!
    pt

    could be coz you have not left enough room for it on the layout of your JPanel?

  • JComboBox is not opened

    Hi,
    I have a strange problem. My frame has BorderLayout - in the north I have JcomboBox, in the south I have button and the center is populated with rows of labels and textfields according the chosen item from the JComboBox.
    The problem is, that when there are more than 3 rows of labels and textfields displayed on the frame, the JComboBox is not opened.
    Has anybody faced this problem before? Any ideas what went wrong?
    Thanks, Lior

    Here is part of the code:
    public class ClarifyClient extends JPanel
    private static int m_NumOfParams = 0;
    private static String[] m_Token;
    private static JFrame jframe = new JFrame("ACM Events Builder");
    JComboBox jcombo = new JComboBox();
    Label eventLabel = new Label("Events: ");
    Label lblParam = new Label("Parameters: ");
    Button sendBtn = new Button("Send");
    Panel centerPanel = new Panel();
    Panel northPanel = new Panel(new FlowLayout());
    Panel southPanel = new Panel(new FlowLayout());
    TextField txtParamValue;
    public ClarifyClient()
    jframe.getContentPane().setLayout(new BorderLayout());
    try
    loadEventsFromFile();
    catch(Exception e)
    e.printStackTrace();
    populateComboBox();
    jcombo.setSelectedIndex(-1);
    FrameAction frameAction = new FrameAction();
              jcombo.addActionListener(frameAction);
              sendBtn.addActionListener(frameAction);
              MouseAction mouseAction = new MouseAction();
              jcombo.addMouseListener(mouseAction);
              northPanel.setLayout(new FlowLayout());
              northPanel.add(eventLabel);
    northPanel.add(jcombo);
    jframe.getContentPane().add(northPanel, "North");
    southPanel.setLayout(new FlowLayout());
    southPanel.add(sendBtn);
         jframe.getContentPane().add(southPanel, "South");
         sendBtn.setEnabled(false);
              jframe.pack();
              jframe.setSize(664, 280);
              jframe.setVisible(true);
    class FrameAction implements java.awt.event.ActionListener
         public void actionPerformed(java.awt.event.ActionEvent event)
              try
              Object object = event.getSource();
                   if (object == jcombo)
                        jcombo_actionPerformed(event);
                   else if (object == sendBtn)
                   sendBtn_actionPerformed(event);
              catch(Exception e)
              e.printStackTrace();
    void jcombo_actionPerformed(java.awt.event.ActionEvent event)
         int index = jcombo.getSelectedIndex();
         m_NumOfParams = Integer.parseInt((String)(((ArrayList)(eventDetails_V.get(index))).get(1)));
         centerPanel.removeAll();
         centerPanel.setLayout(new GridLayout(m_NumOfParams+1, 4));
         centerPanel.add(lblParam);
         centerPanel.add(new Label());
         centerPanel.add(new Label());
         centerPanel.add(new Label());
         m_Token = new String[m_NumOfParams];
         //inserting the ACM event parameters to the Panel container
         for (int i=0; i<m_NumOfParams; i++)
         txtParamValue = new TextField(20);
    Label lblName = new Label("Name: ");
    lblName.setAlignment(java.awt.Label.LEFT);
    Label lblValue = new Label("Value: ");
    lblValue.setAlignment(java.awt.Label.RIGHT);
    Label lblParamName = new Label();
    m_Token[i] = (String)((ArrayList)(eventDetails_V.get(index))).get(i+2);
         centerPanel.add(lblName);
         lblParamName.setText(m_Token);
         lblParamName.setAlignment(java.awt.Label.LEFT);
         centerPanel.add(lblParamName);
         centerPanel.add(lblValue);
         centerPanel.add(txtParamValue);
         jframe.getContentPane().remove(centerPanel);
         jframe.getContentPane().add(centerPanel, "Center");
         sendBtn.setEnabled(true);
         jframe.pack();
    public static void main(String[] args)
    ClarifyClient clfy = new ClarifyClient();

  • Jbuttons are not visible

    Hi,
    Please Help.
    I have defined a Jpanel which contains some buttons. This panel is initially collapsed and there is an expand button, clicking on which will expand the panel and buttons should be visible.
    Sometimes the buttons are not visible after expanding the panel, or only some of them are visible.
    This problem is not reproducible everytime.
    For expanding and collapsing the Jpanel i am chaging the bound settings of the panel by using function
    setBounds().
    Can someone please help me with this issue?
    Thanks

    My intention was not to annoy anyone by posting my problem at two different forums. Sorry if i did that. I just wanted to get more opinions on this problem.
    The suggestions i received on this one was mainly to use 'Layout Manager'. I tried using that but was running into other issues. If i have to use Layout Manager then i guess i have to change the design of the full window. I cannot use layout manger on just the part of the window which is giving problem (please let me know i am wrong). Also, I am new to Swings and not much familiar with 'Layout Manager'.
    Is there a way to resolve this problem without using layout manager. This is not reproducible. It happens only in production.
    I am pasting my code below -
    I have modified the code as per the suggestions received from the forum to include repaint() and revalidate() methods.
    The part i added is in bold. Please let me know what changes i should do to improve this and resolve the issue.
    public static void main(String[] args) {
              initGUI();          
              frame = new JFrame();          
              frame.getContentPane().add(this);          
              frame.setBackground(LIGHT_BLUE);          
              frame.setTitle("ABC");
              logoImage = imgSPIcon.getImage();
              frame.setIconImage(logoImage);          
              frame.setSize(286,298);
              frame.setResizable(false);          
              frame.setVisible(false);  
                    frame.getContentPane().validate();  
                    frame.validate();     
    private void initGUI() {
              try {          
                   this.setSize(294, 280);
                   this.setBackground(LIGHT_BLUE);
                   this.setName("ABC");
                   getContentPane().setBackground(this.LIGHT_BLUE);
                   getContentPane().setLayout(null);               
                   this.setFocusable(false);
                   //collapse button used for expanding and collapsing the dial panel
                             m_btnCollapse = new JButton();
                             BottamPanel.add(m_btnCollapse);
                             m_btnCollapse.setBounds(163, 0, 112, 21);
                             m_btnCollapse.setIcon(imgExpandDialpad);
                             m_btnCollapse.setBorder(BorderFactory.createCompoundBorder(null, null));
                             m_btnCollapse.setBackground(new java.awt.Color(177, 201, 224));
                             m_btnCollapse.setContentAreaFilled(false);
                   //Dial panel
                        DialPanel = new JPanel();                    
                        //getContentPane().add(DialPanel);                    
                        DialPanel.setBounds(0, 251, 280, 0);                    
                        DialPanel.setLayout(null);
                        DialPanel.setBackground(bkColor);                    
                             m_btn1 = new JButton();                         
                             m_btn1.setIcon(imgDPOne);
                             m_btn1.setContentAreaFilled(false);
                             m_btn1.setBounds(79, 0, 35, 28);
                             m_btn1.setBorderPainted(false);
                             DialPanel.add(m_btn1);
                             m_btn2 = new JButton();                         
                             m_btn2.setBounds(120, 0, 35, 28);
                             m_btn2.setIcon(imgDPTwo);
                             m_btn2.setContentAreaFilled(false);
                             m_btn2.setBorderPainted(false);
                             DialPanel.add(m_btn2);
                             m_btn3 = new JButton();                         
                             m_btn3.setBounds(161, 0, 35, 28);
                             m_btn3.setIcon(imgDPThree);
                             m_btn3.setContentAreaFilled(false);
                             m_btn3.setBorderPainted(false);
                             DialPanel.add(m_btn3);
                        //includes more such buttons
                                    DialPanel.validate();
                        getContentPane().add(DialPanel);               
                   //adding mouse listner for the collapse button
                   JavaPhoneMouse aJavaPhoneMouse = new JavaPhoneMouse();
                   m_btnCollapse.addMouseListener(aJavaPhoneMouse);
         //mouse listner.
         class JavaPhoneMouse extends java.awt.event.MouseAdapter {
              public void mouseClicked(java.awt.event.MouseEvent event) {
                   Object object = event.getSource();
                   if (object == m_btnCollapse)
                        m_btnCollapse_MouseClicked(event);
         //On expanding the dial panel the dial panel is expanded(the size changes) but the buttons are invisible. 
         void m_btnCollapse_MouseClicked(java.awt.event.MouseEvent event) {
              //if the dial pad is in expanded form it will collapse else it will be expanded.
              if (isDialPadCollapsed == false) {               
                   DialPanel.setBounds(0, 251, 280, 0);
                   DialPanel.revalidate();
                   DialPanel.repaint();                              
                   BottamPanel.setBounds(0, 251, 280, 21);
                   m_btnCollapse.setIcon(imgExpandDialpad);               
                   this.setSize(280, 277);               
                   frame.setResizable(true);
                   frame.setSize(286, 298);
                   frame.setResizable(false);
                            frame.getContentPane().repaint();
                   frame.repaint();                              
                   isDialPadCollapsed = true;
              } else {               
                   this.setSize(280, 408);               
                   frame.setResizable(true);
                   frame.setSize(286, 430);
                   frame.setResizable(false);               
                   BottamPanel.setBounds(0, 384, 280, 21);               
                   DialPanel.setBounds(0, 251, 280, 133);     
                            DialPanel.revalidate();
                   DialPanel.repaint();
                   frame.getContentPane().repaint();
                   frame.repaint();          
                   m_btnCollapse.setIcon(imgCollDialpad);
                   isDialPadCollapsed = false;
    {code}
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • External hard drive not visible in disk utility or finder

    Hi all,
    I have had a good look through previous discussions and I can't seem to find an issue relevant to mine.
    My external hard drive has 2 partitions (1 time machine back up, 1 general hard drive). The issue is that the HD is running when it is plugged in however it is not visible in either disk utility or finder.
    I am running OS X 10.10 (Yosemite) on a 2010 MacBook Pro. I also have parallels desktop running windows 7. When I boot windows and plug in the HD I usually get the option to mount the HD to either OS X or Windows. With this issue the option window appears for a split second (not enough time to select either) and then disappears. It seems that the HD may be ejecting itself as soon as it is registered by the computer. I have tried using a different power cable for the HD and also a different usb cable, this doesn't help.
    The external HD is a Samsung D3 Station, which i have had for 6 months now and never had an issue with.
    Any help is appreciated
    Thanks,
    Bruce

    An update for anyone who can help me:
    I have tried the external hard drive in other computers (mac and windows), each time I get the same problem above.
    I have removed the HD from the enclosure and purchased a docking station for it (3.5" SATA). When I plug it in to the laptop it disconnects itself straight away before it is visible. With the windows computers it installs the drivers and says that the device is ready to use, then disconnects before it shows up.
    As the HD is not visible there is no option to re-format or anything.
    This is very frustrating as I was using the HD with no issues and it randomly disconnected and I have not been able to access since.
    Thanks in advance for any help.
    Bruce

  • Hi - I am looking for the Adobe Illustrator 2014 1.2 (or .0.2) bugfix update for Mac - and it is not visible in the Adobe Creative Cloud Packager (Mac version). The only update visible is Illustrator CC 2014.1  - which is what introduced the bugs.

    Hi - I am looking for the Adobe Illustrator 2014 1.2 (or .0.2) bugfix update for Mac - and it is not visible in the Adobe Creative Cloud Packager (Mac version). The only update visible is Illustrator CC 2014.1  - which is what introduced the bugs.
    The only thing that I can think of that might be causing the issues that I have a Mac Mini on Mavericks.
    Dave

    Hi
    I have discovered that my question above is a non-question. A user triggered by looking at the below article about Illustrator 2014 cc 17.0.2
    http://helpx.adobe.com/illustrator/release-note/illustrator-17-0-2-release-notes.html 
    He had recently upgraded from wht we now know is 18.0 to 18.1 which is the latest version. He read the above artic
    le and supposed that it was a bug fix release for his version - because the v17 ov18 number is not often displayed. It is usually just 2014 CC.
    I have asked him to post a bug report about Adobe Illustrator CC 2014.1
    Dave

Maybe you are looking for