Advertisement
Advertisement
| 02.29.2008 at 12:37PM PST, ID: 23205023 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: |
package comboBoxTable;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
public class MyFrame extends JFrame{
/** Creates a new instance of MyFrame */
MyTable myTable;
public MyFrame() {
myTable = new MyTable();
JScrollPane scrollPane = new JScrollPane(myTable);
JPanel myPanel = new JPanel();
myPanel.add(scrollPane);
JButton addRowButton = new JButton("Add Row");
addRowButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
addRow();
}
});
myPanel.add(addRowButton);
getContentPane().add(myPanel);
setSize(new Dimension(400,400));
pack();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void addRow(){
Object [] rowData = {"Column 1","ComboBoxItem"};
DefaultTableModel myModel = (DefaultTableModel)myTable.getModel();
myModel.insertRow(myTable.getModel().getRowCount(),rowData);
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyFrame().setVisible(true);
}
});
}
}
package comboBoxTable;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class MyTable extends JTable{
DefaultTableModel model = new DefaultTableModel();
public MyTable() {
setModel(model);
model.addColumn("Column 1");
model.addColumn("ComboBox");
String [] items = {"ITEM1","ITEM2"};
getColumn("ComboBox").setCellEditor(new MyComboBoxEditor());
getColumn("ComboBox").setCellRenderer(new MyComboBoxRenderer(items));
setVisible(true);
}
// Don't need to implement this method unless your table's data can change.
/*
public void setValueAt(Object value, int row, int col) { }
*/
public boolean isCellEditable(int row, int column) {
boolean editable = true;
if(column < 1){
editable = false;//only edit combobox
}
return editable;
}
}
package comboBoxTable;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
public class MyComboBoxEditor extends DefaultCellEditor {
// JComboBox comboBox;
public MyComboBoxEditor(String[] items) {
super(new JComboBox(items));
}
public MyComboBoxEditor() {
super(new JComboBox());
}
}
package comboBoxTable;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
public class MyComboBoxRenderer extends JComboBox implements TableCellRenderer {
public MyComboBoxRenderer(String[] items) {
super(items);
}
public MyComboBoxRenderer() {
super();
addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ComboBox Action Performed");
}
});
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
// Select the current value
setSelectedItem(value);
return this;
}
}
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 02.29.2008 at 12:43PM PST, ID: 21017356 |
| 02.29.2008 at 01:16PM PST, ID: 21017660 |
| 02.29.2008 at 01:26PM PST, ID: 21017749 |
| 02.29.2008 at 01:32PM PST, ID: 21017813 |
| 02.29.2008 at 01:38PM PST, ID: 21017852 |
| 02.29.2008 at 01:43PM PST, ID: 21017891 |
| 02.29.2008 at 01:44PM PST, ID: 21017895 |
| 02.29.2008 at 01:47PM PST, ID: 21017918 |
| 02.29.2008 at 01:49PM PST, ID: 21017937 |
| 02.29.2008 at 02:04PM PST, ID: 21018055 |
| 02.29.2008 at 02:33PM PST, ID: 21018248 |
1: 2: 3: 4: 5: 6: 7: 8: |
public MyComboBoxEditor(String[] items) {
super(comboBox();
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ComboBox Action Performed");
}
});
}
|
| 02.29.2008 at 03:01PM PST, ID: 21018441 |
1: 2: 3: 4: 5: 6: 7: 8: |
public MyComboBoxEditor(JComboxBox comboBox) {
super(comboBox();
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ComboBox Action Performed");
}
});
}
|