Article View: borland.public.jbuilder.java.swing
Article #10099JB3 Bug? DecFrame + JTable cell renderer problems
From: bl
Date: Thu, 18 Nov 1999 00:00
Date: Thu, 18 Nov 1999 00:00
124 lines
4305 bytes
4305 bytes
Where is the appropriate place to submit a bug report or look for other
existing bug reports?
I have been unable to get JB3 to allow me to put a combo box inside a
table cell/column if I use DecoratedFrame as the top level frame. The
programs compile and run, but clicking on the dropdown control causes
a brief flash of the menu, it never becomes accessible.
Here is the simplest version of the code I was able to create that shows
the problem.
Taking this code and simply replacing "DecoratedFrame" with "JFrame"
and then adding the 2 appropriate "getContentPane()" calls, makes it
work fine. The code here, when compiled on my system, will not let
me access the ComboBox. Is there something I'm not understanding about
the interactions between Swing components and JB components?
thanks for any help,
b
blincoln@ssesco.com
--
import java.awt.*;
import java.awt.event.*;
import com.borland.jbcl.control.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import javax.swing.table.*;
public class Frame1 extends DecoratedFrame {
XYLayout xYLayout2 = new XYLayout();
BevelPanel bevelPanel1 = new BevelPanel();
BorderLayout borderLayout1 = new BorderLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable1;
//Construct the frame
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jTable1 = new JTable(new MyTableModel());
this.setLayout(borderLayout1);
this.setSize(new Dimension(529, 360));
TableColumn column = null;
SetUpPopup(jTable1.getColumnModel().getColumn(3));
bevelPanel1.setLayout(xYLayout2);
this.add(bevelPanel1, BorderLayout.CENTER);
bevelPanel1.add(jScrollPane1, new XYConstraints(16, 50, 468, 101));
jScrollPane1.getViewport().add(jTable1, null);
}
//File | Exit action performed
public void fileExit_actionPerformed(ActionEvent e) {
System.exit(0);
}
class MyTableModel extends AbstractTableModel
{
final String[] columnNames = { "A", "B", "C", "D", "E" };
String [][] Data = { { "11","12","13","14","15"} ,
{"21","22","23","24","25"} } ;
public int getColumnCount() { return columnNames.length; }
public int getRowCount() { return 2; }
public String getColumnName(int col) { return
columnNames[col]; }
public Object getValueAt(int row, int col)
{ return Data[row][col];
}
public Class getColumnClass(int c)
{
return getValueAt(0, c).getClass();
}
/*
* Don't need to implement this method unless your table's
* editable.
*/
public boolean isCellEditable(int row, int col)
{ return true; }
public void setValueAt(Object value, int row, int col)
{ Data[row][col] = (String) value;
}
}
public void SetUpPopup(TableColumn myCol)
{
//Set up the editor for the Num Bytes cells.
JComboBox JCB = new JComboBox();
JCB.addItem("4");
JCB.addItem("2");
JCB.addItem("1");
JCB.addItem("this is too");
myCol.setCellEditor(new DefaultCellEditor(JCB));
DefaultTableCellRenderer renderer = new
DefaultTableCellRenderer();
myCol.setCellRenderer(renderer);
}
public static void main(String[] args) {
Frame1 frame = new Frame1();
if (packFrame)
frame.pack();
else
frame.validate();
frame.setVisible(true);
}
}
Technical Details
Message-ID:
<3834C9F0.3AE307BE@ssesco.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,8a61be33a47042dd,start X-Google-Attributes: gid111d45,public From: bl <blincoln@ssesco.com> Subject: JB3 Bug? DecFrame + JTable cell renderer problems Date: 1999/11/18 Message-ID: <3834C9F0.3AE307BE@ssesco.com> X-Deja-AN: 550394123 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing