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);
  }
Example #2
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);
            }
          }
        });
  }
  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);
  }
Example #4
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
  }
  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");
  }
Example #6
0
  /** GUIコンポーネントを初期化する。 */
  public void initComponent() {

    frame = new JFrame(ClientContext.getFrameTitle(title));
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            stop();
          }
        });

    JPanel contentPane = createBrowsePane();
    contentPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));

    contentPane.setOpaque(true);
    frame.setContentPane(contentPane);
    frame.pack();

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int n = ClientContext.isMac() ? 3 : 2;
    int x = (screen.width - frame.getPreferredSize().width) / 2;
    int y = (screen.height - frame.getPreferredSize().height) / n;
    frame.setLocation(x, y);

    blockGlass = new BlockGlass();
    frame.setGlassPane(blockGlass);

    frame.setVisible(true);
  }
Example #7
0
 public RemoveFrame() {
   frame = new JFrame("Select Files you wish to Remove from Drive");
   frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   frame.getRootPane().setDefaultButton(confirm);
   try {
     files = DriveList.list();
   } catch (IOException e) {
     files = new ArrayList<File>();
   }
   confirm = new JButton("Remove");
   quit = new JButton("Cancel");
   confirm.addActionListener(this);
   quit.addActionListener(this);
   frame.setLayout(new BorderLayout());
   checkPanel = new JPanel();
   control = new JPanel();
   control.setLayout(new GridLayout(1, 2));
   control.add(confirm);
   control.add(quit);
   frame.add(control, BorderLayout.SOUTH);
   drawCheckPanel();
   frame.add(checkPanel, BorderLayout.CENTER);
   frame.pack();
   frame.setVisible(true);
 }
 public static void main(String[] args) {
   JFrame frame = new JFrame();
   frame.add(new JDemoFontMetrics());
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(300, 460);
   frame.setVisible(true);
 }
  public static void main(String[] args) {

    StringBuffer result = new StringBuffer("<html><body><h1>Fibonacci Sequence</h1><ol>");

    long f1 = 0;
    long f2 = 1;

    for (int i = 0; i < 50; i++) {
      result.append("<li>");
      result.append(f1);
      long temp = f2;
      f2 = f1 + f2;
      f1 = temp;
    }

    result.append("</ol></body></html>");

    JEditorPane jep = new JEditorPane("text/html", result.toString());
    jep.setEditable(false);

    //  new FibonocciRectangles().execute();
    JScrollPane scrollPane = new JScrollPane(jep);
    JFrame f = new JFrame("Fibonacci Sequence");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    f.setContentPane(scrollPane);
    f.setSize(512, 342);
    EventQueue.invokeLater(new FrameShower(f));
  }
 public void create() {
   JFrame frame = new JFrame();
   frame.getContentPane().add(new JScrollPane(jgraph));
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
  // -------------------------------------------------------------------
  public static void main(String[] args) {
    // Create the window
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(new Dimension(300, 100));
    frame.setTitle("A frame");
    frame.setLayout(new FlowLayout()); // This will be discuss in the next lesson

    // Create and add the first button
    JButton button1 = new JButton();
    button1.setText("I'm a button.");
    button1.setBackground(Color.BLUE);
    frame.add(button1);

    // Create and add the second button
    JButton button2 = new JButton();
    button2.setText("Click me!");
    button2.setBackground(Color.RED);
    frame.add(button2);

    // Reset the sizes of the buttons and window
    frame.pack();

    // Actually put the window on the screen and draw all its components
    frame.setVisible(true);
  }
 public static void main(String[] args) {
   JFrame frame = new JFrame("startbooking1");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.getContentPane().add(new startbooking1());
   frame.pack();
   frame.setVisible(true);
 }
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame
        .getContentPane()
        .setLayout(
            new FormLayout(
                new ColumnSpec[] {
                  FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                  ColumnSpec.decode("default:grow"),
                  FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                },
                new RowSpec[] {
                  FormFactory.RELATED_GAP_ROWSPEC,
                  RowSpec.decode("default:grow"),
                  FormFactory.LINE_GAP_ROWSPEC,
                  RowSpec.decode("default:grow"),
                  FormFactory.LINE_GAP_ROWSPEC,
                }));

    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, "2, 2, fill, fill");

    openDialog = new FileDialog(this, "Open File", FileDialog.LOAD);

    JButton btnCharger = new JButton("Charger une partie");
    btnCharger.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            openDialog.setVisible(true);
            try {
              String dir = openDialog.getDirectory() + openDialog.getFile();
              Utilitaire.writeln(dir, textArea);
              jeu = new Kakuro(frame, dir);
              jeu.setVisible(true);
            } catch (NullPointerException point) {

            }
          }
        });
    panel.add(btnCharger);

    JButton btnNvlPartie = new JButton("Nouvelle Partie");
    panel.add(btnNvlPartie);
    btnNvlPartie.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            Random list = new Random();
            int seed = list.nextInt();
            new Utilitaire(Utilitaire.x, Utilitaire.y, seed);
            jeu = new Kakuro(frame);
            jeu.setVisible(true);
          }
        });

    textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    frame.getContentPane().add(scrollPane, "2, 4, fill, fill");
  }
Example #14
0
  private MainPanel(final JFrame frame) {
    super();
    add(check);
    setPreferredSize(new Dimension(320, 240));

    if (!SystemTray.isSupported()) {
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      return;
    }
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowIconified(WindowEvent e) {
            if (check.isSelected()) {
              e.getWindow().dispose();
            }
          }
        });
    // or
    // frame.addWindowStateListener(new WindowStateListener() {
    //    @Override public void windowStateChanged(WindowEvent e) {
    //        if (check.isSelected() && e.getNewState() == Frame.ICONIFIED) {
    //            e.getWindow().dispose();
    //        }
    //    }
    // });

    final SystemTray tray = SystemTray.getSystemTray();
    Dimension d = tray.getTrayIconSize();
    BufferedImage image = makeBufferedImage(new StarIcon(), d.width, d.height);
    final PopupMenu popup = new PopupMenu();
    final TrayIcon icon = new TrayIcon(image, "TRAY", popup);

    MenuItem item1 = new MenuItem("OPEN");
    item1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            frame.setVisible(true);
          }
        });
    MenuItem item2 = new MenuItem("EXIT");
    item2.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            tray.remove(icon);
            frame.dispose();
            // frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
          }
        });
    popup.add(item1);
    popup.add(item2);

    try {
      tray.add(icon);
    } catch (AWTException e) {
      e.printStackTrace();
    }
  }
  public static void main(String[] args) {
    JFrame frame = new JFrame("Add");
    frame.setLocation(500, 400);
    //		frame.setPreferredSize(new Dimension(250, 100));
    Container contentPane = frame.getContentPane();

    FlowLayout layout = new FlowLayout();
    contentPane.setLayout(layout);
    JPanel panel = new JPanel();
    panel.add(new JTextField(6));
    panel.add(new JLabel("+"));
    panel.add(new JTextField(6));
    panel.add(new JLabel("="));
    panel.add(new JTextField(6));

    contentPane.add(panel, BorderLayout.CENTER);

    JPanel panel2 = new JPanel();
    panel2.add(new JButton("확인"));
    panel2.add(new JButton("취소"));
    contentPane.add(panel2, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
Example #16
0
  /**
   * Init JWhiteBoard interface
   *
   * @throws Exception
   */
  public void go() throws Exception {
    if (!noChannel && !useState) channel.connect(groupName);
    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    drawPanel = new DrawPanel(useState);
    drawPanel.setBackground(backgroundColor);
    subPanel = new JPanel();
    mainFrame.getContentPane().add("Center", drawPanel);
    clearButton = new JButton("Clean");
    clearButton.setFont(defaultFont);
    clearButton.addActionListener(this);
    leaveButton = new JButton("Exit");
    leaveButton.setFont(defaultFont);
    leaveButton.addActionListener(this);
    subPanel.add("South", clearButton);
    subPanel.add("South", leaveButton);
    mainFrame.getContentPane().add("South", subPanel);
    mainFrame.setBackground(backgroundColor);
    clearButton.setForeground(Color.blue);
    leaveButton.setForeground(Color.blue);
    mainFrame.pack();
    mainFrame.setLocation(15, 25);
    mainFrame.setBounds(new Rectangle(250, 250));

    if (!noChannel && useState) {
      channel.connect(groupName, null, stateTimeout);
    }
    mainFrame.setVisible(true);
  }
Example #17
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Maze View");

    Random random = new Random();
    long startTime = System.nanoTime();
    MazeNode maze = MazeNode.generate(random, 100, 100);
    System.out.println("Gen : " + elapsedMs(startTime) + "ms");

    startTime = System.nanoTime();
    int sx = 0; // random.nextInt(maze.width);
    int sy = 0; // random.nextInt(maze.height);
    int dx = maze.width - 1; // random.nextInt(maze.width);
    int dy = maze.height - 1; // random.nextInt(maze.height);
    Path path = PathSolver.solve(maze, sx, sy, dx, dy);
    System.out.println("Solve : " + elapsedMs(startTime) + "ms");
    int pathSize = 0;
    PathCell pathIt = path.first;
    while (pathIt != null) {
      pathSize++;
      pathIt = pathIt.next;
    }
    System.out.println("Path Size: " + pathSize);

    frame.add(new JScrollPane(new MazeView(maze, sx, sy, dx, dy, path)));

    frame.setSize(500, 500);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    SwingUtilities.invokeLater(() -> frame.setVisible(true));
  }
Example #18
0
  private Game() {
    // Top-level frame
    final JFrame frame = new JFrame("Falling Blocks");
    frame.setLocation(200, 50);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Main playing area
    final TetrisCourt court = new TetrisCourt();
    frame.add(court, BorderLayout.CENTER);

    // Reset button
    final JPanel panel = new JPanel();
    frame.add(panel, BorderLayout.NORTH);
    final JButton reset = new JButton("Reset");
    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            court.reset();
          }
        });

    panel.add(reset);

    // Put the frame on the screen
    frame.pack();
    frame.setVisible(true);
    // Start the game running
    court.reset();
  }
 public static void main(String[] args) {
   JFrame win = new JFrame("MouseMotionEvents");
   win.setSize(1024, 768);
   win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   win.add(new MouseMotionEvents());
   win.setVisible(true);
 }
Example #20
0
  public static void main(String[] args) {
    Toolkit theKit = aWindow.getToolkit(); // Get the window Toolkit
    Dimension wndSize = theKit.getScreenSize(); // Get the screen size

    // Set the position to screen center & size to half screen size
    aWindow.setBounds(
        wndSize.width / 4,
        wndSize.height / 4, // Position
        wndSize.width / 2,
        wndSize.height / 2); // Size
    aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    GridLayout grid = new GridLayout(5, 2, 30, 20); // Create a layout manager
    Container content = aWindow.getContentPane();
    content.setLayout(grid);

    EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border

    // Now add ten Button compenents
    JButton button;
    for (int i = 1; i <= 10; i++) {
      content.add(button = new JButton("Press " + i));
      button.setBorder(edge);
    }

    aWindow.getContentPane().setBackground(new Color(238, 233, 233));
    aWindow.setVisible(true);
  }
 public static void main(String[] args) {
   JFrame gameWindow = new JFrame("Tic Tac Toe");
   gameWindow.add(new TicTacToeGame());
   gameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   gameWindow.pack();
   gameWindow.setVisible(true);
 }
Example #22
0
 public void setUpGui() {
   m1 = new MyDrawPanel();
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.setContentPane(m1);
   f.setBounds(30, 30, 300, 300);
   f.setVisible(true);
 } // quit meth
Example #23
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();
  }
Example #24
0
  public SchiebePuzzle() {
    JFrame jF = new JFrame("Misc_2015/SchiebePuzzle");
    jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jF.setLayout(new GridLayout(YY, XX)); // ggf zu ändern
    try {
      BufferedImage fuYou = ImageIO.read(new File("fuYou.jpg"));
      int w = fuYou.getWidth();
      int h = fuYou.getHeight();
      for (int y = 0; y < YY; y++)
        for (int x = 0; x < XX; x++) {
          buttons[y][x] =
              new PuzzButton(
                  new ImageIcon(fuYou.getSubimage(x * (w / XX), y * (h / YY), w / XX, h / YY)));

          buttons[y][x].setBorder(new LineBorder(Color.BLACK, 1));
          buttons[y][x].setActionCommand("" + x + y);
          buttons[y][x].setName("" + x + y);
          buttons[y][x].setPosY(y);
          buttons[y][x].setPosX(x);
          buttons[y][x].addActionListener(this);
          jF.add(buttons[y][x]);
        }

    } catch (IOException e) {
      System.out.println("Bild nicht gefunden!");
    }

    jF.pack();
    jF.setVisible(true);
  }
Example #25
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();
  }
Example #26
0
  void makeFrame() {
    JPanel p = new JPanel();
    p.setBackground(Color.blue);
    p.setLayout(new BorderLayout(0, 0));
    p.setBorder(new EmptyBorder(0, GAP, GAP, GAP));
    days.setFont(BIG);
    days.setForeground(COLOR);
    p.add(days, "North");
    left.setFont(NORM);
    left.setForeground(COLOR);
    p.add(left, "South");

    JFrame f = new JFrame("Sayaç"); // a window
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setContentPane(p);
    setDate();
    f.pack(); // minimal size
    f.setVisible(true); // show

    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            stop();
          }
        });
  }
Example #27
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());
  }
Example #28
0
  /**
   * This method starts the GUI.
   *
   * @throws CoapException Thrown, if the connection to obix via CoAP fails.
   */
  public void runGui() throws CoapException {
    this.lobby = obixChannel.getLobby(obixChannel.getLobbyUri());
    // Create and set up the window.
    mainFrame =
        new JFrame("ObixConnector at " + obixChannel.getBaseUri() + ": " + obixChannel.getPort());
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setUndecorated(false);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            close();
          }
        });

    Container contentPane = mainFrame.getContentPane();

    // Create and set up the content pane.
    this.addComponentToPane(contentPane);

    // Display the window.
    mainFrame.pack();
    executor.execute(updateThread);
    connector.addRunAndStopAble(updateThread);
    mainFrame.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);
 }
Example #30
0
  public ObserverPattern() {
    root = null;
    // window = new JFrame();
    width = 400;
    height = 400;

    window = new JFrame("New Window");
    // controllwin =  new JFrame("Controll");
    // controllwin.setLayout(new FlowLayout());
    JButton b = new JButton("Értéket ad");
    tf = new JTextField();

    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // controlwindow.removeAll();
            if (!ertad()) {
              tf.setText("Nem megfelelo parameter!!");
            }
          }
        });

    /*controllwin.add(tf);
    controllwin.add(b);
    controllwin.setSize(100,50);
    controllwin.setVisible(true);
    controllwin.pack();*/

    window.setLayout(new FlowLayout());
    window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    window.setSize(width, height);
    window.setVisible(true);
  }