Example usage for javax.swing JFrame setBackground

List of usage examples for javax.swing JFrame setBackground

Introduction

In this page you can find the example usage for javax.swing JFrame setBackground.

Prototype

@Override
public void setBackground(Color bgColor) 

Source Link

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame f = new JFrame();
    f.setBackground(new Color(0, true)); // 1.7.0
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().add(makeUI());/*from  w w w . j  a  v  a  2 s.  co m*/
    f.setSize(320, 240);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setUndecorated(true);/*w  w  w .  ja  v a 2  s.  com*/
    frame.setBackground(new Color(0, 0, 0, 0));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new ShadowPane());

    JPanel panel = new JPanel(new GridBagLayout());
    panel.add(new JLabel("Look ma, no hands"));

    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] av) {
    JFrame frame = new JFrame("MainClass");
    frame.setForeground(Color.black);
    frame.setBackground(Color.lightGray);
    Container cp = frame.getContentPane();
    cp.add(new MainClass(new File(".")));

    frame.pack();/*from  w  w  w.  j  av  a2s.  c om*/
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:TextLayoutPanel.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setBackground(Color.white);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*w w  w.  j ava 2 s .  com*/
        }
    });
    frame.getContentPane().add("Center", new TextLayoutPanel());
    frame.pack();
    frame.setSize(new Dimension(400, 300));
    frame.setVisible(true);
}

From source file:edu.gmu.isa681.client.Main.java

public static void main(String[] args) {
    log.info("Setting look and feel...");

    try {//from w  ww.j  ava2 s .c  o  m
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

    } catch (Exception ex1) {
        log.warn(ex1.getMessage(), ex1);
        log.warn("Nimbus is not available.");
        log.warn("Switching to system look and feel");
        log.warn("Some GUI discrepancies may occur!");

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex2) {
            log.error(ex2.getMessage(), ex2);
            log.error("Could not setup a look and feel.");
            System.exit(1);
        }
    }

    log.info("Initializing GUI...");

    final JFrame frame = new JFrame();
    frame.setTitle("GoForward");
    frame.setBackground(new Color(0, 100, 0));
    UIManager.put("nimbusBase", new Color(0, 100, 0));
    //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0));
    UIManager.put("control", new Color(0, 100, 0));

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            frame.setPreferredSize(frame.getSize());
        }
    });

    Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    if (dim.width < 1366) {
        frame.setPreferredSize(new Dimension(800, 600));
    } else {
        frame.setPreferredSize(new Dimension(1200, 700));
    }

    //frame.setResizable(false);
    frame.setLocationByPlatform(true);
    frame.pack();

    Client client = new Client("localhost", Constants.SERVER_PORT);
    Controller controller = new Controller(client, frame);
    controller.applicationStarted();

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    log.info("Started");
}

From source file:FileTree.java

/** Main: make a Frame, add a FileTree */
public static void main(String[] av) {

    JFrame frame = new JFrame("FileTree");
    frame.setForeground(Color.black);
    frame.setBackground(Color.lightGray);
    Container cp = frame.getContentPane();

    if (av.length == 0) {
        cp.add(new FileTree(new File(".")));
    } else {// ww  w  .j  a  v a  2  s. c o  m
        cp.setLayout(new BoxLayout(cp, BoxLayout.X_AXIS));
        for (int i = 0; i < av.length; i++)
            cp.add(new FileTree(new File(av[i])));
    }

    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Tree With Popup");
    Main panel = new Main();

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.setBackground(Color.lightGray);
    frame.getContentPane().add(panel, "Center");

    frame.setSize(panel.getPreferredSize());
    frame.setVisible(true);//from   www .j a  v  a 2 s  .com
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:lu.lippmann.cdb.weka.SilhouetteUtil.java

public static void main(String[] args) throws Exception {
    final Instances ds = WekaDataAccessUtil.loadInstancesFromARFFOrCSVFile(
            //new File("./samples/csv/uci/zoo.csv"));
            //new File("./samples/arff/UCI/cmc.arff"));
            //new File("./samples/csv/direct-marketing-bank-reduced.csv"));
            //new File("./samples/csv/bank.csv"));
            //new File("./samples/csv/preswissroll.csv"));
            new File("./samples/csv/iris.csv"));
    //new File("./samples/csv/lines.csv"));
    //new File("./samples/csv/pima.csv"));
    //new File("./samples/csv/isolet.csv"));
    //new File("./samples/csv/iris.csv"));

    final SimpleKMeans kmeans = WekaMachineLearningUtil.buildSimpleKMeansClustererWithK(3);

    final WekaClusteringResult cr = WekaMachineLearningUtil.computeClusters(kmeans, ds);

    final JFrame mainFrame = new JFrame();
    mainFrame.setTitle("Silhouette plot");
    mainFrame.setBackground(Color.WHITE);
    LogoHelper.setLogo(mainFrame);//from  ww w .j av a 2  s .c om

    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane().add(buildSilhouettePanel(ds, cr), BorderLayout.CENTER);

    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    mainFrame.setSize(1200, 900);
    mainFrame.setVisible(true);

}

From source file:lu.lippmann.cdb.lab.mds.MDSViewBuilder.java

/**
 * /*  w  ww  .  j a  va  2 s . co  m*/
 * @param args
 * @throws Exception
 */
public static final void main(String[] args) throws Exception {

    //final String fileName = "./samples/csv/salary.csv";
    //final String fileName = "./samples/csv/uci/mushroom.csv";
    final String fileName = "./samples/csv/uci/zoo.csv";
    //final String fileName = "./samples/csv/lines.csv";
    //final String fileName = WekaDataAccessUtil.DEFAULT_SAMPLE_DIR+"csv/zoo.csv";
    //final String fileName = "./samples/csv/speech-revisited.csv";
    //final String fileName = "./samples/arff/UCI/autos.arff";

    Instances instances = WekaDataAccessUtil.loadInstancesFromARFFOrCSVFile(new File(fileName));

    //Modify instance using SHIH Algorithm
    //Shih2010 shih = new Shih2010(instances);
    //instances = shih.getModifiedInstances();

    LookAndFeelUtil.init();

    final JFrame mainFrame = new JFrame();
    mainFrame.setBackground(Color.WHITE);
    LogoHelper.setLogo(mainFrame);
    mainFrame.setTitle("MDS for '" + instances.relationName() + "'");

    int maxResult = 1000;
    final MDSResult mdsResult = ClassicMDS.doMDS(instances, MDSDistancesEnum.EUCLIDEAN, 2, maxResult, true,
            false);

    mainFrame.getContentPane().setLayout(new BorderLayout());
    mainFrame.getContentPane()
            .add(buildMDSViewFromDataSet(instances, mdsResult, maxResult, new Listener<Instances>() {
                @Override
                public void onAction(final Instances parameter) {
                    //System.out.println(parameter);      
                }
            }));

    mainFrame.setSize(1200, 900);
    mainFrame.setVisible(true);

}

From source file:Main.java

public Main() {
    this.setSize(400, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton button = new JButton("Change Frame Color");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Component component = (Component) e.getSource();
            JFrame frame = (JFrame) SwingUtilities.getRoot(component);
            frame.setBackground(Color.RED);
        }/*from  w  w w .  jav a2  s .c o  m*/
    });
    this.getContentPane().add(button);
}