Advertisement
Advertisement
| 03.06.2008 at 06:54PM PST, ID: 23221939 |
|
[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: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: |
public class ListModel extends JFrame implements ActionListener {
JList list;
DefaultListModel model;
private JMenu fileMenu = new JMenu("File");
private JMenuBar menuBar = new JMenuBar();
private JMenuItem saveItem = new JMenuItem("Save");
private JMenuItem openItem = new JMenuItem("Load");
private JMenuItem exitItem = new JMenuItem("Exit");
private String filename = null;
int counter = 100;
public ListModel() {
add(new JScrollPane(list));
JFrame frame = new JFrame("List Model");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new ListModel());
frame.setSize(260, 200);
frame.setVisible(true);
fileMenu.add(openItem);
fileMenu.add(saveItem);
fileMenu.add(exitItem);
openItem.addActionListener(this);
saveItem.addActionListener(this);
exitItem.addActionListener(this);
menuBar.add(fileMenu);
setJMenuBar(menuBar);
setLayout(new BorderLayout());
model = new DefaultListModel();
JList list = new JList(model);
JScrollPane pane = new JScrollPane(list);
final JButton addButton = new JButton("Add Element");
JButton removeButton = new JButton("Remove Element");
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String element = JOptionPane.showInputDialog(this);
if (element == null)
{return;
}else{
model.addElement(element);
}
}
});
removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (model.getSize() > 0)
model.removeElementAt(0);
}
});
add(pane, BorderLayout.NORTH);
add(addButton, BorderLayout.WEST);
add(removeButton, BorderLayout.EAST);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == openItem)
try {
loadFile();
} catch (IOException e1) {
e1.printStackTrace();
}
else if (e.getSource() == exitItem)
System.exit(0);
}
private DefaultListModel loadFile() throws IOException {
JFileChooser fc = new JFileChooser();
String name = null;
if (fc.showOpenDialog(null) != JFileChooser.CANCEL_OPTION)
name = fc.getSelectedFile().getAbsolutePath();
else
return model;
FileInputStream stream = new FileInputStream(name);
InputStreamReader reader = new InputStreamReader(stream);
BufferedReader buffer = new BufferedReader(reader);
String line = buffer.readLine();
String[] words = line.split("\\s+");
for(int j=0;j<words.length;j++)
{
model.addElement(new String(words[j]));
model.addElement(words[j]);
}
return model;
}
public static void main(String s[]) {
new ListModel();
}
public ListModel getModel() {
return null;
}
public String getElementAt(int i) {
return null;
}
}//end of class
class RadioButton1 extends JApplet implements ItemListener {
private Container Panel;
private LayoutManager Layout;
private JRadioButton Unsorted;
private JRadioButton Ascending;
private JRadioButton Descending;
public RadioButton1 () {
Layout = new FlowLayout ();
Panel = getContentPane ();
Unsorted = new JRadioButton ("Unsorted");
Ascending = new JRadioButton ("Ascending");
Descending = new JRadioButton ("Descending");
Panel.setLayout (Layout);
Panel.add (Unsorted);
Panel.add (Ascending);
Panel.add (Descending);
Unsorted.addItemListener (this);
Ascending.addItemListener (this);
Descending.addItemListener (this);
}
public void itemStateChanged (ItemEvent e) {
ItemSelectable Source;
Source = e.getItemSelectable();
if (Source == Unsorted) {
//unsorted jlist
} else if (Source == Ascending) {
sortList(null);
} else if (Source == Descending) {
//descending jlist
}
}
void sortList(JList list)
{
javax.swing.ListModel model = list.getModel();
int numItems = model.getSize();
String[] a = new String[numItems];
for (int i=0;i<numItems;i++)
{
a[i] = (String)model.getElementAt(i);
}
sortArray(a);
list.setListData(a);
list.revalidate();
}
void sortArray(String[] strArray)
{
if (strArray.length == 1)
return;
Collator collator = Collator.getInstance();
String strTemp;
for (int i=0;i<strArray.length;i++)
{
for (int j=i+1;j<strArray.length;j++)
{
if (collator.compare(strArray[i], strArray[j]) > 0)
{
strTemp = strArray[i];
strArray[i] = strArray[j];
strArray[j] = strTemp;
}
}
}
}
}
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 03.06.2008 at 06:57PM PST, ID: 21066956 |
| 03.06.2008 at 07:02PM PST, ID: 21066974 |