Cardlayout show  --- delay ..

CardLayout card = (CardLayout ) (jPanel1.getLayout());
DownTable dt = new DownTable();
dt.setBounds(0,0,1016,526);
jPanel1.add(dt,"downTable");
card.show(jPanel1, "downTable");
jPanel1.validate();
dt.downloading(dt.getsFileName(),dt.getlFileSize());
I can't promptly show downTable card ..
dt.downloading(dt.getsFileName(),dt.getlFileSize()); <--- this code is downloading files
dt.downloading(dt.getsFileName(),dt.getlFileSize());<-- if this code is not exist, i can promptly show card. but exist this code, i can't promptly show card.
that's my problem!
so sorry my poor english

Don't forget to use the "Code Formatting Tags", so the posted code retains its original formatting.
http://forum.java.sun.com/help.jspa?sec=formatting
in the future, Swing related questions should be posted in the Swing forum.
Read the Swing tutorial on "Concurrency" for an explanation of what is happening and why the above suggestion should solve the problem:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html

Similar Messages

  • Automatic do background work in panelX when you cardLayout.show(panelX)?

    Let me first explain what I try to accomplish
    +Panel 1: A form that allow people to enter username and password to connect to a database
    +Panel 2: Use the connection that just created in panel1 to access database and load data into a JcomboBox
    +ContentPane that hold these 2 panel (Layout: cardlayout)
    +Top container is a JApplet
    So when the program load, I will cardlayout.show(Panel1), then if the user press a "submit" button, I will cardlayout.show(Panel2). Simple enough. Panel2' s job is to silently access a database using the connection that is created in panel1 a load some information onto a JComboBox. My question is how do I design so that when the user press that "submit" button, it detects that now panel2 is in focus so invoke my loadData() that access the database and load data onto the JcomboBox?
    Right now i have it so that when panel2 show, the user have to click the "load" button to load information. However, I wish to change that. So please give me some advice.
    Thank you very much and happy thanksgiving

    JohnBrand wrote:
    A clarifying question - should the uploading and downloading be done on a SwingWorker background thread or should it be on a non-SwingWorker thread? You can do it either way. It's fielder's choice here.
    Don't the SwingWorker threads end up on the Event Dispatch Thread?Some methods of SwingWorker are always called in the EDT including the done method and the process method, but the main method, doInBackground, in fact the only method that is required in a SwingWorker-extended class is done off of the EDT. Having methods that reliably work on and off of the EDT is what makes using a SwingWorker object an easier way to create background threads in Swing vs. creating a roll-your-own background thread.

  • CardLayout does not work

    I'm building a dynamic UI which has "x" number of labels and "x" no of fields. I'm able build the UI.
    When I make a selection in the ComboBox the UI(labels and fields change). For this I'm using a cardlayout.
    It does not seem to work.
    AttributesPanel builds the UI(Labels, Fields)
    import java.util.*;
    import java.util.List;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class AttributesPanel extends JPanel {
        private JTextField[] fields;
        private List attributes;
        public AttributesPanel(String templateName) throws Exception{
            JSeparator sep = new JSeparator();
            JButton okButton = new JButton("OK");
            JButton cancelButton = new JButton("Cancel");
            com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader loader = new com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader();
            attributes = loader.BuildAttributes(templateName);
            for(int i = 0; i< attributes.size(); i ++) {
              String attributename = (String)attributes.get(i);
              System.out.println("Names of the attribute: " +attributename);
            fields = new JTextField[attributes.size()];
            JLabel[] labels = new JLabel[attributes.size()];
            for(int i = 0; i< attributes.size(); i++) {
                labels[i] = new JLabel((String)attributes.get(i));
                fields[i] = new JTextField(15);
            GridBagLayout gb1 = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            setLayout(gb1);
            gbc.anchor = GridBagConstraints.NORTHWEST;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            add(new JLabel("Assign Profile Template"), gbc);
            gbc.anchor = GridBagConstraints.NORTH;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.insets = new Insets(0,0,10,0);
            add(sep, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            gbc.insets = new Insets(0,0,0,0);
            for(int i = 0;i < attributes.size(); i ++){
                gbc.gridwidth = 1;
                add(labels[i] ,gbc);
                add(Box.createHorizontalStrut(10));
                gbc.gridwidth = GridBagConstraints.REMAINDER;
                add(fields,gbc);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.insets = new Insets(15,0,0,0);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = 7;
    add(buttonPanel,gbc);
    2nd class which calls AttributesPanel
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.lang.*;
    import java.util.*;
    import java.util.List;
    public class ProfileUI extends JPanel implements ActionListener{
    private JPanel templatePanel;
    JComboBox comboBox = new JComboBox();
    private CardLayout cardLayout;
    com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader loader = new com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader();
    public ProfileUI() throws Exception {
    templatePanel = new JPanel();
    List templates = loader.BuildTemplates();
    comboBox.addActionListener(this);
    for(int i = 0; i< templates.size(); i ++) {
    comboBox.addItem(templates.get(i));
    //attributes = loader.BuildAttributes((String)templates.get(i));
    templatePanel.add(comboBox);
    List attributes = loader.BuildAttributes("Email Template");
    // //creating no of card layouts.
    cardLayout = new CardLayout();
    JPanel mainCardPanel = new JPanel(cardLayout);
    AttributesPanel[] cardPanels = new AttributesPanel[attributes.size()];
    for (int i = 0; i < attributes.size(); i++) {
    mainCardPanel.add(cardPanels[i], i);
    // createCardPanel(cardPanels[i], (String)comboBox.getItemAt(i));
    cardLayout.show(cardPanels[i], "" + i);
    templatePanel.add(mainCardPanel);
    //updateLabel(0);
    cardLayout.show(cardPanels[0], "" + 0);
    public void actionPerformed(ActionEvent e){
    if(e.getSource() == comboBox) {
    public static void main (String args []) throws Exception {
    JFrame frame = new JFrame("ProfileUI");
    JComponent newContentPane= new ProfileUI();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // use this or a
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    frame.setSize(400,390);
    frame.setVisible(true);
    //frame.setResizable(false);
    thnx

    Personally, I've had numerous issues with CardLayout -- I'd suggest you try CardPanel instead:
    http://java.sun.com/products/jfc/tsc/articles/cardpanel/
    - Fromage

  • Background job Delay In ( sec)

    Hi Experts ,
    I submitted one job in background Via SM37 here i have one question.
    Job is still in Active but it shows  Delay ( sec ) 2,181.
                                                    Duration ( Sec) 1,999
    what it means ?
    Thnx .

    Hi
    refer the below Link:
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/ab3207b610e3408fff44d6b1de15e6/content.htm

  • Delayed Payment charges and Arrears in the Invoice output

    Hi,
    can we show Delayed Payment charges and Arrears in the Invoice output in case of SD invoice. From where can i take those. suggest.

    Hi,
    Please check whether the SMARTFORM/SAP SCRIPT  was created in the DE login langage, if so then you have to maintain the Language conversion using SE63 transaction
    Goto SE63 and in that transaction you have option to convert the TEXT to different langage.
    Use transaction SE63 (translations). From the menu select:
    Translation - Logntexts - Sapscript - Forms
    From this point on you can translate both the descriptions and the
    window texts. This transaction also checks if you don't forget to
    translate a part of the script.
    Hope it is clear
    cheers,
    santosh

  • I Can't switch my CardLayout @.@

    There is a card 3 but i havn't add ,so the "Enterbtn" is to trigger card 3.
    So what is wrong with my code that it can't switch? I changed the cardPanel from 2 to 1 and 1 to 2 but it only appear card 2.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class HPhoneInv extends JFrame {
    private int currentCard = 1;
    private JPanel cardPanel;
    private CardLayout cl;
    public HPhoneInv() {
    setTitle("Handphone Inventory System");
    setSize(500, 160);
    cardPanel = new JPanel();
    cl = new CardLayout();
    cardPanel.setLayout(cl);
    JPanel jp1 = new JPanel();
    jp1.setLayout(new GridLayout(1,1) );
    JLabel jl1 = new JLabel("Select Option:");
    jp1.add(jl1);
    cardPanel.add(jp1, "1");
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1,2) );
    JButton AcqBtn=new JButton("Used Phone Acquisition");
    JButton TranBtn=new JButton("Sale Transaction");
    buttonPanel.add(AcqBtn);
    buttonPanel.add(TranBtn);
    getContentPane().add(jp1, BorderLayout.NORTH);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    JPanel jp2 = new JPanel();
    jp2.setLayout(new GridLayout(5,2) );
    JLabel lbl1 = new JLabel("Cust IC No:");
    JLabel lbl2= new JLabel("Brand:");
    JLabel lbl3 =new JLabel("Model:");
    JLabel lbl4=new JLabel("Serial No:");
    JLabel lbl5=new JLabel("Cost:");
    JTextField tf1=new JTextField("");
    JTextField tf2=new JTextField("");
    JTextField tf3=new JTextField("");
    JTextField tf4=new JTextField("");
    JTextField tf5=new JTextField("");
    jp2.add(lbl1);
    jp2.add(tf1);
    jp2.add(lbl2);
    jp2.add(tf2);
    jp2.add(lbl3);
    jp2.add(tf3);
    jp2.add(lbl4);
    jp2.add(tf4);
    jp2.add(lbl5);
    jp2.add(tf5);
    cardPanel.add(jp2, "2");
    JPanel buttonPanel2 = new JPanel();
    buttonPanel2.setLayout(new GridLayout(1,2) );
    JButton EnterBtn=new JButton("Enter");
    JButton CancelBtn=new JButton("Cancel");
    buttonPanel2.add(EnterBtn);
    buttonPanel2.add(CancelBtn);
    getContentPane().add(jp2, BorderLayout.NORTH);
    getContentPane().add(buttonPanel2, BorderLayout.SOUTH);
    AcqBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    if (currentCard < 2) {
    currentCard +=1;
    cl.show(cardPanel, "" + (currentCard));
    TranBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    if (currentCard < 2) {
    currentCard += 1;
    cl.show(cardPanel, "" + (currentCard));
    EnterBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    if (currentCard > 1) {
    currentCard = 1;
    CancelBtn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    if (currentCard > 1) {
    currentCard = 1;
    cl.show(cardPanel, "" + (currentCard));
    public static void main(String[] args) {
    HPhoneInv cl = new HPhoneInv();
    cl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    cl.setVisible(true);
    Message was edited by:
    RockmanEXE
    Message was edited by:
    RockmanEXE

    The order of the components, added into the cards and into the JFrame are wrong, so i just rearranged the order and i added one more JPanel.
    so based on that, u code accordinglyimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class HPhoneInv extends JFrame {
        private int currentCard = 1;
        private JPanel cardPanel;
        private CardLayout cl;
        JPanel card1 = null;
        JPanel card2 = null;
        public HPhoneInv() {
            setTitle("Handphone Inventory System");
            setSize(500, 160);
            cardPanel = new JPanel(new CardLayout());
            JPanel jp1 = new JPanel();
            jp1.setLayout(new GridLayout(1,1) );
            JLabel jl1 = new JLabel("Select Option:");
            jp1.add(jl1);
            //cardPanel.add(jp1, "1");
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new GridLayout(1,2) );
            JButton AcqBtn=new JButton("Used Phone Acquisition");
            JButton TranBtn=new JButton("Sale Transaction");
            buttonPanel.add(AcqBtn);
            buttonPanel.add(TranBtn);
            card1 = new JPanel(new BorderLayout());
            //getContentPane().add(jp1, BorderLayout.NORTH);
            //getContentPane().add(buttonPanel, BorderLayout.SOUTH);
            card1.add(jp1, BorderLayout.NORTH);
            card1.add(buttonPanel, BorderLayout.SOUTH);
            card2 = new JPanel(new BorderLayout());
            JPanel jp2 = new JPanel();
            jp2.setLayout(new GridLayout(5,2) );
            JLabel lbl1 = new JLabel("Cust IC No:");
            JLabel lbl2= new JLabel("Brand:");
            JLabel lbl3 =new JLabel("Model:");
            JLabel lbl4=new JLabel("Serial No:");
            JLabel lbl5=new JLabel("Cost:");
            JTextField tf1=new JTextField("");
            JTextField tf2=new JTextField("");
            JTextField tf3=new JTextField("");
            JTextField tf4=new JTextField("");
            JTextField tf5=new JTextField("");
            jp2.add(lbl1);
            jp2.add(tf1);
            jp2.add(lbl2);
            jp2.add(tf2);
            jp2.add(lbl3);
            jp2.add(tf3);
            jp2.add(lbl4);
            jp2.add(tf4);
            jp2.add(lbl5);
            jp2.add(tf5);
            //cardPanel.add(jp2, "2");
            JPanel buttonPanel2 = new JPanel();
            buttonPanel2.setLayout(new GridLayout(1,2) );
            JButton EnterBtn=new JButton("Enter");
            JButton CancelBtn=new JButton("Cancel");
            buttonPanel2.add(EnterBtn);
            buttonPanel2.add(CancelBtn);
            //getContentPane().add(jp2, BorderLayout.NORTH);
            //getContentPane().add(buttonPanel2, BorderLayout.SOUTH);
            card2.add(jp2, BorderLayout.NORTH);
            card2.add(buttonPanel2, BorderLayout.SOUTH);
            cardPanel.add(card2,"two");
            cardPanel.add(card1,"one");
            this.getContentPane().add(cardPanel);
             AcqBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                        CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
                        cardLayout.show(cardPanel,"two");
                    /*if (currentCard < 2) {
                        currentCard +=1;
                        cl.show(cardPanel, "" + (currentCard));
               TranBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                        CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
                        cardLayout.show(cardPanel,"two");
                    /*if (currentCard < 2) {
                        currentCard += 1;
                      cl.show(cardPanel, "" + (currentCard));
                EnterBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                        //System.out.println("Enter Button got clicked");
                        CardLayout cardLayout = (CardLayout)(cardPanel.getLayout());
                        cardLayout.show(cardPanel,"one");
             CancelBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                        System.exit(0);
                    if (currentCard > 1) {
                        currentCard = 1;
                      cl.show(cardPanel, "" + (currentCard));
        public static void main(String[] args) {
            HPhoneInv cl = new HPhoneInv();
            cl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            cl.setVisible(true);
    }

  • Script to change PowerPoint shows automatically

    Hi, I'm trying to figure out a task using AppleScript without much joy, hoping some wise person can help me with some pearls of wisdom:)
    Basically, I'm using a PowerMac running 10.3.9 to automatically display a PowerPoint show of announcements (.pps file). That works fine, it wakes at a certain time, and using a scheduled task in iCal it begins the PowerPoint show at the right time.
    But at a certain time I want it to switch to a different .pps show, and I cannot get it to do this. It will not quit the current show without me manually hitting escape, and then it straight away loads and runs the next show, but it won't do it automatically.
    Is this something I can write a specific AppleScript for? Or is it an iCal issue, where it won't run a scheduled task while another is running? Is it a Panther issue that has been resolved in Tiger?
    I'd be grateful for any help, thanks:)
    Mark.

    Ironically, even with 'Microsoft Excel' instead of 'Microsoft PowerPoint' the two (2) code segments above did function as expected.
    For clarity:
    -- Code starts here --
    set presentation01 to "HD02_140:Users:s:Desktop:Presentation1.pps"
    set presentation02 to "HD02_140:Users:s:Desktop:Presentation2.pps"
    set dPeriod to 25 -- Number of seconds to delay, before switching '.pss' files.
    tell application "Microsoft PowerPoint" to open presentation01 -- Open first presentation slide show.
    delay dPeriod
    tell application "System Events" to tell process "Microsoft PowerPoint" to key code 53 -- 'esc' key pressed.
    tell application "Microsoft PowerPoint" to open presentation02 -- Open second presentation slide show.
    -- Code ends here --
    ... and ...
    -- Code starts here --
    set presentation02 to "HD02_140:Users:s:Desktop:Presentation2.pps"
    tell application "System Events" to tell process "Microsoft PowerPoint" to key code 53 -- 'esc' key pressed.
    tell application "Microsoft PowerPoint" to open presentation02 -- Open second presentation slide show.
    -- Code ends here --
    However, the code segments can be reduced even further, to ...
    -- Code starts here --
    set presentation01 to "HD02_140:Users:s:Desktop:Presentation1.pps"
    set presentation02 to "HD02_140:Users:s:Desktop:Presentation2.pps"
    set dPeriod to 25 -- Number of seconds to delay, before switching '.pss' files.
    tell application "Microsoft PowerPoint"
    open presentation01 -- Open first presentation slide show.
    delay dPeriod
    tell application "System Events" to key code 53 -- 'esc' key pressed.
    open presentation02 -- Open second presentation slide show.
    end tell
    -- Code ends here --
    ... and ...
    -- Code starts here --
    set presentation02 to "HD02_140:Users:s:Desktop:Presentation2.pps"
    tell application "System Events" to key code 53 -- 'esc' key pressed.
    tell application "Microsoft PowerPoint" to open presentation02 -- Open second presentation slide show.
    -- Code ends here --
    ... respectively.

  • Reducing the delay time.

    hi sapgurus,
       I am facing problem with the process chains.
    1.The job BI_PROCESS_TRIGGER is taking a delay time of 1445 secs.
       The chain is getting after 15 minutes of scheduled time,
      I checked in sm37,its showing delay.
    2. BI_PROCESS_LOADING taking a delay of 1203 secs.
       The infopackages are getting started after about 10 minutes,from previous job.
    Can anybody help me to solve this problem.
    thanks in advance.

    Hi,
    If the chain start, and the job is in delay mode, check in SM50 that you have a BGD/BCT Work Process to take the request from the process chain.
    May be you dont have free Work Process to take the request.After waiting for 10 or 15 minutes, the system get a free work process which starts processing the process chain.

  • CardLayout & AWT Components

    Switching between panels when using AWT components with a CardLayout is not as smooth as when using Swing components.
    At best the 2 panels seem to merge into one another until only one is displayed, while at worst a part of the previous panel can remain on the screen for a half second or so before the switch is complete.
    Kind of hard to explain but there is no instantaneous switch like you get when using Swing components.
    As I hope to eventually run this GUI as an Applet - when the problem may, I imagine, become even more pronounced - I would be grateful for any assistance anyone could offer on this matter.
    When switching the panels ALL I do is:
    cardLayout.show(deck, "PanelName");

    Well it's too big to post the whole thing. Some snippets:
    // add the panels to the cardLayout
    deck = new Panel();
    deck.setLayout(cardDisplay);
    deck.add(menuPanel, "MenuPanel");
    deck.add(notePanel, "NotePanel");
    deck.add(logonPanel, "LogonPanel");
    deck.add(tabbedPane, "TabbedPane");
    this.add(deck);
    cardDisplay.show(deck, "LogonPanel");
    // switch on some button press
    if (e.getSource() == appendNote)
    cardDisplay.show(deck, "NotePanel");
    noteArea.requestFocus();

  • Images in an applet

    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CardDeck5 extends Applet implements ActionListener
    {//start class CardDeck3
    private CardLayout cardLayout;
    private Panel main,crd1,crd2,crd3,crd4,crd5,p,card;
    private Button first,second,third,fourth,fifth,sixth;
    private Image image1,image2,image3,image4,image5,image6,image7,image8;
    static int typeImage=0;
    public void init()
    {     //start void init
    Image image1=getImage(getDocumentBase(),"chi2.gif");
         /*image2=getImage(getDocumentBase(),"Frog.gif"); //establish variables for images
         image3=getImage(getDocumentBase(),"Cryn_syf.gif");
         image4=getImage(getDocumentBase(),"Cnitemid.gif");
         image5=getImage(getDocumentBase(),"aoxom.gif");
         image6=getImage(getDocumentBase(),"stealy.gif");
         image7=getImage(getDocumentBase(),"lake_tahoe_ban.gif");
         image8=getImage(getDocumentBase(), "mykistys.jpg");*/
         prepareImage(image1, this);
         /*prepareImage(image2, this);
         prepareImage(image3, this);
         prepareImage(image4, this);
         prepareImage(image5, this);
         prepareImage(image6, this);
         prepareImage(image7, this);
    prepareImage(image8, this);*/
    setLayout(new BorderLayout());     //set layout
    card = new Panel();                                   //est main panel
         card.setSize(500,500);
    cardLayout = new CardLayout();     //est card layout
    card.setLayout(cardLayout);          //put cardlayout on panel
    add("Center", card);
    /*first card*/
    Picture Pic1=new Picture();                    //create Pic1 of type Picture
    Pic1.setSize(400,400);               //set size of panel
    crd1=new Panel();                    // Pic1 to panel crd1
    crd1.add(Pic1);                     //add Pic 1 to panel crd1
    card.add(crd1,"1");               //add crd1 to main panel
    /*second card*/
    Picture Pic2=new Picture();
         Pic2.setSize(400,400);
    crd2=new Panel();
    crd2.add(Pic2);
    card.add(crd2,"2");
    /*third card*/
         Picture Pic3=new Picture();
         Pic3.setSize(400,400);
    crd3=new Panel();
    crd3.add(Pic3);
    card.add(crd3,"3");
    /*fourth panel*/
    Picture Pic4=new Picture();
         Pic4.setSize(400,400);
         crd4=new Panel();
         crd4.add(Pic4);
    card.add(crd4,"4");
    /*fifth panel*/
    Picture Pic5=new Picture();
    Pic5.setSize(400,400);
    crd5=new Panel();
    crd5.add(Pic5);
    card.add(crd5,"5");
    Panel p = new Panel();
    p.setLayout(new GridLayout(1,3));
    first=new Button("Image1");
    first.addActionListener(this);
    p.add(first);
    second=new Button("Image2");
    second.addActionListener(this);
    p.add(second);
    third=new Button("Image3");
    third.addActionListener(this);
    p.add(third);
    fourth=new Button("Image4");
    fourth.addActionListener(this);
    p.add(fourth);
    add( card, BorderLayout.CENTER);               //put card panel in center
    add(p,BorderLayout.SOUTH);                         //add button panel to south border
    } //end constructor
    public void actionPerformed(ActionEvent e)
    Object source=e.getSource();
    if (source == first)
    cardLayout.show(card,"2");
              typeImage=1;
              card.repaint();
              //System.out.println("typeimage in ap "+ typeImage);
    if (source== second)
    cardLayout.show(card,"3");
         typeImage=2;
         card.repaint();
         // System.out.println("typeimage in ap "+ typeImage);
    if (source == third)
              cardLayout.show(card,"4");
              typeImage=3;
              card.repaint();
              //System.out.println("typeimage in ap "+ typeImage);
    if (source == fourth)
              cardLayout.show(card,"5");
              typeImage=5;
              card.repaint();
              //System.out.println("typeimage in ap "+ typeImage);
    }//end action performed
    class Picture extends Canvas
    {  //picture start
    protected void showImage(Graphics g, int x, int y, Image image,
              String loadingMessage, String errorMessage)
              // Get the status of the image
              int flags = checkImage(image, this);
              // If the image aborted or had an error, print the error message
              if ((flags & (ImageObserver.ABORT+ImageObserver.ERROR)) != 0)
              g.drawString(errorMessage, x, y+30);
              return;
              // If the image has been loaded fully, display it
              } else if ((flags & ImageObserver.ALLBITS) != 0) {
              g.drawImage(image, x, y, this);
              // If the image is still loading, display the loading message
              } else {
              g.drawString(loadingMessage, x, y+30);
              return;
         public void paint (Graphics g )
         {      //begin paint
    g.drawRect(0,0,400,400);
    showImage(g,0,0,image8,"image loading","image can't load");
    showImage(g,40,0,image7,"image loading","image can't load");
    switch(typeImage)
              case 1:
                   //System.out.println("typeimage in paint after switch" +typeImage);
                   showImage(g,100,100,image1,"image loading","image can't load");
                   break;
         case 2:
                   //System.out.println("typeimage in paint after switch" +typeImage);
                   g.drawString("We miss you!",100,100);
                   showImage(g,90,90,image2,"image loading","image can't load");
    break;
              case 3:
                        //System.out.println("typeimage in paint after switch" +typeImage);             //begin else if
    g.drawString("Its crying time",150,100);
                        showImage(g,100,150,image3,"image loading","image can't load");
    break;
              case 4:
    //System.out.println("typeimage in paint after switch" +typeImage);
                                       showImage(g,130,75,image6,"image loading","image can't load");
    break;
         case 5:
                        //System.out.println("typeimage in paint after switch" +typeImage);
    g.drawString(" Album cover from Aoxomoxa",150,230);
                             showImage(g,130,75,image5,"image loading", "image can't load");
    break;
    }//end switch
         } //end paint
    }          //end class picture
    } //end class CardDeck1
    when I compile the previous applet(that use to work under previous version) I get the following errors
    D:\data\CardDeck5.java:16: incompatible types
    found : java.awt.Image
    required: Image
    image1=getImage(getDocumentBase(),"chi2.gif");
    ^
    D:\data\CardDeck5.java:25: cannot resolve symbol
    symbol : method prepareImage (Image,CardDeck5)
    location: class CardDeck5
         prepareImage(image1, this);
    ^
    D:\data\CardDeck5.java:154: cannot resolve symbol
    symbol : method checkImage (Image,CardDeck5.Picture)
    location: class CardDeck5.Picture
              int flags = checkImage(image, this);
    ^
    D:\data\CardDeck5.java:157: cannot resolve symbol
    symbol : variable ImageObserver
    location: class CardDeck5.Picture
              if ((flags & (ImageObserver.ABORT+ImageObserver.ERROR)) != 0)
    ^
    D:\data\CardDeck5.java:157: cannot resolve symbol
    symbol : variable ImageObserver
    location: class CardDeck5.Picture
              if ((flags & (ImageObserver.ABORT+ImageObserver.ERROR)) != 0)
    ^

    try to fix the errors your self beware with the datatypes, about the pictures, they are stored in the "server side" and applets run on the "client side" and applets have restricted acces to server resources...

  • SQLException after end of result set

    hi guys.
    im in a lot of bother at the moment.
    i have a GUI with a database in mysql. my gui is a recommender system and so users need to log in etc...
    i know for certain that the gui does connect to the database because when a new user enters there details it does get updated in the database.
    my problem is that when the user tries to gain acces to the system by going to the 'current user' and entering there details nothing happens.
    i am finding it very difficult to find out what the problem is, i have been trying for over a week but no luck and im hoping somebody will know how to help me.
    please could somebody help me here, i have a very short time aswell. monday.
    here is my code below.
    thank-you very much for your help
    its not normal to post the whole class here but im really really stumped.
    the errors that appears in the dos window is SQLException After end of result set.
    *     Function: This class is used for loggin in. It looks for the user name and password           *
    *          the user enters in the database. If there is no match an error message will appear     *
    *          to the user. If there is a match the system logs the user in and dispalys the chose      *
    *          topic page                                   *
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import com.mysql.jdbc.Driver;
    import java.sql.*;
    import java.awt.BorderLayout;
    import java.io.IOException;
    public class CurrentUserFrame extends JPanel implements ActionListener {
         // private is used so object variables cannot be changes by another class.
         private JButton loginButton = null ;
         private JTextField userName = null ;
         private JTextField password = null ;
         private JLabel userLabel = null ;
         private JLabel passwordLabel = null ;
         Boolean loginSuccess ;
         private JPanel cardPanel = null ;
         public CardLayout cardLayout = null ;
         protected static com.mysql.jdbc.Driver mysqlDriver = null;
         String passwordDbase ;
         String usernameDbase ;
              private CardLayout getCardLayout () {
              if (cardLayout == null ) {
              cardLayout = new CardLayout () ;
              return cardLayout ;
         private JPanel getCardPanel () {
         if (cardPanel == null) {
         cardPanel = new JPanel () ;
         return cardPanel ;
         // creates the background colours for the panels by specifying the amounts of red
         // green, blue where 0.5F is the least amount and 1.0F is the most
         Color currentTitleColor = new Color (0.58F, 0.73F, 0.83F) ;
         Color currentMainPanelColor = new Color (0.980F, 0.973F, 0.843F) ;
         public CurrentUserFrame ()
              setLayout (new BorderLayout ()) ;
              JPanel mainCPnl = new JPanel () ;
              mainCPnl.setLayout (new BorderLayout ()) ;
              JPanel mainPanel = new JPanel () ;
              // maindisplaypanel will be set with a borderlayout
              mainPanel.setLayout (new BorderLayout ());
              JPanel descriptionPanel = new JPanel ();
              descriptionPanel.setLayout(new BorderLayout ());
              // creates a textarea for the title and description
              JTextArea description2 = new JTextArea ("\t\tCurrent User Page\n\n" +
              "Please enter your user name and password to login.\n\n" +
              "If you have forgotten your user name or password click on " +
              " 'FORGOT PASSWORD'.") ;
              // stops the text area being edited by the user
              description2.setEditable (false) ;
              // once the text in description reaches the end of the textarea it will start a new line
              description2.setLineWrap (true) ;
              //sets the background colour of the textarea
              description2.setBackground (currentTitleColor) ;
              //sets the type of font with its size for the description textarea
              description2.setFont (new Font ("TimesRoman", Font.BOLD, 16)) ;
              // the descriptionpanel will be placed in the mainpanel at the top.
              mainPanel.add (descriptionPanel, BorderLayout.NORTH) ;
              descriptionPanel.add(description2, BorderLayout. NORTH) ;
              JPanel currentUserPanel = new JPanel () ;
              currentUserPanel.setLayout (new BoxLayout (currentUserPanel, BoxLayout.Y_AXIS)) ;
              // creates a button with an actionlistener so t can carryout a task when it is pressed.
              // the settooltiptext () method displays a message when the user hovers over the button with the curser
              loginButton = new JButton ("Log In") ;
              loginButton.addActionListener(this) ;
              loginButton.setToolTipText ("Logs you into the system") ;
              // creates a text field which is 25 characters in length for the user to enter their name
              userName = new JTextField (25) ;
              // creates a text field which is 15 characters in length for the user to enter their password
              password = new JPasswordField (15) ;
              userLabel = new JLabel ("User Name") ;
              passwordLabel = new JLabel ("Password") ;
              //adds the text fields and the JLabels to the currentuserPanel
              currentUserPanel.add (userLabel) ;
              currentUserPanel.add (userName) ;
              currentUserPanel.add (passwordLabel) ;
              currentUserPanel.add (password) ;
              currentUserPanel.add (loginButton) ;
              JPanel loginPanel = new JPanel () ;
              loginPanel.setLayout (new FlowLayout (FlowLayout.CENTER, 0, 170)) ;
              loginPanel.setBackground (currentMainPanelColor) ;
              loginPanel.add (currentUserPanel, BorderLayout.CENTER) ;
              mainPanel.add (loginPanel, BorderLayout.CENTER) ;
              JPanel chooseTopicCard = new JPanel () ;
              chooseTopicCard.setLayout (new GridLayout (0, 1, 0, 10)) ;
              ChooseTopic frame8 = new ChooseTopic () ;
              frame8.setVisible (true) ;
              chooseTopicCard.add(frame8) ;
              // this will create the panel for the maincontent area and sets the layout
              JPanel cp = getCardPanel();
              cp.setLayout(getCardLayout());
              cp.add("card3",mainPanel) ;
              cp.add("card7", chooseTopicCard) ;
              cardLayout.show (getCardPanel () , "card3") ;
              // this adds the cardlayout to the main panel and then adds the mainpanel screen
              mainCPnl.add(cp) ;
              this.add (mainCPnl) ;
         public void actionPerformed (ActionEvent event) {
              Object source = event.getSource () ;
              if (source == loginButton) {
                   // creates a string to connect to the local host and database
                   // the following 10 lines of code is from the mysql website
                   String url = "jdbc:mysql://:3306/project" ;
                   Connection con = null ;
                   // com.mysql.jdbc.Driver is a folder downloaded from mysql website
                   try {
                        mysqlDriver = (com.mysql.jdbc.Driver) Class.forName ("com.mysql.jdbc.Driver").newInstance () ;
                   } catch ( Exception E) {
                   throw new RuntimeException ("Can not load driver class com.mysql.jdbc.Driver") ;
                   try {
                   // attempts a connection with the computer     
                   // root is used as a default so i can have full access to the database
                   con = DriverManager.getConnection (url,"root","") ;
                   // trys to log in to the database
                   // statement is a mysql class
                   Statement select = con.createStatement ();
                   ResultSet result = select.executeQuery ("select * from user_login") ;                    
                   String userNameText = userName.getText();
                   String passwordText = password.getText();
                   if (userNameText.equals("") || passwordText.equals("")) {
                        JOptionPane okoptionpane = new JOptionPane () ;
                        okoptionpane.showMessageDialog(null, "You have entered your username or password incorrectly, please try again") ;
                        while ((result.next()) && (result != null))
                             //String usernameval ;
                             //String passwordval ;
                             passwordDbase = result.getString("password");
                             usernameDbase = result.getString("user_name");
                             //passwordDbase = "password";
                             //usernameDbase = "user_name";
                             if ((passwordDbase.equals(passwordText)) && (usernameDbase.equals(userNameText))) {
                             cardLayout.show(getCardPanel(), "Card7");                         
                        catch (Exception e) {
                        e.printStackTrace() ;
                        finally {
                        if (con != null ) {               
                             try {con.close () ;  }
                             catch (Exception e) {
                             e.printStackTrace () ;
    LIZ

    ooppps, very sorry, you can guess im new to this forum. sorry again. i thought maybe the whole code was needed.
    i have posted all the output from the dos window.
    java.sql.SQLException: After end of result set
    at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:3628)
    at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1763)
    at com.mysql.jdbc.ResultSet.getString(ResultSet.java:1827)
    " at CurrentUserFrame.actionPerformed(CurrentUserFrame.java:214) "
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
    n Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
    ce)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    i think it is mainly line that is in speach marks. line 214.
    the error that comes up says." after end of result set "
    thank-you
    and sorry once again, im in a bit of a panic,
    Liz

  • Processing ActionListener in panel_class.

    Hi,
    My application has:
    1) JMenuBar
    2) panel with cardlayout having 2 cards (screens)
    on a contentpane.
    The application is referred to as c1.
    It is build with the use of seperate classes.
    c2 = menubuilder
    c3 = detailscreenbuilder
    c4 = listscreenbuilder
    All ActionListeners are created inside these classes.
    So, C1 initializes and 'calls' C2, C3, C4 to build its screen.
    When user selects a menu-item, the corresponding ActionListener is executed.
    But how do I link this with an action in the applicationclass C1?
    Example:
    - User starts application
    ==> CardLayout shows default screen (c4)
    ==> JMenuBar is shown also
    - User selects MenuItem:List.
    ==> an ActionListener, linked to the JMenuItem is triggered
    This ActionListener is coded in the menubuilder (c2)
    I would like to change the card_panel so that the detailscreen (c3) is shown.
    This is done by executing: cardlayout.show("screen3");
    Problem is... none of the objects used in the applicationclass are known to the menubuilder so how can I execute this?
    Now I can

    sorry, maybe the description is a bit difficult to understand without any code.
    So, herewith you'll find the testcode (four classes)
    Put them in a package called 'testscreenbuilder' and it should work.
    The application starts with a menu and welcomescreen shown.
    When selecting 'File - List', the 'ListPanel' should be displayed...
    * Application
    package testscreenbuilder;
    import javax.swing.UIManager;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class myApplication
         extends JFrame {
         private Container c;
         private CardLayout cardlayout = new CardLayout();
         private JPanel pCards = new JPanel();
         boolean packFrame = false;
         private JPanel pNorth, pCenter, pSouth;
         private JLabel lNorth, lSouth, lCenter, lEast, lWest;
         // Variables
         private String titleScreen1, titleScreen2;
         private String gui = "J";
         private ActionListener al;
         //Construct the application
         public myApplication() {
              // Create View
              setTitle("myApplications");
              setSize(800, 550);
              c = getContentPane();
              c.setLayout(new BorderLayout());
              // add HomePanel
              pCards.setLayout(cardlayout);
              WelcomePanel cWelcome = new WelcomePanel(this, "welcome");
              pCards.add("welcome", cWelcome);
              ListPanel cList = new ListPanel();
              pCards.add("list", cList);
              cardlayout.show(pCards, "welcome");
              c.add(pCards, BorderLayout.CENTER);
              // add Menu
              Menu mMenu = new Menu();
              setJMenuBar(mMenu.getMenu());
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
         // MenuFrame1 frame = new MenuFrame1();
         //Validate frames that have preset sizes
         //Pack frames that have useful preferred size info, e.g. from their layout
         if (packFrame) {
              this.pack();
         else {
              this.validate();
         //Center the window
         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
         Dimension frameSize = this.getSize();
         if (frameSize.height > screenSize.height) {
              frameSize.height = screenSize.height;
         if (frameSize.width > screenSize.width) {
              frameSize.width = screenSize.width;
         this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
         //Main method
         public static void main(String[] args) {
         try {
              UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
         catch(Exception e) {
              e.printStackTrace();
         new myApplication();
         class MenuHandlerList implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   cardlayout.show(pCards, "list");
    * MenuBar
    package testscreenbuilder;
    import java.awt.event.*;
    import javax.swing.*;
    * @author pgo
    public class Menu
         extends JFrame {
         private JMenuBar mMyMenu;
         // Menu
         private JMenu[] arMenu;
         private String arMenuText[] = {     
                   "File", "Help"};
         // MenuItems
         private JMenuItem[] arMenuItem0;
         private String arMenuItem0Text[] = {
                   "New", "List", "Exit"};
              private JMenuItem[] arMenuItem1;
         private String arMenuItem1Text[] = {
              "Help", "About..."};
    public Menu() {
    public JMenuBar getMenu() {
         if (arMenuText!=null)
              arMenu = new JMenu[arMenuText.length];
              // Menu 0 (File)
              if (arMenuItem0Text!=null)
                   arMenu[0] = new JMenu(arMenuText[0]);
                   arMenuItem0 = new JMenuItem[arMenuItem0Text.length];
                   for (int si = 0;si<arMenuItem0Text.length;si++)
                        arMenuItem0[si] = new JMenuItem(arMenuItem0Text[si]);
                        switch(si)
                             case 0:     //New
                                  arMenuItem0[si].addActionListener(new MenuHandler());
                                  break;
                             case 1: //Properties
                                  arMenuItem0[si].addActionListener(new MenuHandlerList());
                                  break;
                             case 2: //Exit
                                  arMenuItem0[si].addActionListener(new MenuHandlerExit());
                                  break;
                             default:
                                  arMenuItem0[si].addActionListener(new MenuHandler());
                                  break;
                        arMenu[0].add(arMenuItem0[si]);
              // Menu 1 (Help)
              if (arMenuItem1Text!=null)
                   arMenu[1] = new JMenu(arMenuText[1]);
                   arMenuItem1 = new JMenuItem[arMenuItem1Text.length];
                   for (int si = 0;si<arMenuItem1Text.length;si++)
                        arMenuItem1[si] = new JMenuItem(arMenuItem1Text[si]);
                        switch(si)
                             case 0: //Help
                                  arMenuItem1[si].addActionListener(new MenuHandler());
                                  break;
                             case 1: //About
                                  arMenuItem1[si].addActionListener(new MenuHandlerAbout());
                                  break;
                             default:
                                  arMenuItem1[si].addActionListener(new MenuHandler());
                                  break;
                        arMenu[1].add(arMenuItem1[si]);
         // Set MenuBar
         mMyMenu = new JMenuBar();
         if (arMenu != null)
              for (int i = 0;i<arMenu.length;i++){
                   mMyMenu.add(arMenu);
         setJMenuBar(mMyMenu);
         return mMyMenu;
    class MenuHandler implements ActionListener{
         public void actionPerformed(ActionEvent e){
         JMenuItem keuze = (JMenuItem)e.getSource();
         String tekst = keuze.getText();
         JOptionPane.showMessageDialog(null, "Function: '"+tekst+"' is under construction");
    class MenuHandlerAbout implements ActionListener{
    public void actionPerformed(ActionEvent e){
         JOptionPane.showMessageDialog(null, "My Application.\n\nVersion 1.0\nRelease Date June 2005");
    class MenuHandlerExit implements ActionListener{
         public void actionPerformed(ActionEvent e){
         int response = JOptionPane.showConfirmDialog(null, "Are you sure that you wish to exit this application?", "Confirm Exit", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
         if (response==0){
         System.exit(0);
    class MenuHandlerList implements ActionListener{
         public void actionPerformed(ActionEvent e){
    * Welcome Panel
    package testscreenbuilder;
    import java.awt.*;
    import javax.swing.*;
    * @author pgo
    public class WelcomePanel
         extends JPanel {
         private JPanel pNorth, pCenter, pSouth, pEast, pWest;
         private JLabel lNorth, lSouth, lCenter, lEast, lWest;
         WelcomePanel(){
         WelcomePanel(myApplication application, String title)
         setLayout(new BorderLayout());
         pNorth = new JPanel();
         lNorth = new JLabel();
         lNorth.setText("Welcome Title");
         pNorth.add(lNorth);
         pEast = new JPanel();
         lEast = new JLabel("Welcome (East)");
         pEast.add(lEast);
         pCenter = new JPanel();
         lCenter = new JLabel("Welcome (Center)");
         pCenter.add(lCenter);
         pWest = new JPanel();
         lWest= new JLabel("Welcome (West)");
         pWest.add(lWest);
         pSouth = new JPanel();
         lSouth = new JLabel("Welcome South");
         pSouth.add(lSouth);
         add(pNorth, BorderLayout.NORTH);
         add(pEast, BorderLayout.EAST);
         add(pCenter, BorderLayout.CENTER);
         add(pWest, BorderLayout.WEST);
         add(pSouth, BorderLayout.SOUTH);
    * ListPanel
    package testscreenbuilder;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ListPanel
         extends JPanel {
         private String listTitle = new String("");
         private JLabel lblTitle;
         private JButton bListOK, bListNOK;
         private JPanel dpNorth, dpCenter, dpSouth;
         private JLabel dlNorth, dlSouth, dlCenter, dlEast, dlWest;
    public ListPanel() {
         setLayout(new BorderLayout());
         dpNorth = new JPanel();
         dpNorth.setLayout(new FlowLayout());
         dpCenter = new JPanel();
         dpCenter.setLayout(new FlowLayout());
         dpSouth = new JPanel();
         dpSouth.setLayout(new FlowLayout());
         lblTitle = new JLabel("Properties");
         bListOK = new JButton("OK");
         bListOK.addActionListener(new ActionListenerOK());
         bListNOK = new JButton("Cancel");
         bListNOK.addActionListener(new ActionListenerNOK());
         dpNorth.add(lblTitle);
         dpSouth.add(bListOK);
         dpSouth.add(bListNOK);
         add(dpNorth, BorderLayout.NORTH);
         add(dpCenter, BorderLayout.CENTER);
         add(dpSouth, BorderLayout.SOUTH);
    class ActionListenerOK implements ActionListener{
         public void actionPerformed(ActionEvent e){
    class ActionListenerNOK implements ActionListener{
         public void actionPerformed(ActionEvent e){

  • Is iphone 6 plus going to ship october 10th

    Is the iPhone 6 plus really going to ship out October 14th

    Yea...I stayed up going back and forth between Apple App, Verizon site, and Apple site.. I finally gave up and called.. I was pretty po'd by this point but- the guy I spoke with was pretty pleasant (actually calmed me down)... but- I ordered iPhone 6 Plus Silver 64GB.. The mall closest to me was showing they had them available in the Apple store, but just couldn't order it.. So- I paid for the "expedited shipping" for $19.99 which meant "id get it by Saturday by noon" I repeated everything:
    ME: "So I will get this then on SATURDAY then if I pay the $19.99?"
    VZW REP: "Yes, by noon Saturday"
    ME: "Oh by noon?"
    VZW: "Yes"
    I continued with my order, he gave my confirmation number, ran my card...STILL have not gotten confirmation email, the VZW preorder status says 10/7..
    I called back and spoke with another gentleman bc now Apple site works and shows delayed shipment and not available in stores.. I told the new rep that I still have not received my confirmation email and I wanted to be certain my order was still in place..
    VZW Rep: "yep. you are all set.. I see an estimated ship date of 10/7..any other questions?"
    ME: "Yea..why was I told before I would get this on Saturday the 15th BY NOON? why would I pay $20 to expedite almost a month?!"
    VZW Rep: "umm- well sir, I do see your order is here but- you still may get it sooner..most won't get them till 10/14...So 10/7 is expedited.."
    I realized I was getting no where, so I guess I have no choice but to just wait and see but- I am a litttttttle aggravated right now.. Hope you all have a better experience than I have..

  • GridBagLayout with Panels

    In a nutshell I have five panels. The comboPanel contains a label and comboBox; objectPanel has a label and text field; filePanel and directPanel have a label, text field and button; buttonPanel has two buttons.
    When the program is first run only the comboPanel is visible. If "Display object and filePanel" is selected from the comboBox then the objectPanel and filePanel are visible, else directPanel is visible. buttonPanel is visible no matter what is selected.
    The problem is I am trying to add them to the GridBayLayout and have them display below one another which is why I am using gbc.gridwidth = GridBagConstraints.REMAINDER for each, however they are all showing up on the same line.
    Thanks in advance
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SMG3AuditInterface extends JFrame
        JComboBox comboBox;
        JLabel lblComponent, lblObjectName, lblFileName, lblDirectName;
        JTextField tfObjectName, tfFileName, tfDirectName;
        JButton btnSubmit, btnCancel, btnFileBrowse, btnDirectBrowse;
        JPanel comboPanel, objectPanel, filePanel, directPanel, buttonPanel;
        GridBagLayout gb;
        GridBagConstraints gbc;
        public SMG3AuditInterface()
        gb = new GridBagLayout();
        gbc = new GridBagConstraints();
        Container cp = getContentPane();
        cp.setLayout(gb);
        String components[] = {"Display directPanel",
            "Display object and filePanel"};
        comboBox = new JComboBox(components);
        comboBox.setSelectedIndex(-1);
        lblComponent = new JLabel("Component Type: ");
        comboPanel = new JPanel();
        comboPanel.add(lblComponent);
        comboPanel.add(comboBox);
        cp.add(comboPanel);
        lblObjectName = new JLabel("Object name: ");
        tfObjectName = new JTextField(20);
        objectPanel = new JPanel();
        objectPanel.add(lblObjectName);
        objectPanel.add(tfObjectName);
        cp.add(objectPanel);
        objectPanel.setVisible(false);
        lblFileName = new JLabel("XML Filename: ");
        tfFileName = new JTextField(20);
        btnFileBrowse = new JButton("Browse");
        filePanel = new JPanel();
        filePanel.add(lblFileName);
        filePanel.add(tfFileName);
        filePanel.add(btnFileBrowse);
        cp.add(filePanel);
        filePanel.setVisible(false);
        lblDirectName = new JLabel("XML Directory name: ");
        tfDirectName = new JTextField(20);
        btnDirectBrowse = new JButton("Browse");
        directPanel = new JPanel();
        directPanel.add(lblDirectName);
        directPanel.add(tfDirectName);
        directPanel.add(btnDirectBrowse);
        cp.add(directPanel);
        directPanel.setVisible(false);
        btnSubmit = new JButton("Submit");
        btnCancel = new JButton("Cancel");
        buttonPanel = new JPanel();
        buttonPanel.add(btnSubmit);
        buttonPanel.add(btnCancel);
        cp.add(buttonPanel);
        buttonPanel.setVisible(false);
        gbc.gridx = GridBagConstraints.RELATIVE;
        gbc.gridy = GridBagConstraints.RELATIVE;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.ipadx = 0;
        gbc.ipady = 0;
        gbc.gridwidth = 3;
        gbc.gridheight = 1;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gb.setConstraints(comboPanel, gbc);
        add(comboPanel);
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = 1;
        gb.setConstraints(objectPanel, gbc);
        add(objectPanel);
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = 2;
        gb.setConstraints(filePanel, gbc);
        add(filePanel);
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridheight = 2;
        gb.setConstraints(directPanel, gbc);
        add(directPanel);
        gbc.gridwidth = 2;
        gbc.gridheight = 1;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gb.setConstraints(buttonPanel, gbc);
        add(buttonPanel);
        comboBox.addItemListener(new ItemListener()
           public void itemStateChanged(ItemEvent e)
              JComboBox cb = (JComboBox)e.getSource();
              String itemName = (String)cb.getSelectedItem();
              buttonPanel.setVisible(true);
              if (itemName == "Display object and filePanel")
                 objectPanel.setVisible(true);
                 filePanel.setVisible(true);
                 directPanel.setVisible(false);
              else
                 objectPanel.setVisible(false);
                 filePanel.setVisible(false);
                 directPanel.setVisible(true);
        public static void main(String[] args)
        SMG3AuditInterface ai = new SMG3AuditInterface();
        ai.setDefaultCloseOperation(ai.EXIT_ON_CLOSE);
        ai.setLocation(400, 300);
        ai.setPreferredSize(new Dimension(400,300));
        ai.pack();
        ai.show();
    }

    Here's an example:
    import java.awt.BorderLayout;
    import java.awt.CardLayout;
    import java.awt.FlowLayout;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class SMG3Petes extends JPanel
        private static final String DIRECT_PANEL = "Display directPanel";
        private static final String OBJECT_FILE_PANEL = "Display object and filePanel";
        private static final String components[] =
            DIRECT_PANEL, OBJECT_FILE_PANEL
        private static final String SUBMIT = "Submit";
        private static final String CANCEL = "Cancel";
        private static final String EMPTY_PANEL = "Empty Panel";
        private JPanel centerPanel;
        private CardLayout cardlayout = new CardLayout();
        private JComboBox comboBox;
        private JButton submitBtn = new JButton(SUBMIT);
        private JButton cancelBtn = new JButton(CANCEL);
        private JTextField tfObjectName = new JTextField(20);
        private JTextField tfFileName = new JTextField(20);
        private JTextField tfDirectName = new JTextField(20);
        public SMG3Petes()
            int eb = 15;
            setBorder(BorderFactory.createEmptyBorder(eb, eb, eb, eb));
            setLayout(new BorderLayout());
            add(createBigCenterPanel(), BorderLayout.CENTER);
            add(createPageEndPanel(), BorderLayout.PAGE_END);
        private JPanel createBigCenterPanel()
            JPanel p = new JPanel();
            p.setLayout(cardlayout);
            p.add(new JPanel(), EMPTY_PANEL);
            p.add(createObjectFilePanel(), OBJECT_FILE_PANEL);
            p.add(createDirectPanel(), DIRECT_PANEL);
            centerPanel = p;
            return p;
        private JPanel createObjectFilePanel()
            JPanel p = new JPanel();
            p.setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = 0;
            gbc.gridheight = 1;
            gbc.gridwidth = 1;
            gbc.weightx = 1;
            gbc.weighty = 1;
            gbc.insets = new Insets(5, 5, 5, 5);
            p.add(new JLabel("Object name: "), gbc);
            gbc.gridx = 1;
            gbc.gridwidth = 2;
            gbc.weightx = 2;
            p.add(tfObjectName, gbc);
            gbc.gridx = 3;
            gbc.gridwidth = 1;
            gbc.weightx = 1;
            p.add(new JLabel("   "));
            gbc.gridx = 0;
            gbc.gridy = 1;
            gbc.gridwidth = 1;
            gbc.weightx = 1;
            p.add(new JLabel("XML Filename: "), gbc);
            gbc.gridx = 1;
            gbc.gridwidth = 2;
            gbc.weightx = 2;
            p.add(tfFileName, gbc);
            gbc.gridx = 3;
            gbc.gridwidth = 1;
            gbc.weightx = 1;
            JButton browseBtn = new JButton("Browse");
            p.add(browseBtn, gbc);
            return p;
        private JPanel createDirectPanel()
            JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 0));
            JLabel lblDirectName = new JLabel("XML Directory name: ");
            tfDirectName = new JTextField(20);
            JButton btnDirectBrowse = new JButton("Browse");
            p.add(lblDirectName);
            p.add(tfDirectName);
            p.add(btnDirectBrowse);
            return p;
        private JPanel createPageEndPanel()
            JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 0));
            p.add(createComboPanel());
            p.add(createButtonPanel());
            return p;
        private JPanel createComboPanel()
            comboBox = new JComboBox(components);
            comboBox.setSelectedIndex(-1);
            comboBox.addItemListener(new ComboItemListener());
            JPanel p = new JPanel();
            p.add(new JLabel("Component Type: "));
            p.add(comboBox);
            return p;
        private class ComboItemListener implements ItemListener
            public void itemStateChanged(ItemEvent ie)
                submitBtn.setEnabled(true);
                cancelBtn.setEnabled(true);
                String itemName = (String) comboBox.getSelectedItem();
                if (itemName.equals(DIRECT_PANEL))
                    cardlayout.show(centerPanel, DIRECT_PANEL);
                else if (itemName.equals(OBJECT_FILE_PANEL))
                    cardlayout.show(centerPanel, OBJECT_FILE_PANEL);
        private JPanel createButtonPanel()
            JPanel p = new JPanel(new GridLayout(1, 0, 15, 0));
            submitBtn.setEnabled(false);
            cancelBtn.setEnabled(false);
            p.add(submitBtn);
            p.add(cancelBtn);
            return p;
        private static void createAndShowGUI()
            JFrame frame = new JFrame("SMG3 Petes1234 Application");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(new SMG3Petes());
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

  • Printing forums in exact format

    I have a seven page card layout Forms (combination of check box, tables, text fields and text area). I need to print the content of each page in the exact form draw check box, text area, text field and tables all with its content. What would be the exact process? Should I draw each individual component or is there a java class from SUN or 3rd party vendor to draw everything automatically? Cuz drawing each individual component will be painful. Would it be best if I first save them in a file and then send the file to the printer? But even that way I have to draw the components (checkbox, text field, area and tables) individually in the file then their content. Right?
    There must be an easy way... can't be that complicated...
    Would appreciate your help a lot...

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.print.*;
    import java.util.Random;
    public class Test extends JFrame {
        CardLayout cardLayout = new CardLayout();
        JPanel cardPanel = new JPanel(cardLayout);
        String currentPanel = "0";
        public Test() {
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container content = getContentPane();
         content.add(cardPanel, BorderLayout.CENTER);
         JPanel buttonPanel = new JPanel();
         content.add(buttonPanel, BorderLayout.SOUTH);
         for (int i=0; i<8; i++) {
             JPanel jp = new PrintablePanel("Panel "+i);
             cardPanel.add(jp, ""+i);
             JButton jb = new JButton(""+i);
             jb.setBorder(BorderFactory.createRaisedBevelBorder());
             buttonPanel.add(jb);
             jb.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                  currentPanel = ((JButton)ae.getSource()).getText();
                  cardLayout.show(cardPanel, (currentPanel));
         JButton jb = new JButton("Print All");
         jb.setBorder(BorderFactory.createRaisedBevelBorder());
         buttonPanel.add(jb);
         jb.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent ae) {
              PrinterJob printJob = PrinterJob.getPrinterJob();
              if (printJob.printDialog()) {
                  Component[] c = cardPanel.getComponents();
                  for (int i=0; i<c.length; i++) {
                   printJob.setPrintable((PrintablePanel)c);
                   cardLayout.show(cardPanel, ""+i);
                   try { printJob.print(); }
                   catch (Exception ex) { ex.printStackTrace(); }
              cardLayout.show(cardPanel, currentPanel);
         setSize(300,300);
         show();
    public static void main(String[] args) { new Test(); }
    class PrintablePanel extends JPanel implements Printable {
    RepaintManager currentManager = RepaintManager.currentManager(this);
    private static Random r = new Random();
    public PrintablePanel(String Name) {
         JLabel jl = new JLabel(Name);
         jl.setSize(100,20);
         add(jl);
         Component c=null;
         for (int i=0; i<5; i++) {
         switch (r.nextInt(4)) {
              case 0:
              c = new JTextField("Text "+r.nextInt(100)); break;
              case 1:
              c = new JLabel("Label "+r.nextInt(100)); break;
              case 2:
              c = new JTextArea("TextArea "+r.nextInt(100)+"\nand more...");
              break;
              case 3:
              c = new JTree(); break;
         add(c);
    public int print(Graphics g, PageFormat pf, int pi)
                   throws PrinterException {
         if (pi>0) return Printable.NO_SUCH_PAGE;
         Graphics2D g2 = (Graphics2D)g;
         g2.translate(pf.getImageableX(), pf.getImageableY());
         currentManager.setDoubleBufferingEnabled(false);
         paint(g2);
         currentManager.setDoubleBufferingEnabled(true);
         return Printable.PAGE_EXISTS;

Maybe you are looking for

  • Color newbie tmeline question...

    When I send an hour long clip to Color the timeline shows a very small portion of the timeline, about two or three minutes. I don't seem to be able to zip around the timeline like I can in FCP. The interface seems to be "rigid" - kind of like the way

  • Manually change ip address on photosmart D110a

    How do i change ip adress on HP Photosmart D110a, on operating system mac os lion. it apears an auto ip 169.254.140.65 an it does not work

  • Satellite M100-233: shuts down just after the XP logo

    Hi, I have a Satellite M100-233 with XP Home Edition SP3 (in Portuguese) When connected to the mains and the battery is not totally charged, sometimes the amber light does not light up. Checking the voltmeter application when this happens tells me th

  • Error 1607 Message - Please Help!!

    Hi ive tried to install iTunes from the cd and downloading from Apple.com but each time i try to do this it comes up with the following error message: '1607: Unable to install InstallShield Scripting Runtime' I have seen that a few people have had th

  • MacBook Air 13' network

    My Macbook Air 13' used to detect my home wifi .. but now i have to wait like 10 minute to find it or sometimes i have to restart my macbook to find it .. What should i do ?