Exemplo n.º 1
1
  public static void main(String[] args) {
    // String output;
    Ball BigBall = new Ball(5);
    JFrame frame1 = new JFrame();
    frame1.setTitle("Welcome to Ship!");
    frame1.setSize(300, 300);
    frame1.setLocation(200, 100);
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComboBox<String> box = new JComboBox<String>(new String[] {"Casey", "Connolly", "Nielson"});
    JPanel panel = new JPanel();
    panel.add(box);
    frame1.add(panel);
    frame1.setVisible(true);

    TV tv1 = new TV();
    tv1.turnOn();
    tv1.setChannel(30);
    tv1.setVolume(3);

    System.out.println(tv1.toString());
    Stack stacker = new Stack();

    for (int i = 0; i < 10; i++) stacker.push(i);
    while (!stacker.empty()) System.out.println(stacker.pop() + " ");

    System.out.println(BigBall.toString());
    System.out.println("Finished");
  }
  /**
   * Creates a new GraphicUI with the given title.
   *
   * @param title the title of the JFrame.
   */
  public GraphicUI(String title) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    f = new JFrame("BackgroundBorderExample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final Container cp = f.getContentPane();
    final JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    BufferedImage im =
        ResourceLoader.getResourceLoader().getBufferedImage(Values.MenuImages + "backsmall.jpg");
    Dimension size = new Dimension(im.getWidth(null), im.getHeight(null));
    f.setPreferredSize(size);
    f.setMinimumSize(size);
    f.setMaximumSize(size);
    f.setSize(size);
    final Border bkgrnd = new CentredBackgroundBorder(im);
    Runnable r =
        new Runnable() {
          public void run() {
            p.setBorder(bkgrnd);
            cp.repaint();
          }
        };
    SwingUtilities.invokeLater(r);
    readFile();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    p.add(createResolution(), BorderLayout.CENTER);
    p.add(createStartButton(), BorderLayout.SOUTH);

    cp.add(p);

    f.setLocationRelativeTo(null);
    f.pack();
    f.setVisible(true);
  }
  public static void main(String[] args) {

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JBubblePanel bubblePanel = new JBubblePanel();
    JTextPane textPane = new JTextPane();
    bubblePanel.setLayout(new BorderLayout());
    bubblePanel.add(textPane, BorderLayout.CENTER);

    Font normalFont = new Font("Arial", Font.PLAIN, 12);
    Font boldFont = new Font("Arial", Font.BOLD, 12);

    SimpleAttributeSet normal = new SimpleAttributeSet();
    SimpleAttributeSet bold = new SimpleAttributeSet();
    StyleConstants.setBold(bold, true);

    try {
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "Your connection to ", normal);
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "cvs.dev.java.net ", bold);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              "failed. Here are a few possible reasons.\n\n",
              normal);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              " Your computer is may not be connected to the network.\n"
                  + "* The CVS server name may be entered incorrectly.\n\n",
              normal);
      textPane
          .getDocument()
          .insertString(
              textPane.getDocument().getLength(),
              "If you still can not connect, please contact support at ",
              normal);
      textPane
          .getDocument()
          .insertString(textPane.getDocument().getLength(), "*****@*****.**", bold);
      textPane.getDocument().insertString(textPane.getDocument().getLength(), ".", normal);
    } catch (BadLocationException ex) {
      ex.printStackTrace();
    }

    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(bubblePanel, BorderLayout.CENTER);

    frame.setBounds(200, 300, 400, 360);
    frame.setVisible(true);
  }
Exemplo n.º 4
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setVisible(true);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);

    JButton btnCustomer = new JButton("Customer");
    btnCustomer.setFont(new Font("Tahoma", Font.BOLD, 16));
    btnCustomer.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JOptionPane.showMessageDialog(null, "Welcome to Coffee Kiosk ");
            // Coffee1 nw = new Coffee1();
            // nw.NewScreen();
            cust = cust + 1;
            Customer cs = new Customer();
            cs.CustomerScreen();
          }
        });
    btnCustomer.setBounds(83, 94, 117, 86);
    frame.getContentPane().add(btnCustomer);

    JButton btnAdmin = new JButton("Admin");
    btnAdmin.setFont(new Font("Tahoma", Font.BOLD, 16));
    btnAdmin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "Welcome Admin ");
            Login ls = new Login();
            ls.LoginScreen();
          }
        });

    btnAdmin.setBounds(229, 94, 117, 86);
    frame.getContentPane().add(btnAdmin);

    JButton btnExit = new JButton("EXIT");
    btnExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            JOptionPane.showMessageDialog(null, "Thank You for using Coffee Kiosk");
            System.exit(0);
          }
        });
    btnExit.setBounds(168, 207, 89, 23);
    frame.getContentPane().add(btnExit);

    JLabel lblLeedsCoffeeKiosk = new JLabel("LEEDS COFFEE KIOSK");
    lblLeedsCoffeeKiosk.setHorizontalAlignment(SwingConstants.CENTER);
    lblLeedsCoffeeKiosk.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 30));
    lblLeedsCoffeeKiosk.setForeground(new Color(148, 0, 211));
    lblLeedsCoffeeKiosk.setBounds(36, 11, 366, 72);
    frame.getContentPane().add(lblLeedsCoffeeKiosk);
  }
Exemplo n.º 5
0
  public static void main(String[] args) {

    JFrame frame = new JFrame();
    GameScreen gameScreen = new GameScreen();

    frame.setPreferredSize(new Dimension(1366, 768));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // frame.setUndecorated(true);
    // frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setResizable(false);
    frame.add(gameScreen);
    frame.pack();
    frame.setVisible(true);

    gameScreen.updateScreenSize();

    InputFlag.reset();

    while (true) {
      try {
        Thread.sleep((long) (1000f / GameScreen.FRAMERATE));
      } catch (InterruptedException e) {
      }

      gameScreen.update();
      gameScreen.repaint();

      InputFlag.clearTrigger();
    }
  }
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 public void createAndShowQueryManager() {
   mainFrame.setPreferredSize(new Dimension(770, 500));
   mainFrame.setLocation(400, 100);
   mainFrame.pack();
   mainFrame.setVisible(true);
   mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 }
Exemplo n.º 7
0
  /** @param args */
  public static void main(String[] args) {
    JFrame f = new JFrame("Test PCarte");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.setLayout(new FlowLayout()); // au lieu de BorderLayout par défaut
    f.getContentPane().setBackground(new Color(143, 143, 195));

    PTasDeCartes pt = new PTasDeCartes(new CTasDeCartes("tas", new CUsine()));
    PCarte pc1 = new PCarte("1D");
    pt.empiler(pc1);
    PCarte pc2 = new PCarte("8S");
    pt.empiler(pc2);
    PCarte pc3 = new PCarte("KH");
    pt.empiler(pc3);
    PCarte pc4 = new PCarte("3C");
    pt.empiler(pc4);

    // pt.depiler(pc1);

    // f.getContentPane().add(pt);
    f.setContentPane(pt);

    // f.pack(); // dimensionner le cadre
    f.setLocation(200, 100); // le positionner
    f.setVisible(true); // et le rendre visible
  }
Exemplo n.º 8
0
    public void actionPerformed(ActionEvent e) {
      if (DBRecordStat.totalVar > 0.0) {
        JFrame JFrameAUC = new JFrame("AUCs for each reader and modality");
        RefineryUtilities.centerFrameOnScreen(JFrameAUC);
        JFrameAUC.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        Object[] colNames = {
          "ReaderID", "AUC " + DBRecordStat.modalityA, "AUC " + DBRecordStat.modalityB
        };
        Object[][] rowContent = new String[(int) DBRecordStat.Nreader][3];
        int i = 0;
        for (String desc_temp : InputFile1.readerIDs.keySet()) {
          rowContent[i][0] = desc_temp;
          rowContent[i][1] = Double.toString(DBRecordStat.AUCs[i][0]);
          rowContent[i][2] = Double.toString(DBRecordStat.AUCs[i][1]);
          i++;
        }

        JTable tableAUC = new JTable(rowContent, colNames);
        JScrollPane scrollPaneAUC = new JScrollPane(tableAUC);
        JFrameAUC.add(scrollPaneAUC, BorderLayout.CENTER);
        JFrameAUC.setSize(600, 300);
        JFrameAUC.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(
            GUI.MRMCobject.getFrame(),
            "Pilot study data has not yet been analyzed.",
            "Error",
            JOptionPane.ERROR_MESSAGE);
      }
    }
Exemplo n.º 9
0
 public void setupFrame() {
   JFrame.setDefaultLookAndFeelDecorated(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLayout(new GridLayout(3, 2));
   frame.pack();
   frame.setVisible(true);
 }
Exemplo n.º 10
0
  public static void main(String[] args) {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser");
    addressBar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            browser.loadURL(addressBar.getText());
          }
        });

    JPanel addressPane = new JPanel(new BorderLayout());
    addressPane.add(new JLabel(" URL: "), BorderLayout.WEST);
    addressPane.add(addressBar, BorderLayout.CENTER);

    JFrame frame = new JFrame("JxBrowser - Hello World");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(addressPane, BorderLayout.NORTH);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.loadURL(addressBar.getText());
  }
Exemplo n.º 11
0
 public void display() {
   JFrame frame = new JFrame();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(widthPix, heightPix);
   frame.getContentPane().add(this);
   frame.setVisible(true);
 }
Exemplo n.º 12
0
  public static void main(String[] args) {

    // Desktop desk = new Desktop("Pham's Desktop", 2500, true,300, 750, 1000, true);
    Desktop desk = new Desktop("Dell", 2500, false, 15, 750, 1000, false);
    Cameras cam = new Cameras("Nikon", 500, false, 25, 550, true);
    Games game = new Games("Civilizations V", 29.99, true, 50, false, false);
    CD cd = new CD("Berzerk", 10, true, 200, "Eminem");
    TV tv = new TV("Panasonic", 2000, false, 12, 900, 70);
    Laptop lap = new Laptop("Alienware", 980, false, 13, 750, 500, false);
    Movies movie = new Movies("Shrek 2", 15, true, 50, true, "Comedy", 2007);

    FrysProducts.list.add(cam);
    FrysProducts.list.add(game);
    FrysProducts.list.add(cd);
    FrysProducts.list.add(desk);
    FrysProducts.list.add(tv);
    FrysProducts.list.add(lap);
    FrysProducts.list.add(movie);

    final JFrame frame = new JFrame("Fry's Electronics");
    frame.setSize(600, 600);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setLocation(400, 200);
    createGUI(frame);
    frame.setVisible(true);
  }
Exemplo n.º 13
0
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(1000, 700);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("Collision Effects Test - press any key to start");
    frame.setVisible(true);
    frame.setFocusable(true);
    frame.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent e) {
            start();
          }

          public void keyReleased(KeyEvent e) {}

          public void keyTyped(KeyEvent e) {}
        });
    frame.add(new CollisionEffectsTest());

    Ball ball = new Ball(200, 300, 3);
    ArrayList<Body> bodies = new ArrayList<Body>();
    bodies.add(new Body(500, 300, 150, Color.blue));
    level = new Level(ball, bodies, null, null, null, 5.0, 1.0);
    level.generateLevelData();
  }
Exemplo n.º 14
0
  public static void main(String[] args) {
    JFrame jf = new JFrame("Òƶ¯µÄÎÄ×Ö");
    final JPanel jp =
        new JPanel() {
          public void paint(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g2.setColor(Color.white);
            g2.fillRect(0, 0, 500, 400);
            g2.setColor(Color.black);
            g2.drawString("helloWorld", x, y);
          }
        };
    jp.addMouseMotionListener(
        new MouseMotionListener() {

          @Override
          public void mouseMoved(MouseEvent e) {}

          @Override
          public void mouseDragged(MouseEvent e) {
            // TODO Auto-generated method stub
            x = e.getX();
            y = e.getY();
            jp.repaint();
          }
        });
    jf.add(jp);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.setSize(500, 400);
    jf.setVisible(true);
  }
Exemplo n.º 15
0
 public JpgMini() {
   f = new JFrame();
   l = new JLabel();
   f.getContentPane().add(l);
   f.setSize(640, 480);
   f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 }
Exemplo n.º 16
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
Exemplo n.º 17
0
 /** @param args the command line arguments */
 public static void main(String[] args) {
   JFrame jf = new JFrame("DotPhysics");
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   jf.setSize(500, 300);
   jf.add(new DrawingPanel());
   jf.setVisible(true);
 }
Exemplo n.º 18
0
  /**
   * Constructs a new game.
   *
   * @param web <code>true</code> if this game is meant to be an applet (which can be played
   *     online), and <code>false</code> otherwise. Note: this doesn't work yet.
   */
  public Game() {
    Game.applet = false;
    canvas = new Canvas(this);
    solidShapes = Collections.newSetFromMap(new ConcurrentHashMap<Shape, Boolean>());
    allShapes = Collections.newSetFromMap(new ConcurrentHashMap<Shape, Boolean>());

    // TODO: sort out which data structures actually have to support concurrency
    layerContents = new ConcurrentHashMap<Integer, java.util.List<Shape>>();
    layers = new CopyOnWriteArrayList<Integer>();
    layerOf = new ConcurrentHashMap<Shape, Integer>();

    counters = new ArrayList<Counter>();

    Mouse mouse = new Mouse();
    if (applet) {
      addMouseMotionListener(mouse);
      addMouseListener(mouse);
      addKeyListener(new Keyboard());
    } else {
      frame = new JFrame();
      frame.addMouseMotionListener(mouse);
      frame.addMouseListener(mouse);
      frame.addKeyListener(new Keyboard());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    setDefaults();
  }
Exemplo n.º 19
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("MainForm");
   frame.setContentPane(new MainForm().panel1);
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Exemplo n.º 20
0
  @Override
  public void streamOpen() {
    if (isStreamOpen) {
      L.og("INTERNAL L ERROR: trying to re-open alreadyopen stream ");
      return;
    }

    logFrame = new JFrame("Logging Window");
    logArea = new JTextArea();
    logArea.setEditable(false);

    logFrame.setSize(width, height);
    logFrame.setResizable(false);
    logFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    JScrollPane logAreaScroller = new JScrollPane(logArea);
    logAreaScroller.setSize(logFrame.getSize());
    logAreaScroller.setPreferredSize(
        new Dimension((logFrame.getWidth() * 3) / 4, (logFrame.getHeight() * 3) / 4));

    logPanel.add(logAreaScroller);
    logFrame.getContentPane().add(logPanel);

    logFrame.setVisible(true);

    isStreamOpen = true;
  }
Exemplo n.º 21
0
  public void newframe() {
    JFrame frame = new JFrame("Cab Service ");
    frame.setSize(800, 600);

    frame.setVisible(true);
    // frame.setBackground(Color.CYAN);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton jb = new JButton("Set Name of Places ");
    jb.setBounds(100, 100, 20, 50);

    JPanel jp = new JPanel();
    jp.setBackground(Color.gray);
    jp.add(jb);
    frame.add(jp);
    JPanel jp1 = new JPanel();
    jp1.setBackground(Color.gray);
    frame.add(jp1);

    frame.add(jp);
    jb.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            try {
              CreateFrame();

            } catch (IOException ex) {
              Logger.getLogger(SetMap.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
  }
Exemplo n.º 22
0
  private void create() {
    JFrame f = new JFrame("JSplitPane");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MyPanel p1 = new MyPanel(Color.red);
    MyPanel p2 = new MyPanel(Color.blue);
    final JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, p1, p2);
    Timer timer =
        new Timer(
            200,
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                ratio += delta;
                if (ratio >= 1.0) {
                  ratio = 1.0;
                  delta = -delta;
                } else if (ratio <= 0) {
                  delta = -delta;
                  ratio = 0;
                }
                jsp.setDividerLocation(ratio);
              }
            });

    f.add(jsp);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    timer.start();
  }
Exemplo n.º 23
0
  private void initWindow() {
    window.setIconImage(fsuicon);
    window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    window.setResizable(false);
    window.setLocation(400, 400);
    window.setSize(400, 600);
    window.setLayout(null);
    window.add(mainPanel);
    mainPanel.setSize(395, 570);
    mainPanel.setLayout(null);
    mainPanel.setBackground(garnet);
    mainPanel.setBorder(BorderFactory.createLineBorder(gold, 10));

    logoLBL = new JLabel(new ImageIcon(fsutitle));
    setJLabel(logoLBL, 372, 35, 10, 30);

    nameLBL = new JLabel(new ImageIcon(nametitle));
    nameLBL.setBorder(BorderFactory.createLineBorder(gold, 5));
    setJLabel(nameLBL, 400, 55, 0, 510);

    p1Stats = new JLabel();
    setJLabel(p1Stats, 150, 50, 20, 470);

    p2Stats = new JLabel();
    setJLabel(p2Stats, 150, 50, 225, 470);

    buildGridPanel();
    buildMenuPanel();
  }
  /**
   * Cria a interface grafica para o teste
   *
   * @param jLayerPausable objeto para o teste
   */
  public static void interfaceGrafica(JLayerPausableTest jLayerPausable) {
    JFrame frame = new JFrame("Test JlayerPlayerPausable");

    JButton buttonPlay = new JButton("Play");
    JButton buttonPause = new JButton("Pause");
    JButton buttonStop = new JButton("Stop");
    JPanel panel = new JPanel(new GridBagLayout());

    panel.add(buttonPlay);
    panel.add(buttonPause);
    panel.add(buttonStop);

    buttonPlay.addActionListener(new ButtonListener(jLayerPausable));
    buttonPause.addActionListener(new ButtonListener(jLayerPausable));
    buttonStop.addActionListener(new ButtonListener(jLayerPausable));

    frame.add(panel);

    frame.setPreferredSize(new Dimension(200, 100));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);

    frame.setVisible(true);
  }
Exemplo n.º 25
0
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
 public static void main(final String[] args) {
   JFrame frame = new JFrame("Credit calculator");
   frame.setContentPane(new HypothecCalculator().mainPanel);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
  public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 600);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.setDownloadHandler(
        new DownloadHandler() {
          public boolean allowDownload(DownloadItem download) {
            download.addDownloadListener(
                new DownloadListener() {
                  public void onDownloadUpdated(DownloadEvent event) {
                    DownloadItem download = event.getDownloadItem();
                    if (download.isCompleted()) {
                      System.out.println("Download is completed!");
                    }
                  }
                });
            System.out.println(
                "Destination file: " + download.getDestinationFile().getAbsolutePath());
            return true;
          }
        });

    browser.loadURL("ftp://ftp.teamdev.com/updates/jxbrowser-4.0-beta.zip");
  }
Exemplo n.º 28
0
 public static void panelInit() {
   JFrame frame = new JFrame("Test");
   frame.setContentPane(new Test().mainPanel);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Exemplo n.º 29
0
  public static void main(String[] args) {
    JFrame frame = new JFrame();

    // Set the size to whatever size you like (width, height)
    // For projects you turn in, lets not get any bigger than 640,480

    frame.setSize(640, 480); // @@@ MODIFY THIS LINE IF YOU LIKE

    // Set your own title
    frame.setTitle("Phill's Drawing"); // @@@ MODIFY THIS LINE

    // Always do this so that the red X (or red circle) works
    // to close the window.

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Instantiate your drawing as a "component"

    PictureComponent component = new PictureComponent();

    // Always add your component to the frame
    // and then make the window visible

    frame.add(component);
    frame.setVisible(true);
  }
Exemplo n.º 30
0
    public void textual() {
      if (!isVisible()) return;
      // create jeditorpane
      JEditorPane jEditorPane = new JEditorPane();

      // make it read-only
      jEditorPane.setEditable(false);

      // create a scrollpane; modify its attributes as desired
      JScrollPane scrollPane = new JScrollPane(jEditorPane);

      // add an html editor kit
      HTMLEditorKit kit = new HTMLEditorKit();
      jEditorPane.setEditorKit(kit);
      Document doc = kit.createDefaultDocument();
      jEditorPane.setDocument(doc);
      jEditorPane.setText(floater.getText());

      // now add it all to a frame
      JFrame j = new JFrame("Read information");
      j.getContentPane().add(scrollPane, BorderLayout.CENTER);

      // make it easy to close the application
      j.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      // display the frame
      j.setSize(new Dimension(300, 200));

      // pack it, if you prefer
      // j.pack();

      // center the jframe, then make it visible
      j.setLocationRelativeTo(null);
      j.setVisible(true);
    }