This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Dynamic panel ...

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i want to have dynamic panel. Let say i have 5 appointment,then i want to have 5 panels. If i just have 2 appointments then i just have 2 panel in my frame...
thanks in advance...
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not use a JTabbedPane? there is a tutorial here:
http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
 
suraya ya'acob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your suggestion...
but the problem is I need all the panels appear at the same time in my frame.
Let say i have 5 appointment which is retrieve from database..then each panel will have different contents...
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not put all your panels in a Box (vertical) and put the box in a JScrollPane?
I remember using this technique in a small email client I wrote, where I wanted the "Preview Pane" to contain different panels based on the number of attachments in the mail... it worked!
[ July 15, 2003: Message edited by: Abhik Sarkar ]
[ July 15, 2003: Message edited by: Abhik Sarkar ]
 
suraya ya'acob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...
i've got how to have dynamic JPanel but the thing is... how to put different content to each panel?
thank u
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope this little snippet helps in some way... of course, this might not be the most efficient way of going about it
 
suraya ya'acob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is class can be loop ?
Here is my coding...
My output should be a few lines depends on data of t_diagnosa1 in database...but the thing is...only 1 line appear in my interface but the output from "system.out.println..." appear the looping data..
let say..t_diagnosa1 have value for "302" and "402" then i should have two lines...
*********mdinamik.java**************
import java.awt.*;
import java.awt.Container;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import javax.swing.border.*;
import java.awt.image.*;
import java.sql.*;
import java.util.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.text.*;
public class mdinamik extends JFrame{
String starikh;
int tarikh;
int bil;
int piksel;

public mdinamik()
{
Container pane = getContentPane();
pane.setLayout(new FlowLayout());

try
{
String url = "jdbc dbc b2";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url);

Statement stmt = conn.createStatement();

String query = "SELECT t_diagnosa1 FROM diagnosa WHERE nopesakit = '51' ";
ResultSet rs = stmt.executeQuery(query);

while (rs.next() )
{
starikh = rs.getString("t_diagnosa1");
tarikh = Integer.parseInt(starikh);
System.out.println("starikh" + tarikh);

bil = 0;
piksel = 0;

if(tarikh != 102)
{
bil++;
if(tarikh != 202)
{
bil++;
if(tarikh != 302)
{
bil++;
if(tarikh !=402)
{bil++;
}}}}
if(bil == 1)
piksel = 30;
else if(bil == 2)
piksel = 60;
else if(bil == 3)
piksel = 90;
pixel p1 = new pixel (piksel, 20,600);
pane.add(p1);
System.out.println("bil :" + bil);
System.out.println("piksel :" + piksel);
}
conn.close();
}
catch (Exception e) {
System.err.println("dddd");
System.err.println(e.getMessage());
}


setBounds(0,0,904,750);
setVisible(true);
}
public static void main (String args[])
{
mdinamik aya = new mdinamik();
aya.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
*******pixel.java**********************
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.*;
import java.awt.Container;
import java.awt.event.*;
import java.applet.*;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
import javax.swing.border.*;
import java.awt.image.*;
import java.sql.*;
import java.util.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.text.*;

public class pixel extends JComponent {
int piksel, x,x2;
public pixel(int piksel, int x, int x2) {
this.piksel = piksel;
this.x = x;
this.x2 = x2;
this.setPreferredSize(new Dimension(1000,1000));
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d=(Graphics2D) g;
g2d.drawLine(piksel,x,piksel,x2);

}

public int getpiksel() {
return piksel;
}
public void setY(int piksel) {
this.piksel = piksel;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}

public int getX2() {
return x2;
}
public void setX2(int x2) {
this.x2 = x2;
}

}
 
reply
    Bookmark Topic Watch Topic
  • New Topic