Question on code in swing?

Hey guys, I'm really new to Java. I was working on a bit of code to simply put up an oval and a rectangle in swing/awt. I was wondering if you guys could explain the concept of getContentPane().add(new MyComp()); I really don't get it. I will give you guys the code, and in it I put comments where i dont get stuff. Also, another question is, is the Paint Method called implicitly at run time? How is paint called? Does AWT simply call it? Thanks guys, heres the code;
import javax.swing.*;
import java.awt.*;
class Rect {
     public static void main(String[] args) {
          Rect draw = new Rect(); /*This simply instantiates the object, so that the constructor comes in, right? *\
     public Rect() {  //here we set up the constructor to make our window
          JFrame frame = new JFrame("Drawing with Alph!");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add(new MyComp()); //What does get Contentpane() do? I know it's a method, but what's its use?
          frame.setSize(500, 500);
          frame.setVisible(true);
     public class MyComp extends JComponent { /*This is what I don't understand; the JComponent part. I understand the code block within it, however. *\ What does JComponent do?
          public void paint(Graphics mw) { /*Why is the Graphics class within the parameter here? Is this an object? Super confused on this *\
               int length = 200;
               int width = 130;
               mw.setColor(Color.red);
               mw.drawRect(20, 30, length, width);
               mw.fillRect(20, 30, length, width);
               mw.setColor(Color.red);
               mw.drawOval(250, 100, length, width);
               mw.setColor(Color.cyan);
               mw.fillOval(249, 99, length, width);
If you guys can help me out with those questions, I will be one of the happiest people ever. Thank you so much, and have a great day!

another question is, is the Paint Method called implicitly at run time? How is paint called? Does AWT simply call it?I've already answered that question in a previous thread of yours. If you didn't understand, you should have said so in that thread, rather than just repeating yourself ad nauseam.
You are just wasting your own time and that of other people by this piecemeal approach to learning, forum question by forum question, and I've already told you so in another prior thread. I cannot imagine anything more inefficient. I also recommended you to get a book, and to read the Java Language Tutorial. When you've done that, you should read the Java Swing Tutorial.
Locking this thread.

Similar Messages

  • Need a java code using swing that can do master configuration

    I need a java code using swing that can do master configuration.For example, in the 1st screen it will show all configuration checke boxes . According to those selected check box, it will show the needed panels sequentially and finnaly it will update many xml files.

    TapasB wrote:
    I need a java code .......and I wish you much luck in creating it. Please come back if you have a specific question on a specific part of your code that is not working quite right.

  • Extended Ascii Code in Swing

    Hi master,
    I have found some viewing extended ascii code in Swing. The palteform I used is Windows Me.
    It is not viewing properly for some of chars with ascii code more than 127 to 255.
    Any idea would be appreciate.
    Thanks in advance!

    Hi,
    This character is special one, so you can't print it out. In SAP all special charcter which can't be printed are replaced with placeholder #.  They are intended to do theri special purpose in flat file, once you open it.
    Do the following:
    - use fm HR_KR_XSTRING_TO_STRING to convert xstring with value  '1F' (30 decimal value) to string
    - write this string to certain place in internal string table (where you want later use it in the file)
    - download this table as to file
    - special character will do its purpose in text file
    This is the same functionality as you would be placing Line Feed (0x0A - 10 dec). It would be shown as # but once you open downlaoded file you don't see hash # anymore, but you see that new line in that place.
    Hope this is clear
    Regards
    Marcin

  • Is that where you are offering to help retrieve the encryption-answer questions and cod have been an accident and do not forget the answers

    HHlo Is that where you are offering to help retrieve the encryption-answer questions and cod have been an accident and do not forget the answers

    How to reset your Apple ID security questions
    Go to appleid.apple.com and click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email.
    Go to the Password & Security section on the left side. Then underneath the security questions click on the link that says 'Forgot your answers? Send reset security info email to [email]'.  This will generate an automated e-mail that will allow you to reset your security questions. 
    If that doesn't work, or  there is no rescue email link available, then you will need assistance from Apple Account Security. Follow this procedure:
    click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later. 
    Next, go to getsupport.apple.com. If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services'.
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.  Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.
    The above information quoted with gratitude from TJBUSMC1973, another user in these forums.
    Forum Tip: Since you're new here, you've probably not discovered the Search feature available on every Communities page, but next time, it might save you time (and everyone else from having to answer the same question multiple times) if you search a couple of ways for a topic, both in the relevant forums and in the Apple Knowledge Base before you post a question.
    Regards.

  • A question on JInternalFrame of Swing. Let see the code

    Hello everybody,
    I am setting up a Frame that contains 2 JInternalFrames in its desktopPane. The first JInternalFrame is to show the map. The second one have some check box. What I wanna do is, when I check the CheckBox in the second JInternalFrame, after getting the result from Database, it show the result on Map. The result will be some red ellipses on the first JInternalFrame.
    The code work well with Database. But I really need your help to do with the event on InternalFrame
    Thanks in advance !
    Quin,
    Here is the code of the main Frame:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.beans.*;
    public class MapLocator
         public static void main(String [] args)
              JFrame frame = new DesktopFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
    Create a desktop frames that contains internal frame
    class DesktopFrame extends JFrame implements ActionListener
         public DesktopFrame()
              super("Map Locator v.1.0.0");
              this.setSize(new Dimension(WIDTH,HEIGHT));
              desktop = new JDesktopPane();
              this.setContentPane(desktop);
              this.createInternalFrame(
                   new mapPanel(),"Ban do Thanh pho Ho Chi Minh",0,0,480,515);
              this.createInternalFrame(
                   new commandPanel(),"Chu thich va tim kiem",480,0,320,515);
    Create an internal frame on the desktop.
    @param c the component to display in the internal frame
    @param t the title ofthe internal frame.
         public void createInternalFrame(JPanel c, String t,int ifx, int ify, int ifwidth, int ifheight)
                 final JInternalFrame iframe = new JInternalFrame(t,
                 true//resizeable
                 ,true//closable
                 ,true//maximizable
                 ,true//iconifiable
                 iframe.getContentPane().add(c);
                 desktop.add(iframe);
                 iframe.setFrameIcon(new ImageIcon("new.gif"));
                 //add listener to confirm frame closing
                 iframe.addVetoableChangeListener(new VetoableChangeListener()
                      public void vetoableChange(PropertyChangeEvent event)
                           throws PropertyVetoException
                           String name = event.getPropertyName();
                           Object value = event.getNewValue();
                           //we only want to check attempts to close a frame
                           if(name.equals("closed") && value.equals(Boolean.TRUE))
                                //ask user if it is ok to close
                                int result =
                      JOptionPane.showInternalConfirmDialog(iframe,"OK to close");
                                //if the user doesn't agree, veto the close
                                if(result != JOptionPane.YES_OPTION)
                      throw new PropertyVetoException("User cancel the close",event);
                 iframe.setVisible(true);
                 iframe.setLocation(ifx,ify);
                 iframe.setSize(new Dimension (ifwidth, ifheight));
         private static final int WIDTH = 800;
         private static final int HEIGHT = 600;
         private JDesktopPane desktop;
         private int nextFrameX;
           private int nextFrameY;
            private int frameDistance;
         private JMenuBar menuBar;
         private JMenu fileMenu, viewMenu, searchMenu, windowMenu, helpMenu;
         private JRadioButtonMenuItem javalaf, liquidlaf, motiflaf, windowlaf, threedlaf;
    }Below is the code of first JInternalFrame
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.util.Random;
    import java.util.*;
    import com.sun.image.codec.jpeg.*;
    Create a canvas that show a map
    public class mapPanel extends JPanel
         implements MouseMotionListener, MouseListener
         public mapPanel()
              addMouseMotionListener(this);
              addMouseListener(this);
    Unbarrier the comment below to see how the map model work
    //Unbarrier this to see -->
             try
                InputStream in = getClass().getResourceAsStream(nameOfMap);
                JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);
                mImage = decoder.decodeAsBufferedImage();
                in.close();//Close dong nhap
              catch(ImageFormatException ie)
              { System.out.println ("Error on formating image");}
              catch(IOException ioe)
              { System.out.println ("Error on input/ouput image");}
              catch(Exception e){}
    Connect to database
              connDB();
              String addQuery = "";
              try
              Get the relation amongs points
                   int idStart = 0;
                   int idEnd = 0;
                   addQuery ="SELECT IDStart, IDEnd FROM 2Diem";
                   rs = stmt.executeQuery(addQuery);
                   int incre = 0;
                   while(rs.next())
                        idStart = rs.getInt(1);
                        Rel.add(incre, new Integer(idStart));
                        incre ++;
                        idEnd = rs.getInt(2);
                        Rel.add(incre, new Integer(idEnd));
                        incre ++;
         Load the Coordination of the points to hash table
                   int idPoint = 0;
                   int XP = 0;
                   int YP = 0;
                   addQuery ="SELECT IDDiem, CoorX, CoorY FROM Diem";
                   rs = stmt.executeQuery(addQuery);     
                   while(rs.next())
                        idPoint = rs.getInt(1);
                        XP = rs.getInt(2);
                        YP = rs.getInt(3);
                        hashX.put(new Integer(idPoint), new Integer(XP));
                        hashY.put(new Integer(idPoint), new Integer(YP));
         Create Points to draw the Line
                   line = new Line2D[(Rel.size())/2];
                   for(int i = 0, k = 0; i < Rel.size();i++, k = k+2)
                        X1 = Integer.parseInt(""+hashX.get(Rel.elementAt(i)));
                        Y1 = Integer.parseInt(""+hashY.get(Rel.elementAt(i)));
                        i++;
                        X2 = Integer.parseInt(""+hashX.get(Rel.elementAt(i)));
                        Y2 = Integer.parseInt(""+hashY.get(Rel.elementAt(i)));
                        line[k/2] = new Line2D.Double(X1,Y1,X2,Y2);
              catch(SQLException sqle){}
         private Hashtable hashX = new Hashtable();
         private Hashtable hashY = new Hashtable();
         private Vector Rel = new Vector(100,10);
         private Vector vecBackX = new Vector(10,2);
         private Vector vecBackY = new Vector(10,2);
         private int X1 = 0, X2 = 0, Y1 = 0, Y2 = 0;
         Draw the image to show
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              Graphics2D g2 = (Graphics2D) g;
              g2.setRenderingHint(
                   RenderingHints.KEY_ANTIALIASING,
                   RenderingHints.VALUE_ANTIALIAS_ON);
        //     g2.drawImage(mImage,0,0,null);
        Paint the background with light Gray
              g2.setPaint(Color.lightGray);
              g2.fill(new Rectangle2D.Double(0,0,480,480));          
             fillBack(g2);
        Draw the street with its border is white, its background is orange
             g2.setPaint(Color.white);
              g2.setStroke(new BasicStroke(14,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              for(int k = 0; k < Rel.size()/2; k++)
                   g2.draw(line[k]);
              g2.setPaint(Color.orange);
              g2.setStroke(new BasicStroke(10,BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              for(int k = 0; k < Rel.size()/2; k++)
                   g2.draw(line[k]);
         Draw the grid on map
              g2.setPaint(Color.white);
              g2.setStroke(new BasicStroke(1));
              drawGrid(g2);
              if(point != null)
                   g2.setPaint(Color.red);
                   g2.fillOval(point.x - 3, point.y - 3, 7, 7);
    Draw the Background with tree and water
    @param g2 the Graphics2D that used to draw shapes
         private void fillBack(Graphics2D g2)
              Draw the background for map
              try
                   int BackX = 0;
                   int BackY = 0;
                   int incre = 0;
                   backGround = new GeneralPath[3];
                   for(int idBack = 1; idBack <= 3; idBack++)
    Since we use the vector for each background(tree / water), we have to
    refresh the vector before it can add new path inside
                        vecBackX.clear();
                        vecBackY.clear();
                        String addQuery = "SELECT CoorX, CoorY FROM BackCoor WHERE "
                        + " IDBack =" + idBack;
                        rs = stmt.executeQuery(addQuery);
                        while(rs.next())
                             BackX = rs.getInt(1);
                             BackY = rs.getInt(2);
    This will take the point into vector
                             vecBackX.add(incre,new Integer(BackX));
                             vecBackY.add(incre,new Integer(BackY));
                             incre++;
    Design the shapes of path
                             backGround[(idBack - 1)] =
                                  new GeneralPath(GeneralPath.WIND_EVEN_ODD);
                             backGround[(idBack - 1)].moveTo(
                                  Integer.parseInt(""+vecBackX.elementAt(0)),
                                  Integer.parseInt(""+vecBackY.elementAt(0)));
                             for(int i = 1; i < vecBackX.size(); i++)
                                  backGround[(idBack - 1)].lineTo(
                                       Integer.parseInt(""+vecBackX.elementAt(i)),
                                       Integer.parseInt(""+vecBackY.elementAt(i)));
                             backGround[(idBack - 1)].lineTo(
                                       Integer.parseInt(""+vecBackX.elementAt(0)),
                                       Integer.parseInt(""+vecBackY.elementAt(0)));
                             backGround[(idBack - 1)].closePath();
    Here we have 3 Path that represented to tree and water
    The first and second one is tree.
    The last one is water.
    Draw the path now
                             if(idBack == 3)
                                  g2.setPaint(Color.cyan);
                                  g2.fill(backGround[(idBack - 1)]);
                             else
                                  g2.setPaint(Color.green);
                                  g2.fill(backGround[(idBack - 1)]);
                             incre = 0;
              catch(SQLException sqle)
                   System.out.println ("Khong ve duoc back ground");
    Create the grid on map
    @param g2 the Graphics2D that used to draw shapes
         private void drawGrid(Graphics2D g2)
              try
                 String Query =
                 "SELECT * FROM Grid";
                 rs = stmt.executeQuery(Query);
                 GridX = new Vector(100,2);
                 GridY = new Vector(100,2);
                 GridW = new Vector(100,2);
                 GridH = new Vector(100,2);
                 int incr = 0;
                 while(rs.next())
                      gridX = rs.getInt(2);
                      gridY = rs.getInt(3);
                      gridW = rs.getInt(4);
                      gridH = rs.getInt(5);
                      GridX.add(incr, new Integer(gridX));
                      GridY.add(incr, new Integer(gridY));
                      GridW.add(incr, new Integer(gridW));
                      GridH.add(incr, new Integer(gridH));
                      incr ++;
                 rec = new Rectangle2D.Double[GridX.size()];
                 for(int i = 0; i < GridX.size(); i++)
                      gridX = Integer.parseInt(""+GridX.elementAt(i));
                      gridY = Integer.parseInt(""+GridY.elementAt(i));
                      gridW = Integer.parseInt(""+GridW.elementAt(i));
                      gridH = Integer.parseInt(""+GridH.elementAt(i));
                      rec[i] = new Rectangle2D.Double(gridX, gridY, gridW, gridH);
                      g2.draw(rec);
    catch(SQLException sqle){}
    private Vector GridX, GridY, GridW, GridH;
    private int gridX = 0, gridY = 0, gridW = 0, gridH = 0;
    Fill the point
         public void placePoint(Graphics2D g2,Point p)
              g2.setPaint(Color.red);
              g2.fill(new Ellipse2D.Double(p.x - 3, p.y - 3, 7,7));
    Create connection to Database
         public void connDB()
              System.out.println ("Connecting to Database");
              String fileName = "Pro.mdb";
              String data = "jdbc:odbc:Driver={Microsoft Access Driver " +
         "(*.mdb)};DBQ=" + fileName + ";DriverID=22";
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   conn = DriverManager.getConnection(data,"","");
                   stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_UPDATABLE);
              catch(ClassNotFoundException ce)
              { System.out.println ("Khong tim thay Driver"); }
              catch(SQLException sqle)
              { System.out.println ("Loi SQL trong khi Connect"); }
              Statement stmt = null;
              ResultSet rs = null;
              Connection conn = null;     
    This one is the model map to draw
         private String nameOfMap = "map.jpg";
         private BufferedImage mImage;
    Initialize the path and shapes to draw
         private Line2D line[];
         private Rectangle2D.Double rec[];
         private GeneralPath backGround[];
         private Point point;
         private int changeColor = 0;
    The last one is:
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
    public class commandPanel extends JPanel implements ActionListener
    Initial check box
         JCheckBox uyBanNhanDan = new JCheckBox();
         JCheckBox nganHang = new JCheckBox();
         JCheckBox buuDien = new JCheckBox();     
         JCheckBox khachSan = new JCheckBox();     
         JCheckBox benhVien = new JCheckBox();          
         JCheckBox cho = new JCheckBox();     
         JCheckBox nhaHat = new JCheckBox();     
         JCheckBox daiHoc = new JCheckBox();     
         JCheckBox thuvien = new JCheckBox();     
         JCheckBox nhaTho = new JCheckBox();     
         public commandPanel()
              this.setLayout(new BorderLayout());
              this.setBorder(BorderFactory.createCompoundBorder(
                          BorderFactory.createTitledBorder("***Chu dan***"),
                          BorderFactory.createEmptyBorder(5,5,5,5)));
    Create the combobox to show information
              uyBanNhanDan.setText("Uy Ban ND Quan");
              nganHang.setText("Ngan Hang");
              buuDien.setText("Buu Dien");
              khachSan.setText("Khach San");
              benhVien.setText("Benh Vien");
              cho.setText("Cho - Mua Sam");
              nhaHat.setText("Nha Hat");
              daiHoc.setText("Dai Hoc - Dao Tao");
              thuvien.setText("Thu Vien - Nha Sach");
              nhaTho.setText("Nha Tho - Chua");
              uyBanNhanDan.addActionListener(this);
              nganHang.addActionListener(this);
              buuDien.addActionListener(this);
              khachSan.addActionListener(this);
              benhVien.addActionListener(this);
              cho.addActionListener(this);
              nhaHat.addActionListener(this);
              daiHoc.addActionListener(this);
              thuvien.addActionListener(this);
              nhaTho.addActionListener(this);
              uyBanNhanDan.setActionCommand("1");
              nganHang.setActionCommand("2");
              buuDien.setActionCommand("3");
              khachSan.setActionCommand("4");
              benhVien.setActionCommand("5");
              cho.setActionCommand("6");
              nhaHat.setActionCommand("7");
              daiHoc.setActionCommand("8");
              thuvien.setActionCommand("10");
              nhaTho.setActionCommand("11");
              JPanel secP = new JPanel();
              secP.setLayout(new GridLayout(5,2));
              secP.add(uyBanNhanDan);
              secP.add(nganHang);
              secP.add(buuDien);
              secP.add(khachSan);
              secP.add(benhVien);
              secP.add(cho);
              secP.add(nhaHat);
              secP.add(daiHoc);
              secP.add(thuvien);
              secP.add(nhaTho);
              this.add(secP,BorderLayout.NORTH);
         public void actionPerformed(ActionEvent event)
              int x = 0;
              int y = 0;
              try
                   mapPanel mp = new mapPanel();
                   int idDiaDanh = 0;
                   if(event.getActionCommand() == "1")
                        idDiaDanh = 1;
                   String Query =
                   "SELECT CoorX, CoorY FROM MoTa WHERE IDDiaDanh =" + idDiaDanh;
                   mp.rs = mp.stmt.executeQuery(Query);
                   while(mp.rs.next())
    /*I have problem here*/
    /*Process the event for me*/          x = mp.rs.getInt(1);
                        y = mp.rs.getInt(2);
                        Graphics g2 = mp.getGraphics();
                        mp.paintComponents(g2);
                             g2.setPaint(Color.red);
                             g2.fill(new Ellipse2D.Double(x - 3, y - 3, 7, 7));     
              catch(SQLException sqle){}

    Strings are Objects.
    String[] strings = new String[3];
    String[0]="abcde";Right here, you are initializing the String array, and the String at index 0.
    JButton[] buttons = new JButton[2];
    buttons[0].setText("abcde");Right here, you are initializing the JButton array, but not any of the JButtons in the array. You then try to use the setText() method on a null JButton.

  • Code from swing tutorial

    hi this is code from sun's swing tutorial (http://java.sun.com/docs/books/tutorial/uiswing/learn/example1.html )
    import javax.swing.*;       
    public class HelloWorldSwing
    private static void createAndShowGUI()    // why it is private ??
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame frame = new JFrame("HelloWorldSwing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel label = new JLabel("Hello World");
            frame.getContentPane().add(label);
            frame.pack();
            frame.setVisible(true);
       public static void main(String[] args) {
                 javax.swing.SwingUtilities.invokeLater(new Runnable()  // what does this snippet doing ?
                public void run()
                    createAndShowGUI();
    }i have question on this code. i have put my question in the comment . in the tutorial they are advising to " Be thread safe ...what it means ?
    can anybody explain my questions ( commentation + bold letter) ?
    thanks

    i have seen swing codes which dont use threads
    like above . does it mean they are not safe ?
    what do you mean by safe ? ...does it mean program
    can crash at any time if i dont include that
    snippet ? will you be explicit in a simpler way.It is extremely unlikely that doing the following is unsafe:
    //in main thread:
    frame.pack();
    frame.setVisible(true); //unsafe?But there's no guarantee! And by unsafe, the authors mean that undefined behavior can result --
    your GUI could do anything it wanted! That being said, it's extremely unlikely that anything bad
    would result in this example -- it's too simple. I do remember someone posting once that they
    finally tracked an intermittent bug in their app to just this!
    What I do, if I'm being safe/paranoid is call a utility method I've written, instead of calling setVisible
    in the above code:
    public static void postVisible(final JFrame f, final boolean state) {
        Runnable r = new Runnable() {
            public void run() {
                f.setVisible(state);
        SwingUtilities.invokeLater(r);
    }Problem solved!
    >
    second question was why the method was private
    static......why not public static ?(if you really
    want to make it static !!)1. Since they never instantiate HelloWorldSwing, the method had better be static.
    2. Methods should have the most restrictive scope possible. Since this is the "main" class
    that launches its own GUI, no other class needs to see createAndShowGUI, so it is private.

  • Ebay ask member question, enter code in box will not work, works fine in IE8

    I am using Firefox 19.0. While on Ebay if I go to "Ask seller a question", you have to enter a random generated security code in a box. In the past this worked fine, but in the past year or so has quit working with Firefox and several versions of it. The process works fine with IE8, so it must be associated with Firefox. The only way I can leave a message is the fact that you can choose to have the code read aloud. If I do this and enter the code it works fine, but not if you enter the code printed on the screen. I have tried deleting history/cookies as suggested by Ebay help, but didn't help

    Which security software (firewall, anti-virus) do you have?<br />
    Make sure that it isn't interfering with the CAPTCHA.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Make sure that you aren't blocking cookies.
    You can inspect and manage the permissions for all domains on the <b>about:permissions</b> page.
    *https://support.mozilla.org/kb/how-do-i-manage-website-permissions
    If clearing cookies doesn't work then it is possible that the <i>cookies.sqlite</i> file that stores the cookies is corrupted.
    Rename (or delete) <b>cookies.sqlite</b> (cookies.sqlite.old) and delete other present cookie files like <b>cookies.sqlite-journal</b> in the Firefox Profile Folder in case the file cookies.sqlite got corrupted.
    *http://kb.mozillazine.org/Cookies

  • Simple question about code

    Hello, I am beginning with SQL again after a long break and am having a niggling problem with the following code. What is going wrong? Thanks, Jonathon Sunny
    CREATE
    TABLE CHILDREN
    CHILD_ID
    INT NOT
    NULL PRIMARY KEY,
    FNAME
    VARCHAR(24)
    NOT NULL,
    LNAME
    VARCHAR(24)
    NOT NULL,
    PHONE
    CHAR(12)
    NOT NULL,
    CHECK (PHONE
    LIKE '(0[0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'),
    CHILDGRADE
    VARCHAR(8)
    NOT NULL,
    CHECK (CHILDGRADE
    LIKE 'BEGINNER'
    OR 'NOVICE' OR
    'SKILLED' OR
    'EXPERT'))
    CREATE
    TABLE INSTRUCTORS
    STAFF_NO
    INT NOT
    NULL PRIMARY KEY,
    FNAME
    VARCHAR(24)
    NOT NULL,
    LNAME
    VARCHAR(24)
    NOT NULL,
    PHONE
    CHAR(13)
    NOT NULL,
    CHECK (PHONE
    LIKE '(0[0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'))
    CREATE
    TABLE LESSONS
    LESSON_ID
    INT NOT
    NULL PRIMARY KEY,
    DAY
    DATE NOT
    NULL,
    TIME
    TIME NOT
    NULL,
    LESSONGRADE
    VARCHAR(8)
    NOT NULL,
    CHECK (LESSONGRADE
    LIKE 'BEGINNER'
    OR 'NOVICE' OR
    'SKILLED' OR
    'EXPERT'))
    CREATE
    TABLE QUALIFICATION
    QUAL_NAME
    VARCHAR(24)
    NOT NULL
    PRIMARY KEY,
    DATE_AWARDED
    DATE NOT
    NULL,
    INSTITUTIONNAME
    VARCHAR(24)
    NOT NULL)
    CREATE
    TABLE BOOK
    FOREIGN
    KEY (CHILD_ID,
    LESSON_ID))
    CREATE
    TABLE TEACH
    FOREIGN
    KEY (LESSON_ID,
    STAFF_ID))
    CREATE
    TABLE AWARDED
    FOREIGN
    KEY (STAFF_ID,
    QUAL_NAME))

    Bellow is the right one:
    CREATE TABLE CHILDREN (
    CHILD_ID INT NOT NULL PRIMARY KEY,
    FNAME VARCHAR(24) NOT NULL,
    LNAME VARCHAR(24) NOT NULL,
    PHONE CHAR(12) NOT NULL,
    CHECK (PHONE LIKE '(0[0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'),
    CHILDGRADE VARCHAR(8) NOT NULL,
    CHECK (CHILDGRADE = 'BEGINNER' OR CHILDGRADE = 'NOVICE' OR CHILDGRADE = 'SKILLED' OR CHILDGRADE = 'EXPERT'))
    CREATE TABLE INSTRUCTORS (
    STAFF_NO INT NOT NULL PRIMARY KEY,
    FNAME VARCHAR(24) NOT NULL,
    LNAME VARCHAR(24) NOT NULL,
    PHONE CHAR(13) NOT NULL,
    CHECK (PHONE LIKE '(0[0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'))
    CREATE TABLE LESSONS (
    LESSON_ID INT NOT NULL PRIMARY KEY,
    DAY DATE NOT NULL,
    TIME TIME NOT NULL,
    LESSONGRADE VARCHAR(8) NOT NULL,
    CHECK (LESSONGRADE = 'BEGINNER' OR LESSONGRADE = 'NOVICE' OR LESSONGRADE = 'SKILLED' OR LESSONGRADE = 'EXPERT'))
    CREATE TABLE QUALIFICATION (
    QUAL_NAME VARCHAR(24) NOT NULL PRIMARY KEY,
    DATE_AWARDED DATE NOT NULL,
    INSTITUTIONNAME VARCHAR(24) NOT NULL)
    CREATE TABLE BOOK (
    CHILD_ID INT NOT NULL,
    LESSON_ID INT NOT NULL
    FOREIGN KEY (CHILD_ID) REFERENCES CHILDREN(CHILD_ID),
    FOREIGN KEY (LESSON_ID) REFERENCES LESSONS(LESSON_ID))
    CREATE TABLE TEACH (
    LESSON_ID INT NOT NULL,
    STAFF_ID INT NOT NULL
    FOREIGN KEY (LESSON_ID) REFERENCES LESSONS(LESSON_ID),
    FOREIGN KEY (STAFF_ID) REFERENCES INSTRUCTORS(STAFF_NO))
    CREATE TABLE AWARDED (
    STAFF_ID INT NOT NULL,
    QUAL_NAME VARCHAR(24) NOT NULL
    FOREIGN KEY (STAFF_ID) REFERENCES INSTRUCTORS(STAFF_NO),
    FOREIGN KEY (QUAL_NAME) REFERENCES QUALIFICATION(QUAL_NAME))
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Question to understand javax.swing.plaf.FontUIResource("Arial Unicode MS"..

    Hi Commuity!
    I have an Question about this function!
    javax.swing.plaf.FontUIResource("Arial Unicode MS", Font.PLAIN, 12);
    I have read the Java doc but this didn�t help!
    I wanted to know, what happend, if this Font is not an the Client.
    So i deleted the Font "Arial Unicode MS".
    But the applikation still use this Font. But it is not on my local PC?
    Were do Swing load the Font�s from?
    Are the Fonts included in Java?
    thx a lot
    Florian

    Has got nobody an idea, where swing load the fonts from?

  • Yet another question on code optimization

    Hello again
    Sorry for asking too many questions, but I really want to learn how to simplify my work.
    Let's say I have this ArrayList that gets initialized every time a user clicks on a new combobox item and a set of numbers are added to it. I then add this arrayList to another arraylist that is initialized outside of the actionlistener class.
    So basically every time the user clicks the inner arraylist is added to outer arraylist. But I don't want to have duplicate results if the user chooses to go back to the previous JTextAreas and delete the contents to start typing new stuff. The way i am doing this is like this:
    ArrayList<String> filler = new ArrayList<String>(); //The filler that has to be unique, so the user won't screw with the pattern
    filler.add("A*?1qkQOz]4X1QedyhA`H-6$U[I{]0n<RT.W})(J+z7o.<q[g5[y0YA2tv+c@WN");
    //For each JtextArea object add a filler so that no Nullpointerexception happens with the use of arraylist.set()method....
    for (int i = 0; i <textAreaObjs.size(); i ++){
         allValues.add(filler);
    //Replace the unique filler with the actual user input saved in innerList which is of type ArrayList.               
    allValues.set(textCounter,innerList);
    //Remove all the unnecessary fillers
    for (int outerArrayCounter = 0; outerArrayCounter < allValues.size(); outerArrayCounter ++){
         for (int innerArrayCounter = 0; innerArrayCounter < allValues.get(outerArrayCounter).size(); j++){
              if (allValues.get(outerArrayCounter).get(innerArrayCounter).equals("A*?1qkQOz]4X1QedyhA`H-6$U[I{]0n<RT.W})(J+z7o.<q[g5[y0YA2tv+c@WN")){
                   allValues.remove(outerArrayCounter);
                   outerArrayCounter--;
                   break;
    }I tried the different methods of the ArrayList like arraylist.set() and if there is a null at this location: do this, if not do something else but they returned Nullpointerexceptions...
    I tried the isEmpty method too but that only checks to see if the whole list is empty and not specific parts of the array....
    Is there a better, faster, and simpler way of doing this?
    Thanks for the help.

    I thought this might help... an example of a Sorted[Descending]Map of Lists... I didn't tackle the "frequency aspect" I just generated a random "key" for the map... and a random string to stuff in the Word...
    I presume your Word is {String word, int lineNumber, int startIndex} from the source-document... and now you need to query your frequency table for "the most common word" or maybe "the top five words".
    You can fill in the blanks.
    ... and BTW... If I where doing this for real I'd be awfully tempted to extend TreeMap into a "generic" DescendingTreeMap, which I would stick somewhere in my common utils package, from whence it could be reused in future by myself and others.
    If you want the code for krc.utilz.RandomString just ask.
    package forums;
    import java.util.Collections;
    import java.util.Collection;
    import java.util.SortedMap;
    import java.util.TreeMap;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.Comparator;
    import java.util.Random;
    import krc.utilz.RandomString;
    public class SortedDescendingMap
      private static final RandomString RANDOM_STRING = new RandomString();
      private static final Random RANDOM = new Random();
      private class DescendingIntegerComparator implements Comparator<Integer>
        @Override
        public int compare(Integer a, Integer b) {
          return -1 * a.compareTo(b);
        @Override
        public boolean equals(Object o) {
          return this == o; // yes I do mean reference-equals.
      private class Word
        private final String word;
        public Word() {
          this.word = RANDOM_STRING.nextString(5);
        @Override
        public String toString() {
          return this.word;
      private final SortedMap <Integer,List<Word>> freqTable;
      private SortedDescendingMap() {
        freqTable = new TreeMap<Integer,List<Word>>(new DescendingIntegerComparator());
      private void populate() {
        for (int i=0; i<50; i++) {
          List<Word> list = new ArrayList<Word>();
          for (int j=1; j<=5; j++) {
            list.add(new Word());
          freqTable.put(RANDOM.nextInt(5), list);
      private void print() {
        for ( Map.Entry<Integer,List<Word>> entry : freqTable.entrySet() ) {
          System.out.println(entry.getKey()+": "+entry.getValue());
      public static void main(String[] args) {
        try {
          SortedDescendingMap map = new SortedDescendingMap();
          map.populate();
          map.print();
        } catch (Exception e) {
          e.printStackTrace();
    }This doesn't mean that I like you, and you're still a Putz! ;-)
    Cheers. Keith.

  • Question about JRE and Swing applications

    Hi i trying to make a Swing application whit some clients but one of them tell me that he have a lot of troubles whit java, because someone make an applet for his website and when he upgrade the JRE the applet dont work anymore.
    In my case i dont want any applets, i want swing, but a im not sure if
    swing uses the JRE and if the application im going to make, may have troubles when they upgrade de JRE.
    Tanks for de answers and sorry for my english

    In general, Java maintains upward compatibility (older code runs in newer Java releases.)
    Certain exceptions are made, and each major Java release identifies these. The current document can be read here:
    http://java.sun.com/j2se/1.5.0/compatibility.html

  • HT5625 i already have an apple ID but every time i try to grt an app from the store theres this question "Security code on the payment box i dont understant it please make it clear"

    Hello,
    I already have an apple ID, but on the payment box theres a question im unable to answer "secret code" what does this mean

    Cannot remember Security Question.
    Call Apple Technical Support. You will have to give proof of your identity.
    http://support.apple.com/kb/HE57

  • Seperating Graphics from code on Swing application

    1)I want to draw simple graphics like rectangles, curves, lines, images etc on top of my swing application. I would like to separate the graphic representation from the code to an external file like XML,XAML , SVG etc.. All these graphics should be editable(i.e. scaling, translating the position, changing font, color etc) . Please let me know the possible technologies?
    2)Also is it possible to use HTML5 canvas component oj java swing.
    JButton button = new JButton("<html><canvas>...</canvas></html>")
    is this possible?.It is not working for me, if it is possible am i missing out something?

    Hi,
    Thanks for your reply!
    I went through the link you provided. This is exactly how my application draws graphics now. But my problem is one of my shape will be a rectagle with circle, another will be rectangle with image.So i have to write seperate classes to draw each of these shapes. My idea is to avoid creating seperate classes but an external file will define all the graphics components and library should be smart enough to identify the drawings required and paint it on my swing components. I am in search for a library or a java feature that can do this. Please help!
    Regards,
    Anjana

  • Quick question reguarding code in libs

    I am currently in the process of just calling an event handler within each of my triggers and having all the code stored in a library, having started this process i released that i cannot refer to :system variables within the lib without causing errors. I.E
    IF v_event_name IN ('KEY-DOWN') THEN
    IF :SYSTEM.LAST_RECORD = 'TRUE'
    THEN     
         MESSAGE('You are at the last record.');
    ELSE     
         DOWN;
    END IF;
    END IF;
    this throws an error stating bad bind variable, wheras it would work perfectly in the trigger, am i doing something stupid, or is there anyway round this? If not i suppose this would just have to remain in the trigger?
    perhaps im being silly but is there no way to refer to any data block items? such as :cars or whatever.
    Thanks in advance.
    Edited by: user13390506 on 13-Aug-2010 04:54

    Hello,
    You can refer these variables and forms items by using the NAME_IN built-in..For example..
    IF v_event_name IN ('KEY-DOWN') THEN
    IF NAME_IN('SYSTEM.LAST_RECORD') = 'TRUE'
    THEN     
         MESSAGE('You are at the last record.');
    ELSE     
         DOWN;
    END IF;
    END IF;And same for the form's items. Remember don't use the COLON (:) while referencing the form's item or these variable in NAME_IN built-in.
    -Ammad

  • 5 question regarding code in DW

    hi
    1 - can i can make php code completion to appear automatically as i write and not use the annoying ctrl+space? just like it does for html and css?
    2- where can i change the font size of the code i write?
    3- where can i change the code formatting for php? like if i prefer the curly braces to appear on its own lines?
    5- regarding code completion. is there a way that when i start a php string it will complete the other '? so when i say: echo ' , it will put the end '?
    4- is there a way to create ducomentation for php? like there is in other IDE`s?
    best regards

    derrida wrote:
     1 - can i can make php code completion to appear automatically as i write and not use the annoying ctrl+space? just like it does for html and css?
    Variables, classes, and objects appear automatically as soon as you start typing. For functions, you need to press Ctrl+Space.
    3- where can i change the code formatting for php? like if i prefer the curly braces to appear on its own lines?
    Dreamweaver does not support source formatting in server-side languages or JavaScript. If you want the curly braces on separate lines, format the code manually as you type it.
    5- regarding code completion. is there a way that when i start a php string it will complete the other '? so when i say: echo ' , it will put the end '?
    Use the echo button in the PHP category/tab of the Insert panel/bar.
    4- is there a way to create ducomentation for php? like there is in other IDE`s?
    No, Dreamweaver does not support PHPDoc.
    If you would like any of these features added to Dreamweaver, submit a feature request through the form at https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform.

Maybe you are looking for

  • How to get Adobe Camera RAW loaded so I can open RAW files from a Panasonic LX7?

    I opened these images two days ago. Now I get a message that the CS6 Photoshop does not recognize this type of file. I went online and again(3rd time)downloaded Camera RAW 7.3 and tried installing and opening the images. Once again - same thing. Now

  • How do I apply a transition to a group of clips?

    Hi, I want to apply a transition to a group of clips. I know how to select a group of clips, but I have not found how to apply the same transition on all of them. Can this be done in FCE?

  • Trying to stream videos just spool and never play

    Hi, Like most people, my Apple TV (2) used to work fine and then after the latest updates (and an apparent lack of software testing by Apple before they release it nowadays) it has become next to useless. My Home Sharing is all turned on, firewalls o

  • How can I change default build time from 1 sec to .5 sec?

    Whenever I create a build, the default time is 1 sec. I'd like it to be .5 sec. I use a blank master slide. How can I change the default build time for all slides? Or can I?

  • Error while running analysis

    Hi, I want to use reports of standard analysis available in SD module, but when I try to run analysis such as MCTA, MCTC, MCTE etc.system shows messege 'No Data exist for chosen selection' What needs to do to get the data in to analysis.