Anagha Medicharla

Greenhorn
+ Follow
since Feb 06, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anagha Medicharla

Hi Brayan,
I tried your code.It is not solving my problem.But thank you very much for your help.I think what Mike saying is correct.

HI Mike,
Can you give me little hint about how to write an explicit code to save such program?

Thanks
Anagha
22 years ago
Hi,
I want to take information from user and that information I want to add to JComboBox.For that I have created few textfields.
Means user will fill information into that textfields and if he click 'Add' button it should go to JComboBox.for that I have created ActionPerformedEvent.What is happening is it's working correct.But When I again run the same application previously added information is not there.Means whatever I am adding through 'Add' button it's not getting added to JcomboBox permanently. Why is this happening?If anybody has an idea please reply immediately.

Thanks
Anagha
------------------
22 years ago
Hi ,
In my project I have created many forms like candiateInfo,Resume etc.(which extends JFrame)
Now I want to use JTabbedPane.Menas if I click on one tab it should take user to resp. form.Code I have written like this(it's in contstructor of that class):
[code]{ contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
JTabbedPane tabbedPane = new JTabbedPane();
String tabs[] = {"CandidateInfo", "Resume"};
tabbedPane.addTab(tabs[0], new Candidate());
tabbedPane.addTab(tabs[1], new Resume());
tabbedPane.setSelectedIndex(0);
add(tabbedPane, BorderLayout.CENTER);

this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
}
****It's giving runtime error- IllegalArgumentException:a window added to a conatainer.Can anybody explain me why it's giving this error.

Thanks in advance
Anagha

------------------
22 years ago
Hi everybody,
In my project i want to write reports.Can anybody tell me how to write reports in java.Is there any special tool for that?
Please send immediate reply.It's urgent.
Thanx in advance
Anagha

------------------
23 years ago
Hi,
I want cells in JTable that takes multiline text. I have created two classes ,TextAreaEditor and TextAreaRenderer.I think there is a problem with TextAreaEditor class .When I type in one cell and go to other cell, conetent of previous cell disappears.
Cananybody help me out.
I have written the code as follows:
[code] class TextAreaEditor extends DefaultCellEditor {
protected JTextArea txt;
private String label;
public TextAreaEditor(JCheckBox checkBox) {
super(checkBox);
txt = new JTextArea();
txt.setOpaque(true);
txt.setLineWrap(true);
txt.setWrapStyleWord(true);
txt.setOpaque(true);

}
public Component getTableCellEditorComponent(JTable table, Object value,boolean isSelected, int row, int column) {

label = (value ==null) ? "" : value.toString();
txt.setText( label );
return txt;
}
public Object getCellEditorValue() {
return new String( label ) ;
}
public boolean stopCellEditing() {
return super.stopCellEditing();
}
protected void fireEditingStopped() {
super.fireEditingStopped();
}
}[\code]
23 years ago
Hi everybody,
I am using JTable.I want rows that takes multiline text.
I have written the code as follows.what is happening is when I press enter on a cell of that row it's going to next row(means it's is not going to next line of same cell but it is crearing new row and it's gong to that row.)
Can anybody help me .
I am giving cod here:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.DefaultCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.JScrollPane;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.JOptionPane;
import javax.swing.border.*;
public class ConersationLogInfo extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
//Construct the frame
public ConersationLogInfo() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception{
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(576, 300));
this.setTitle("CONVERSATION LOG");
jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel1.setMinimumSize(new Dimension(80, 80));
jPanel1.setPreferredSize(new Dimension(80, 80));
jPanel2.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel2.setLayout(null);
jScrollPane1.setBounds(new Rectangle(1, 10, 573, 218));
contentPane.add(jPanel1, BorderLayout.NORTH);
contentPane.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jScrollPane1, null);
MyTableModel myModel = new MyTableModel(){
public Class getColumnClass(int columnIndex) {
return String.class;
}
};
JTable table = new JTable(myModel);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
int lines = 2;
table.setRowHeight( table.getRowHeight() * lines);
table.setDefaultRenderer(String.class,new MultiLineCellRenderer());
jScrollPane1.getViewport().add(table, null);

}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
class MyTableModel extends AbstractTableModel {
final String[] colheads={"DATE","TIME","CALLER_ID","REASON","CONVERSATION INFO"};
final String[][] data={{"","","","",""}, {"","","","",""}};
public int getColumnCount() {
return colheads.length;
}
public int getRowCount() {
return data.length;
}
public String getColumnName(int col) {
return colheads[col];
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
/*
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
*/
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) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.

return true;
}
}
class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
public MultiLineCellRenderer() {
setLineWrap(true);
setWrapStyleWord(true);
setOpaque(true);
}
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
setBackground(table.getSelectionBackground());
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
}
setFont(table.getFont());
if (hasFocus) {
setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
if (table.isCellEditable(row, column)) {
setForeground( UIManager.getColor("Table.focusCellForeground") );
setBackground( UIManager.getColor("Table.focusCellBackground") );
}
} else {
setBorder(new EmptyBorder(1, 2, 1, 2));
}
setText((value == null) ? "" : value.toString());
return this;
}
}
Anagha
23 years ago
Hi,
Can anybody explain me how to use JTextArea as a renderer in a JTable.
thanks
Anagha
23 years ago
hi,
First time I am using JTable.My table will be like this ,
1.user will enter data into table
2.If user clik on last row new row should be created.
3.I want multiline text in each cell.
Can anybody guide me regarding this.
Thanks in advance
ANAGHA
23 years ago
Hi Selvas,
Thanks for your reply. I tried your code.
But it's throwing java.lang.StackOverflowError.
I have written the code as folllows.
jcomboState.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(ItemEvent e) {
jcomboState_itemStateChanged(e);
}
});
void jcomboState_itemStateChanged(ItemEvent e) {
jcomboState.setSelectedItem((jcomboState.getSelectedItem().toString()).substring(0,2));
}

Can you help me out further.Why is it throwing that exception?
Anagha

23 years ago
Hi everybody,
I am using JComboBox for user to select state in US.what i want to do is if user selects 'ALABAMA' then text in combobox should set to 'AL'.Does anybody know how to do tis?

Thanx in advance.
23 years ago
Hi,
Using swing i am creating a text field which will take email address from user.I have one question ,how to check that user has entered '@'(and also '.').Does anybody know this?
I need urgent help.

Thanks
Anagha
------------------
23 years ago