Deepak Raj

Greenhorn
+ Follow
since Jul 22, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Deepak Raj

How do I align text vertically on a JButton? i.e. How do I get the text "Button" display like a top-down instead of left-right? Here's a part of my code...
JButton1.setText("Button");
getContentPane().add(JButton1);
JButton1.setBounds(84,72,38,190);
23 years ago
I have a database of algorithms (all in text). I intend to construct a flowchart(more of a sequence chart diagram) from the algorithm upon the click of a button. Is this feasible in Java Swing? What's the best way to go about doing this? Is Java 2D a good bet?
Any help will be greatly appreciated as I have limited time.
-Deepak
23 years ago
Rajan, I tried what you said but it didn't seem to work. I am adding textfields dynamically to the Panel. The problem lies in showing the Vertical scroll bar once the text fields in the JPanel exceeds the Panel's size. The scrolls don't seem to show up. Here is part of my code where the problem might lie.
public Scenario() // Constructor
{
textPanel = new JPanel();
textPanel.setLayout(null);
textPanel.setSize(508, 520);
textPanel.setLocation(10,10);
//..........lines of code
//.............
}
public void addComponent(String text)
{
j = j + 30;
i = i+1;
String lineno = Integer.toString(i) + ".";
field = new JLabel(lineno);
field.setBounds(90,j,20,24);
textPanel.add(field);

if (addline){
content = new JTextField(text);
content.setBounds(108,j,400,24);
content.setBackground(new Color(255,255,255));
textPanel.add(content);
addline = false;
invscenario = false;
}
else if(invscenario) {
content = new JTextField(text);
content.setBounds(108,j,50,24);
content.setEditable(false);
textPanel.add(content);
try{
if (content.getText().length()!= 0)
{
Statement statement1 = conn.createStatement();
String query1 = "SELECT * FROM scenario " + "WHERE scenario_num LIKE '" + text + "'";
rs = statement1.executeQuery(query1);
rs.next();
int recordNumber = rs.getInt(1);
if(recordNumber != 0)
{
labelcontent = new JLabel(rs.getString(3));
labelcontent.setBounds(165,j,100,24);
textPanel.add(labelcontent);
}
}
}// end try
catch(SQLException e)
{
System.out.println(e);
}
invscenario = false;
addline = false;
}
scrollPane = new JScrollPane(textPanel);
scrollPane.add(textPanel);
contentPane.add(scrollPane);
contentPane.repaint();
show();
}

23 years ago
I have a dynamic user iterface, where the JTextFields are added dynamically to a JPanel within the JFrame upon the click of a JButton. How do I use the JScrollPane so that the Vertical Scroll bar shows up for the JPanel as soon added TextFields go out of range? Any ideas/piece of code to help me out will be of great help!
Regards
-Deepak
23 years ago