예제 #1
0
  public void pdfRead() {
    try {
      String INPUTFILE = "example_2.pdf";
      File file = new File(INPUTFILE);
      RandomAccessFile raf = new RandomAccessFile(file, "r");
      FileChannel channel = raf.getChannel();
      ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
      PDFFile pdffile = new PDFFile(buf);

      // draw the first page to an image
      PDFPage page = pdffile.getPage(0);

      // get the width and height for the doc at the default zoom
      Rectangle rect =
          new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());

      // generate the image
      Image img =
          page.getImage(
              rect.width,
              rect.height, // width & height
              rect, // clip rect
              null, // null for the ImageObserver
              true, // fill background with white
              true // block until drawing is done
              );

      frame.getContentPane().add(new JLabel(new ImageIcon(img)));

      frame.pack();
      frame.setSize(600, 700);
    } catch (Exception e) {
      System.out.println(e);
    }
  }
  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));
  }
예제 #3
0
  // Initialize all the GUI components and display the frame
  private static void initGUI() {
    // Set up the status bar
    statusField = new JLabel();
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1);
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);

    // Set up the options pane
    JPanel optionsPane = initOptionsPane();

    // Set up the chat pane
    JPanel chatPane = new JPanel(new BorderLayout());
    chatText = new JTextArea(10, 20);
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane =
        new JScrollPane(
            chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField();
    chatLine.setEnabled(false);
    chatLine.addActionListener(
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            String s = chatLine.getText();
            if (!s.equals("")) {
              appendToChatBox("OUTGOING: " + s + "\n");
              chatLine.selectAll();

              // Send the string
              sendString(s);
            }
          }
        });
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.CENTER);
    chatPane.setPreferredSize(new Dimension(200, 200));

    // Set up the main pane
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);

    // Set up the main frame
    mainFrame = new JFrame("Simple TCP Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
    mainFrame.setLocation(200, 200);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
예제 #4
0
파일: test.java 프로젝트: Recoskie/3D
 public void Window() {
   JFrame f = new JFrame("test");
   f.setSize(570, 383);
   f.add(new test());
   f.setLocationRelativeTo(null);
   f.setResizable(false);
   f.setVisible(true);
 }
예제 #5
0
 public static void main(String args[]) {
   JFrame frame = new CopyFileToTable();
   frame.setTitle("CopyFileToTable");
   frame.setSize(700, 200);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #6
0
파일: Chart.java 프로젝트: feihugis/NetCDF
  public static void main(String[] args) {
    Chart shc = new Chart("C:/TEMP/table.csv");

    JFrame frame = new JFrame("Stock History Chart for " + shc.getSymbol());
    frame.getContentPane().add(shc, BorderLayout.CENTER);
    frame.setSize(640, 480);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
예제 #7
0
 /**
  * This method creates a JFrame where everything will be displayed INPUT (parameters): none OUTOUT
  * (return): none
  */
 public static void createAndShowGUI() {
   JFrame frame =
       new JFrame("Black Jack"); // title of the JFrame
   BlackJack demo = new BlackJack(); // create and set up the content pane
   frame.setContentPane(demo.createContentPane());
   frame.setDefaultCloseOperation(
       JFrame.EXIT_ON_CLOSE); // what happens if the user presses the x button
   frame.setSize(950, 760);
   frame.setVisible(true); // ensure frame is visible
 }
예제 #8
0
  /* Create and show the graphical user interface. */
  private static void createAndShowGUI() {
    JFrame frame = new JFrame("My Collapsing Puzzle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Game game = new Game();
    frame.setJMenuBar(game.createMenuBar());
    frame.setContentPane(game.createContentPane());
    frame.setSize(game.getGameSize());

    frame.setVisible(true);
  }
예제 #9
0
  public ArcViewer() {

    JFrame frame = new JFrame("ArcViewer v.0.9");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    frame.add("Center", this);
    frame.setSize(900, 600);
    frame.setVisible(true);

    init();
  }
예제 #10
0
 public void actionPerformed(ActionEvent e) {
   if (!datapanel.isInitialized()) {
     return;
   }
   datapanel.refreshData();
   panel.setDisplayPlot(true);
   panel.update(panel.getGraphics());
   frame.setSize(700, 600);
   frame.setVisible(true);
   frame.pack();
 }
예제 #11
0
  private void initialize() {
    frame = new JFrame();
    frame.setSize(600, 700);
    //		frame.getContentPane().setLayout(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //		frame.setResizable(false);
    frame.setTitle("PDF");
    //		frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    //        frame.pack();

  }
예제 #12
0
 /** This method sets up the window and displays it. */
 private void setupFrame() {
   JFrame window = new JFrame("Dungeon of Dooom");
   window.setIconImage(Toolkit.getDefaultToolkit().getImage("graphics/icon.png"));
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   populateFrame(window.getContentPane());
   window.pack();
   window.setLocationByPlatform(true);
   window.setVisible(true);
   Dimension windowSize = new Dimension(608, 606);
   window.setSize(windowSize);
   window.setResizable(false);
 }
예제 #13
0
 private void initMinFrame() {
   minFrame = new JFrame("Sikuli Test");
   minFrame.setAlwaysOnTop(true);
   minFrame.setSize(255, 85);
   minFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.7f));
   /*
   Container con = minFrame.getContentPane();
   con.add(minPane);
   minFrame.doLayout();
   minFrame.setVisible(true);
   */
 }
예제 #14
0
 public void go() {
   JFrame frame = new JFrame("JFrame");
   JPanel mainPanel = new JPanel();
   outgoing = new JTextField(20);
   JButton sendButton = new JButton("send");
   sendButton.addActionListener(new SendButtonListener());
   mainPanel.add(outgoing);
   mainPanel.add(sendButton);
   frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
   setUpNetworking();
   frame.setSize(400, 500);
   frame.setVisible(true);
 }
예제 #15
0
 // --------初始化界面的方法---------
 public void init() {
   JPanel top = new JPanel();
   top.add(new JLabel("输入查询语句:"));
   top.add(sqlField);
   top.add(execBn);
   // 为执行按钮、单行文本框添加事件监听器
   execBn.addActionListener(new ExceListener());
   sqlField.addActionListener(new ExceListener());
   jf.add(top, BorderLayout.NORTH);
   jf.setSize(680, 480);
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   jf.setVisible(true);
 }
예제 #16
0
  // Create the GUI and show it.  For thread safety, this method should be invoked from the
  // event-dispatching thread.
  private static void CreateAndShowGUI() {
    // Create and set up the window.
    mainframe = new JFrame("No Drawbot Connected");
    mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    DrawbotGUI demo = DrawbotGUI.getSingleton();
    mainframe.setJMenuBar(demo.CreateMenuBar());
    mainframe.setContentPane(demo.CreateContentPane());

    // Display the window.
    mainframe.setSize(800, 700);
    mainframe.setVisible(true);
  }
예제 #17
0
  /** Create the entire GUI from scratch */
  private void createGUI() {

    clientFrame = new JFrame("LeetFTP");

    // Allow program to exit gracefully

    clientFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    createTabs();
    createMenu();

    // Top Options Bar
    connectButton = new JButton("Connect");
    connectButton.addMouseListener(mouseHandler);

    optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    optionPanel.add(connectButton);
    optionPanel.add(new JLabel("Name Server Hostname"));
    optionPanel.add(serverTextField);
    optionPanel.add(new JLabel("Port #"));
    optionPanel.add(portTextField);
    optionPanel.add(new JLabel("UserName"));
    optionPanel.add(nameTextField);

    // Bottom Transfer Table

    transferTable = new JTable();
    transferPanel = new JPanel(new BorderLayout());
    transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH);
    transferPanel.add(transferTable);

    // Make the tab pane the GUI pane
    clientFrame.getContentPane().setLayout(new BorderLayout());
    clientFrame.getContentPane().add(mainPanel);
    clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH);
    clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH);

    // Set Client Window Properties
    clientFrame.setSize(800, 600);
    // clientFrame.setResizable(false);
    clientFrame.setLocationRelativeTo(null);
    clientFrame.setVisible(true);
  }
예제 #18
0
  public Fenetre() {

    frame = new JFrame();
    frame.setTitle("Gestion Sauvegarde Serveur");
    frame.setSize(700, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setIconImage(
        Toolkit.getDefaultToolkit().getImage(getClass().getResource("/go-home.png")));
    frame.setResizable(true);
    frame.setLocationRelativeTo(null);
    frame.setUndecorated(false);
    frame.setBackground(Color.white);
    frame.setContentPane(contentPane());
    frame.setVisible(true);
  }
예제 #19
0
 public static void main(String[] args) {
   TableModelDemo applet = new TableModelDemo();
   JFrame frame = new JFrame();
   // EXIT_ON_CLOSE == 3
   frame.setDefaultCloseOperation(3);
   frame.setTitle("TableModelDemo");
   frame.getContentPane().add(applet, BorderLayout.CENTER);
   applet.init();
   applet.start();
   frame.setSize(500, 220);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   frame.setLocation(
       (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
   frame.setVisible(true);
 }
 /** Creates the JFrame that will contain everything. */
 protected JFrame createFrame() {
   JFrame retFrame = new JFrame("TreeTable III -- " + path);
   Dimension dimension = new Dimension(600, 400);
   retFrame.setSize(600, 600);
   retFrame.setMinimumSize(dimension);
   retFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           frame.dispose();
           if (--ttCount == 0) {
             System.exit(0);
           }
         }
       });
   return retFrame;
 }
  public void init() {
    frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("PersistentFrameTest");
    frame.setSize(400, 200);

    JButton loadButton = new JButton("Load");
    frame.add(loadButton);
    loadButton.addActionListener(EventHandler.create(ActionListener.class, this, "load"));

    JButton saveButton = new JButton("Save");
    frame.add(saveButton);
    saveButton.addActionListener(EventHandler.create(ActionListener.class, this, "save"));

    frame.setVisible(true);
  }
예제 #22
0
 @Override
 public void actionPerformed(ActionEvent event) {
   JFrame frame = new JFrame();
   frame.setTitle(
       "The current best solution for " + optimizationParameters.getProblem().getName());
   frame.setSize(400, 300);
   frame.setLocation(450, 250);
   Population pop = optimizationParameters.getOptimizer().getPopulation();
   frame
       .getContentPane()
       .add(
           optimizationParameters
               .getProblem()
               .drawIndividual(
                   pop.getGeneration(), pop.getFunctionCalls(), pop.getBestEAIndividual()));
   frame.validate();
   frame.setVisible(true);
 }
예제 #23
0
 public BSInterface() {
   mainFrame.setSize(960, 720);
   mainFrame.setResizable(false);
   mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage("pic/ticket_16.png"));
   Container contentPane = mainFrame.getContentPane();
   contentPane.setLayout(new BorderLayout());
   contentPane.add(toolPanel, BorderLayout.NORTH);
   contentPane.add(operPanel, BorderLayout.CENTER);
   mainFrame.setContentPane(contentPane);
   mainFrame.setVisible(true);
   mainFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           // device_close();
           System.exit(0);
         }
       });
 }
예제 #24
0
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      // UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
      // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
      // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception ex) {
      System.err.println(ex);
    }

    JFrame frame = new JFrame("E+ idf TextPanel test");
    frame.getContentPane().add(new EPlusEditorPanel());
    // frame.getContentPane().add(new EPlusTextPanel (null, null, 1, null, null, null));
    frame.setSize(800, 800);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
 public static void main(String s[]) {
   if (s.length > 0) j2kfilename = s[0];
   else j2kfilename = "girl";
   System.out.println(j2kfilename);
   isApplet = false;
   JFrame f = new JFrame("ImageViewer");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   JApplet applet = new ImageViewer();
   f.getContentPane().add("Center", applet);
   applet.init();
   f.pack();
   f.setSize(new Dimension(550, 550));
   f.show();
 }
예제 #26
0
  JFrame openMonitorGUI(String title) {
    try {
      MonitorGUI gui = new MonitorGUI(this, title);

      JFrame frame = new JFrame(title);
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      frame.addWindowListener(this);
      frame.getContentPane().add(gui);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Rectangle r = ge.getMaximumWindowBounds();
      frame.setSize(400, 200);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
      return frame;
    } catch (Exception e) {
      System.out.println("9\b" + getClass().getName() + "\n\t" + e);
      return null;
    }
  }
예제 #27
0
  public static void main(String args[]) throws Exception {

    JFrame ventana = new JFrame("Image");
    // int k=5;
    String n;
    int c[] = new int[9];

    n = "C:\\BORLANDC\\BIN\\CIMG1098.jpg";

    // n[1]="C:\\BORLANDC\\BIN\\sd";

    ventana.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    ventana.getContentPane().add(new erosion(n), BorderLayout.CENTER);

    ventana.setSize(1000, 1000);

    ventana.setVisible(true);

    /*  ventana.addWindowListener( new WindowAdapter() {
         public void windowClosing( WindowEvent evt ){
    System.exit( 0 );
         }
       } );
       ventana.getContentPane().add( new GetImage(),BorderLayout.CENTER );
       ventana.setSize( 500,500 );

       ventana.setVisible( true );

    /*
    GetImage image = new GetImage();
       image.setSize(400, 340);
       image.setVisible(true);
       image.setLocation(200, 100);*/
  }
예제 #28
0
  public void hacerInterfaz() {
    ventana_chat = new JFrame("Cliente");
    btn_enviar = new JButton("Enviar");
    txt_mensaje = new JTextField(4);
    area_chat = new JTextArea(10, 17);
    scroll = new JScrollPane(area_chat);
    contenedor_areachat = new JPanel();
    contenedor_areachat.setLayout(new GridLayout(1, 1));
    contenedor_areachat.add(scroll);
    contenedor_btntxt = new JPanel();
    contenedor_btntxt.setLayout(new GridLayout(1, 2));
    contenedor_btntxt.add(txt_mensaje);
    contenedor_btntxt.add(btn_enviar);
    ventana_chat.setLayout(new BorderLayout());
    ventana_chat.add(contenedor_areachat, BorderLayout.NORTH);
    ventana_chat.add(contenedor_btntxt, BorderLayout.SOUTH);
    ventana_chat.setSize(300, 220);
    ventana_chat.setVisible(true);
    ventana_chat.setResizable(false);
    ventana_chat.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Thread principal =
        new Thread(
            new Runnable() {
              public void run() {
                try {
                  socket = new Socket("localhost", 8000);
                  leer();
                  escribir();
                } catch (Exception ex) {
                  ex.printStackTrace();
                }
              }
            });
    principal.start();
  }
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }
예제 #30
-1
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }