Working in a jFrame - overriding paint

Hey guys, currently I'm programming a game in Java.
I use a JFrame with a CustomJPanel.
In my CutomJPanel i override the Paint method.
This is working well, i have something about 200FPS, but it's still simple.
Today I read a Article about JavaFX and saw it has GPU Support.
So if i use a CustomJFXPanel in my JFrame instead, are I just getting the advantage of GPU-Support by it?
Or do i lose the benefits be overriding the Paint Method?

This question cannot be answered in a simple yes/no way. It depends on the kind of graphics operation that you want to perform. In some areas JavaFX is slower than good old AWT. So it depends.

Similar Messages

  • Overriding paint for customizing JButton??? Shouldn't be paintComponent?

    Hi
    Shouldn't we always override paintComponent to customize the painting of a component?
    Why MetalScrollButton in javax.swing.plaf.Metal overrides paint instead of paintComponent?
    Should I override paint if I want to write my own LnF?
    Thanks.

    As is said in the online doc about paint(), "This method actually delegates the work of painting to three protected methods: paintComponent, paintBorder, and paintChildren. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint method should just override paintComponent."
    That means you can override paint(), , but in this case you'll have to draw the border yourself... and if you have a composite custom component (a panel containing labels, for example), you will have to call the label's paintComponent() methods by yourself...
    Hope this helped,
    Regards

  • Overriding paint method hides my status bar icons

    Hi All,
                I use setStatus on MainScreen to add some image ButtonFields to my status bar.
                It shows up fine.
                But when I override paint method , it hides all the icons I added using setStatus.
               Any clue on this ? Thnx in advance.
              Here is my paint method:
    protected void paint(Graphics graphics) {
    super.paint(graphics);
    Bitmap image = ImageUtility.loadBitMap("header2.jpg");
    graphics.drawBitmap(0, 0, 500, image.getHeight(), image, 0, 0);
    for(int i =0; i < 5; i++ ){
    fieldList.drawListRow(fieldList, graphics, i, 50 + (i*50), 20);
    protected void paint(Graphics graphics) {         
             Bitmap image = ImageUtility.loadBitMap("header2.jpg");
             graphics.drawBitmap(0, 0, 500, image.getHeight(), image, 0, 0); for(int i =0; i < 5; i++ ){           fieldList.drawListRow(fieldList, graphics, i, 50 + (i*50), 20);
    Aranya

    Try Calling super.paint at the start or at the end ... it should do the trick

  • Overriding paint

    Is there any way to override paint only for one instance. For example, I have an image that I want to display, but after it is displayed, I want to be able to modify it. Problem is is that whenever a window is passed over the image, it updates and calls the paint method, which erases the modifications I made to the image. Is there anyway to only override the paint method only when I want to initially display the image?
    Also how would I scale down an ImageIcon so that its smaller?
    Thanks,
    Rick

    Don't modify the original image. Create a second image, paint your original image into the second image and then modify the second image. Each time paint is called, paint the second image to screen. The second one will always have your modifications, so it's safe to paint it multiple times. If you need to change the image agian, paint your original image over the first image again (to get an new clean copy) and modify it again. That's probably the most simplest thing you could do.
    You could also convert an image to a byte array, modify the byte array and use an ImageProducer (please look up that class) to paint your byte array to the screen. If you marked it as animated, you can update the byte array as often as you want and the changes will be viewable on the next call of paint.

  • [svn] 3921: Fix for - @inheritDoc tag not working for get/ set overrides when you only override the setter of a base class

    Revision: 3921
    Author: [email protected]
    Date: 2008-10-28 06:23:00 -0700 (Tue, 28 Oct 2008)
    Log Message:
    Fix for - @inheritDoc tag not working for get/set overrides when you only override the setter of a base class
    QE Notes: Baselines for framework test will need to be updated.
    Doc Notes: None
    Reviewer: Paul
    Bugs: SDK-17304
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17304
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ASDocExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java

    Revision: 3921
    Author: [email protected]
    Date: 2008-10-28 06:23:00 -0700 (Tue, 28 Oct 2008)
    Log Message:
    Fix for - @inheritDoc tag not working for get/set overrides when you only override the setter of a base class
    QE Notes: Baselines for framework test will need to be updated.
    Doc Notes: None
    Reviewer: Paul
    Bugs: SDK-17304
    tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17304
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ASDocExtension.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java

  • How can I stop a JFrame from painting it's background on setVisible?

    When a JFrame is set visible it will paint its background before it paints whatever is in the contentPane. This gives an ugly gray flash before the content pane is painted. I can't use the solution of setting the JFrame's background color because the content pane is displaying an image, not a simple color. I need the image to be the first thing displayed when the frame is set visible. Seems related to doublebuffering some how, but I'm not sure what to do. The same problem presents itself with a JWindow IF it has a parent JFrame. Below is code that will demonstrate this problem.
    import java.awt.Color;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class Test extends JFrame{
    JPanel panel = new JPanel();
    public static void main(String[] args) {
    new Test().setVisible(true);
    private Test(){      
    getContentPane().add(panel);
    // setBackground(Color.white); // <-- uncomment this to remove flash.
    panel.setBackground(Color.white);
    setSize(640, 480);
    super.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    I can't use the solution of setting the JFrame's background color because the content pane is displaying an image, not a simple colorMy question to you is what difference does it make?. Like it or not, JFrame is either going to set the background with the LAF control color or the color you specified. Take a look at the source code and you will see that JFrame calls a protected frameinit method where it gets and sets the backgroud color. The only feasible solution is shown below:
    import java.awt.Color;
    import javax.swing.*;
    public class Test extends JFrame {
       JPanel panel = new JPanel();
       public static void main(String[] args) {
          UIManager.put("control",Color.white);  // added by V.V.
          new Test().setVisible(true);
       private Test() {
          getContentPane().add(panel);
          panel.setBackground(Color.white);
          setSize(640, 480);
          super.setDefaultCloseOperation(EXIT_ON_CLOSE);
    };o)
    V.V.

  • JFrame Not Painting Until Resize

    I have a couple of components in my JFrame. At first, it looks like the JFrame's not painting. I tried calling repaint() before and after I made the JFrame visible. I also moved the JFrame, which should repaint it. However, if I try to resize the JFrame or just click while the cursor is in "resize mode," everything draws and acts fine. Unfortunately, I want to make the JFrame non-resizable. What's the problem?

    try calling the validate method before repainting

  • Overriding paint() method...

    i have a number of JComponents which I am displaying within a JPanel.
    Each JComponent holds a GIF image. Therefore, i overrode the paint(Graphics g) method of my JComponent Subclass.
    Now i need to connect each JComponent with lines. I had to do this within the JPanel, so i added the following to the paint method of the JComponent:
    public void paint(Graphics g) {
      //code here to display JComponent with image
      //then:
      JPanel panel = this.getParent();
      panel.getGraphics().drawLine(this.xCoordinate, this.yCoordinate, myJComponent2.getXCoordinate(), myJComponent2.getYCoordinate());
    }The JPanel displays correctly when i run it. But as soon as i resize the JFrame which holds the JPanel (for example, maximise the window):
    - The images of the JComponents within the JPanel remain visible
    - BUT the lines i drew disappear.
    Any ideas why the lines are disappeaing?
    How can it be solved?
    thanks

    further, I would strongly argue that trying to draw on other components from the paint method of another component is a bad bad bad idea.
    Calling setPreferredSize in the paint methods is also not something you should do either.
    The paint method is for painting in that component only. Setting size and location and doing other layout things in the paint methods is not the appropriate place for those things.
    If you want to draw on the panel, then draw on the panel in the panel, not in some child component. If you want to assign a default preferred size, do so in the constructor.

  • Help with JFrames:Two JFrames dont paint properly

    Hello Guys.I am new here and I would like to ask for some help.
    I have a problem with me Java application.
    My main Class is the MainGUI class which has some selection components and is a JFrame.When the user presses the "proceed" button, it will make a Calculation.class Object to make some calculations.When these are completed, the Calculation class will create a ResultsWindow.class Object which is a new JFrame. The two JFrames (this if type MainGUI and the one of type ResultsWindow) coexist;however they do not show their components properly.What is going on?Can u help me? I am posting some example code:
    public class MainGUI extends JFrame implements ActionListener{
    public MainGUI() {}
    public void actionPerformed(ActionEvent e){
    if (e.getSource() == proceedButton) {
    Calculator calculatorObj=new Calculator();
    if (radioGZIP.isSelected() && radioNone.isSelected()) {
    calculatorObj.applyCalculations("NONE","GZIP",filesTableToProcess,targetFolder);}
    public static void main(String[] args) {
    MainGUI start =new MainGUI();
    public class Calculator{
    public void applyCalculations(String technique,String algorithm,final String[] filesTable,String targetFolder) {
    ResultsWindow resultsWindowObj=new ResultsWindow(technique,algorithm,filesTable,resultTable,resultNCD);
    public class ResultsWindow extends JFrame implements ActionListener{
    public ResultsWindow(String technique,String algorithm,String[] filesTable,String[][] resultTable,double[] resultNCD) { ...}
    I think this is a thread problem...what should I do?The window should repaint everytime I maximize, but it does not...The two JFrames seem to be blocking each other!Help me plz...

    Then, my second stab in the dark is:
    You don't call revalidate() or validate() on some of their containers after
    adding components.
    Post the relevant parts of your code or small example code that can reproduce the problem.
    See: http://www.physci.org/codes/sscce.jsp

  • Best recommendataion to work with one JFrame & Multiple Jpanels(or Windows)

    Hi all,
    I am a bit new(bie) to Java and Gui but not new to programming.
    I need to write an application in using Java. The Current editor I use is Netbeans.
    I have a rough idea on how to write this apps, but I would like to confirm if my idea is applicable to such application (from a performance and feasibility standpoint).
    The main idea for this application is to have multiple forms that users would populate, and the values entered will be stored in a Database.
    I had plan to use only one main Window (JFrame), and no MDI, no multiple Java windows.
    My plan was:
    -     Create the main form (JFrame) with menus, once the application is loaded, I will check if a database connection is available otherwise open a Jpanel to input database settings (which can be started from the menu).
    -     All menus and application/company settings would be set in the main form
    -     All features available in the Jpanel would be in a separate class for clarity/lisibility of my code. For instance : user settings would be a separate jpanel class; database settings is a new jpanel class
    -     Each Jpanel class would be stored in a separate java/class file.
    Here is my test example for now (file MainForm.java) :
    import javax.swing.*;
    public class MainForm extends JFrame {
        /* Initializing a few variables */
        String databaseServer = null;
        String databaseUserName = null;
        String databasePassword = null;
        /** Creates new form MainForm */
        public MainForm() {
            /* Initializing menus */
            initComponents();
           /* starting a new instance of database configuration */
            DbPanel test = new DbPanel();
        /* Initialization menu and graphical components */
        private void initComponents () {
            JMenuBar BarMenu;
            JMenu MenuConfiguration;
    /* �.*/
         BarMenu.add(MenuConfiguration);
         setJMenuBar(BarMenu);
         pack();
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainForm().setVisible(true);
    } Here is my DBpanel class (file MainForm.java) :
    public class DbPanel extends javax.swing.JPanel {
        /** Creates new form DbPanel */
        public DbPanel() {
            initComponents();
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            java.awt.Button buttonClose;
            java.awt.Button buttonSave;
            java.awt.TextField dbName;
    /* � */
           gridBagConstraints.ipadx = 100;
            gridBagConstraints.insets = new java.awt.Insets(0, 21, 0, 21);
            add(dbPassword, gridBagConstraints);
    // </editor-fold>   
    }Here are then my questions:
    -     Would you think that is a practical plan to write such application?
    -     Once I display a Jpanel form and I close it (for instance myJpanel.setVisible=false), will the memory be freed?
    -     Is there any other way to remove entire a JPanel from RAM?
    -     How can I call my �external� Jpanel ? I have designed one Jpanel class for testing but I was not able to display it when I created the new instance of that class.
    -     Is there any other alternative to Jpanel for this application? I was thinking about opening a new window within my Jframe. But, ideally it would be best that multiple windows are not opened simultaneously.
    Thanks for your input

    I was thinking about this but requirements are the
    application development cost should be reduced to the
    minimum.
    thus one desktop application and one database
    server.Application development cost? If you are being paid to do this, the bulk of the cost will be your hourly rate times the number of hours it takes you to do it. Thus you want to minimize the number of hours it takes you to do it. Assuming that the cost of your learning Java is going to be charged to this project, it might well be a good idea for you to do it in a language you already know. Or one where it's easy to develop this sort of application.

  • SetBounds method is not working - settings change after Applet paint()

    Hello,
    I'm creating an applet with a scrollbar on it. I'm using Scrollbar.setBounds to set its position and dimension. These values are correct at the end of the init() method, but when the paint() method starts executing, these values have changed!
    Here's my code :
    import java.awt.Graphics;
    import java.awt.Scrollbar;
    public class testSetBounds extends java.applet.Applet {
      Scrollbar sb;
      public void init(){
        sb = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 270);
        sb.setBounds(10, 200,300,10) ;
        this.add(sb);
        System.out.println("sb.getWidth() " + sb.getWidth() );
        System.out.println("sb.getBounds().x " + sb.getBounds().x  ) ;
      public void paint(Graphics g){
        System.out.println("paint...") ;
        System.out.println("sb.getWidth (at start of paint()) " + sb.getWidth() );
        System.out.println("sb.getBounds().x " + sb.getBounds().x  ) ;
        System.out.println("sb.getMaximum() " + sb.getMaximum()) ;
    <html>
    <body>
    <applet code="testSetBounds" codebase="classes" width="300" height="350">
    </applet>
    </body>
    </html>
    The output I get on the Java Console is:
    sb.getWidth() 300
    sb.getBounds().x 10
    paint...
    sb.getWidth (at start of paint()) 50
    sb.getBounds().x 125
    Can anyone tell me what's going on?
    How to make my scrollbar remain in the position and with the dimensions I specified?
    Thank you very much.

    The layout manager is setting the bounds. If fo some obscure reason you want to do all the layout yourself then -
    Hello,
    I'm creating an applet with a scrollbar on it. I'm
    using Scrollbar.setBounds to set its position and
    dimension. These values are correct at the end of the
    init() method, but when the paint() method starts
    executing, these values have changed!
    Here's my code :
    import java.awt.Graphics;
    import java.awt.Scrollbar;
    public class testSetBounds extends java.applet.Applet
    Scrollbar sb;
    public void init(){
    sb = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0,
    , 0, 270);
    sb.setBounds(10, 200,300,10) ;this.setLayout(null);
    this.add(sb);
    System.out.println("sb.getWidth() " +
    " + sb.getWidth() );
    System.out.println("sb.getBounds().x " +
    " + sb.getBounds().x ) ;
    public void paint(Graphics g){
    System.out.println("paint...") ;
    System.out.println("sb.getWidth (at start of
    t of paint()) " + sb.getWidth() );
    System.out.println("sb.getBounds().x " +
    " + sb.getBounds().x ) ;
    System.out.println("sb.getMaximum() " +
    " + sb.getMaximum()) ;
    <html>
    <body>
    <applet code="testSetBounds" codebase="classes"
    width="300" height="350">
    </applet>
    </body>
    </html>
    The output I get on the Java Console is:
    sb.getWidth() 300
    sb.getBounds().x 10
    paint...
    sb.getWidth (at start of paint()) 50
    sb.getBounds().x 125
    Can anyone tell me what's going on?
    How to make my scrollbar remain in the position and
    with the dimensions I specified?
    Thank you very much.

  • Using the paint() function on a JFrame

    I'm currently enrolled in a graphics course and we've done several programs with line drawing algorithms, polygon filling algorithms, and the like. The only problem is, I have to work on our computers in the lab on campus because of this problem:
    On my computer at home(and many others), every time I try to draw on a JFrame the background of the thing takes on whatever is behind it at the time its run. The line is draw, the background is just clear, making it difficult to see what is going on. I also found that if I completely comment out the paint() function, the background is fine in the JFrame. In the lab, however, the background is the standard light grey and no drawing problems arise. This method of drawing came from my professor, and he's not sure why this is happening either, though I don't think he's taken much time to find the problems.
    Other than the lab computer having a dual core processor, the systems are quite similiar. The only other hardware difference that I reckon could be causing this is the lab's on-board video vs. my PCI-e graphics card. I
    I'm using Netbeans 5.5 and Java 1.6.0. Here is the code I'm using that just draws a simple line:
    /*CSI435   Assignment 4
    * Assign4.java
    * Created on February 5, 2007, 12:58 PM
    package polyfill;
    * @author  bd
    import javax.swing.*;    
    import java.awt.*;  
    public class Assign4 extends JFrame {
        /** Creates new form Assign4 */
        public Assign4(String title) {
            super(title);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            pack();
        }// </editor-fold>                       
         * @param args the command line arguments
        public void paint(Graphics g){
          g.drawLine(100,100,500,500);
        public static void main(){              //sets window
         Assign4 f = new Assign4("Assign4");
         f.setSize(800, 600);
         f.setVisible(true);
        // Variables declaration - do not modify                    
        // End of variables declaration                  
    };Here's a screenshot of the window of what the program produces on my home computer:
    http://i19.photobucket.com/albums/b170/pieps86/window.jpg
    This is strictly the program window, everything from the title bar down should be grey, with the line drawn right down the center, but as you can see, Netbeans is now the background. :)
    Any help is appreciated, because it'd be really nice to work on these programs at home.

    You shouldn't use a JFrame for painting stuff. I cannot run your code because you use 3rd party classes I don't have. Try using a JComponent (like a JPanel for instance) for the painting and override it's protected void paintComponent(Graphics g) method.
    Here's an example:import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class DrawTest extends JFrame {
        public DrawTest(String title) {
            super(title);
            this.getContentPane().add(new DrawingBoard());
            this.setSize(800, 600);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setVisible(true);
        class DrawingBoard extends JPanel {
            protected void paintComponent(Graphics g) {
                g.drawLine(100, 100, 500, 500);
        public static void main(String[] args) {
            new DrawTest("Assign4");
    }Good luck.

  • Override of update not working

    In another class I have a KeyListener that gets the key typed and writes it to c1 of this object. In there I also call repaint(); This is working and I can get the character to write to the screen. I built it so each character writes to a different part of the screen to create a string. But, when I resize the window, all previous characters are lost and only the last character is on the screen. I've tried many different things but it looks like my override to update() isn't doing anything. In fact, if I comment out update() the same thing happens. Any help anyone has is greatly appreciated.
    package wordPack;
    import java.awt.AlphaComposite;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import javax.swing.JPanel;
    public class TextRendering extends JPanel {
    String c1 = "";
    String c2 = "";
    int x;
    int y;
    /** Creates a new instance of TextRendering */
    public TextRendering() {
    public void paint(Graphics g) {
         Graphics2D g1 = (Graphics2D) g;
    Font f1 = new Font("Serif", Font.PLAIN, 15);
    g1.setFont(f1);
    g1.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
    g1.drawString(c1, x, y);
    Graphics2D g2 = (Graphics2D) g;
    c2 = "Second";
    Font f2 = new Font("Serif", Font.PLAIN, 15);
    g2.setFont(f2);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f));
    g2.drawString(c2, 150, 49);
    public void update ( Graphics g ) {
         paint(g);
    }

    Sorry to keep replying to this same post! I've cobbled up a small example showing how to do this. It could definitely be improved:
    1. Calling buf.toString() each time paintComponent() is called may not be the most efficient (but it's okay if you know the input will only be short amounts of text).
    2. Keys such as backspace aren't supported.
    3. It repaints the entire JPanel with each keypress. You should work out an algorithm to paint only the affected area.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TextRenderingTest extends JFrame {
         public TextRenderingTest() {
              TextRenderingPanel contentPane = new TextRenderingPanel();
              setContentPane(contentPane);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              setTitle("Text Rendering Test");
              pack();
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        new TextRenderingTest().setVisible(true);
         class TextRenderingPanel extends JPanel implements KeyListener {
              private StringBuilder buf;
              public TextRenderingPanel() {
                   setFocusable(true);
                   addKeyListener(this);
                   setPreferredSize(new Dimension(300,300));
                   buf = new StringBuilder();
              public void keyPressed(KeyEvent e) {
              public void keyReleased(KeyEvent e) {
              public void keyTyped(KeyEvent e) {
                   char ch = e.getKeyChar();
                   buf.append(ch);
                   repaint(); // Overkill; should only repaint affected area.
              protected void paintComponent(Graphics g) {
                   g.setColor(Color.BLACK);
                   g.drawString(buf.toString(), 10,10);
    }

  • Using Paint in JFrame

    I am trying to divide a frame into a number of different rectangles, and for some reason I can't get the paintComponent to work. Help!!

    I was wrong in reply one. The paint method in JFrame shows up in the Container methods section, so JFrame uses paint as a Container.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class PaintingDemo extends JPanel {
      int
        width,
        height;
      int[][] circles = {
        {2,20}, {100,50}, {180,200}, {90,150}
      int[][] squares = {
        {40,90}, {100,200}, {150,300}
      int[][] rectangles = {
        {100,100}, {200,100}, {300,300}
      public PaintingDemo(int width, int height) {
        this.width = width;
        this.height = height;
        setBackground(Color.pink);
        setPreferredSize(new Dimension(width, height));
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setPaint(Color.blue);
        int x,y;
        for(int i = 0; i < circles.length; i++) {
          x = circles[0];
    y = circles[i][1];
    g2.fill(new Ellipse2D.Double(x, y, 20, 20));
    g2.setPaint(Color.red);
    for(int i = 0; i < squares.length; i++)
    g2.fill(new Rectangle2D.Double(squares[i][0], squares[i][1], 10, 10));
    g2.setPaint(Color.orange);
    for(int i = 0; i < rectangles.length; i++)
    g2.fill(new Rectangle2D.Double(rectangles[i][0], rectangles[i][1], 50, 25));
    public static void main(String[] args) {
    JFrame f = new JFrame();
    f.getContentPane().add(new PaintingDemo(400,400));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);

  • How To Make mozilla.cfg, override.ini, all-companyname.js, Files To Work Once And For All For All Users

    I'm currently trying to apply a fix to the firefox browser (version 23.0.1) on over 250 computers. Setting default webpages, disabling annoying prompts like the default browser and importing bookmarks, and erasing the history on shutdown, or startup. This is very easily done modifying the pref.js file, but I will not edit that file, it's out of the question. Another FF update will erase or overwrite all of my modifications.
    I run a computer lab in the university that is locked down using a Net Support School console. You don't need to look that up. Basically all websites are restricted except the ones the ones I whitelist. The websites we use have extensive API's for JS, CSS, Java, PHP, etc... We utilize technology in order for students to use graphing calculators, video's, and taking module test from these white-listed websites, like Pearson, or Aleks. Now with that said, cookies, and stored profile history become a problem, and on some day's up to 25% of the students using the computers need their entire history deleted in order for a page to load. I think I fixed this problem permanently by whitelisting backend sites importing plugins, and API's etc, that I found from the developers console. Whatever. What I've learned from all of this is that Firefox can be very customizable utilizing the "...\Mozilla Firefox\mozilla.cfg" and the "...\Mozilla Firefox\defaults\prefs\all-companyname.js" (or custom.js) The problem, is no matter what I try I can't get these to work. The closest I got was here:
    http://www.intrntpirate.com/?p=615
    Again, even that ^^ didn't work. I followed these directions to a "T". What is wrong with the above information provided in the link? Why is firefox making harder and harder for us to optimize it for massive deployments across a corporation and a university? I'm not going to do any fancy hacks to avoid the main issue. I need mozilla.cfg, and the all-companyname.js, and the override.ini files to work, if and only if they are still relevant.
    These are what my files look like so far:
    name: all-lmc.js<br />
    location: C:\Program Files (x86)\Mozilla Firefox\defaults\pref\<br />
    pref("general.config.filename", "mozilla.cfg");<br />
    pref("browser.startup.homepage", "https://(some url)");<br />
    name: override.ini<br />
    location: C:\Program Files (x86)\Mozilla Firefox\<br />
    [XRE]<br />
    EnableProfileMigrator=false<br />
    <br />
    name: mozilla.cfg<br />
    location: C:\Program Files (x86)\Mozilla Firefox\<br />
    //<br />
    lockPref("privacy.sanitize.sanitizeOnShutdown", true);<br />
    lockPref("privacy.sanitize.promptOnSanitize", false);<br />
    lockPref("browser.shell.checkDefaultBrowser", false);<br />
    lockPref("toolkit.telemetry.enabled", false);<br />
    lockPref("toolkit.telemetry.prompted", 2);<br />
    lockPref("toolkit.telemetry.rejected", true);
    I've tried using, and not using, the automatic mozilla configurator. I've tried changing lockPref to pref. Nothing works. Not the override.ini, not the all-lmc.js, and not the mozilla.cfg. I've wasted hours reading through blogs of experts telling us to modify files that don't exist, or beating around the bush. I'm done researching. If you have the answer or want to help me figure this out just remember to keep it simple. Please. I ultimately want to package all the config files, with a how to, in a zip folder onto our shared drive. To have FF customized and ready to deploy to different departments across campus.

    Thanks very much for your help, but I'm still overlooking something. I double checked to make sure that I did not have a hidden .txt file extention. I then decided to abandon the lock on preferences idea until I get it working. I converted my mozilla.cfg file back to plain text. I made sure I do not have an extra blank line at the end of each file. The syntax looks good, as far as I can tell. I'll copy and paste what I have so far. Did I have the file locations correct posted above? Also, if you feel i can delete some lines of text in my mozilla.cfg file I'll be happy to do so.
    mozilla.cfg
    <pre><nowiki>//
    pref("privacy.sanitize.sanitizeOnShutdown", true);
    pref("privacy.sanitize.promptOnSanitize", false);
    pref("browser.rights.override", true);
    pref(“app.update.auto”, false);
    pref(“extensions.blocklist.enabled”, false);
    pref(“extensions.shownselectionUI”, true);
    pref(“browser.shell.checkDefaultBrowser”, false);
    pref(“toolkit.telemetry.enabled”, false);
    pref(“toolkit.telemetry.prompted”, 2);
    pref(“toolkit.telemetry.rejected”, true);
    pref(“app.update.auto”, false);
    pref(“browser.download.useDownloadDir”, true);
    pref(“browser.search.update”, false);
    pref(“signon.autofillForms”, false);
    pref(“signon.rememberSignons”, false);
    pref(“browser.download.manager.scanWhenDone”, true);
    pref(“browser.formfill.enable”, false);
    pref(“xpinstall.enabled”, true);</nowiki></pre>
    channel-prefs.js
    pref("app.update.channel", "release");
    override.ini
    [XRE]
    EnableProfileMigrator=false
    all-lmc.js
    pref("general.config.filename", "mozilla.cfg");
    defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://bbc.co.uk");
    Again, thank you very much for your time. Do I create my own browserconfig.properties, and firefox.js? Also, I forgot to mention I'm running Windows 8.

Maybe you are looking for