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"); }
/** Demo. */ public static void main(String[] args) { try { JFrame frame = new JFrame("Panner"); JPanel p = (JPanel) frame.getContentPane(); URL url = PannerHandler.class.getResource("desert.jpg"); String key = System.getProperty("os.name").toLowerCase().indexOf("mac") != -1 ? "\u2318" : "control"; JLabel label = new JLabel("Press " + key + "+shift to display panner, click/drag to navigate"); label.setBorder(new EmptyBorder(4, 4, 4, 4)); p.add(label, BorderLayout.NORTH); JLabel image = new JLabel(new ImageIcon(url)); image.setFocusable(true); PannerHandler handler = new PannerHandler(image, 95, new Point(0, 0)); image.putClientProperty("panner", handler); p.add(new JScrollPane(image)); frame.pack(); Dimension size = image.getPreferredSize(); size.width /= 2; size.height /= 2; Dimension ssize = frame.getToolkit().getScreenSize(); frame.setLocation((ssize.width - size.width) / 2, (ssize.height - size.height) / 2); frame.setSize(size); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); image.requestFocus(); } catch (Exception e) { e.printStackTrace(); } }
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(); }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void createAndShowQueryManager() { mainFrame.setPreferredSize(new Dimension(770, 500)); mainFrame.setLocation(400, 100); mainFrame.pack(); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
/** @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 }
private static void showOnScreen(int screen, JFrame frame, boolean fullscreen) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); if (!Main.protection || (screen > -1 && screen < gd.length)) { if (!Main.protection || (fullscreen && screen == Main.secondScreen)) { // frame.setSize(gd[screen].getDefaultConfiguration().getBounds().x,gd[screen].getDefaultConfiguration().getBounds().y); gd[screen].setFullScreenWindow(frame); } else { frame.setSize(600, 300); Rectangle bound = gd[screen].getDefaultConfiguration().getBounds(); System.out.println( "x: " + bound.x + " y: " + bound.y + " width: " + bound.width + " height : " + bound.height); frame.setLocation((int) (bound.x + bound.getWidth() / 2 - 300), frame.getY()); } return; } System.out.println("Erreur : l'ecran " + screen + " n'a pas ete trouve"); }
public void position() { int x, y; Point topLeft = SchedulerBeta.window.getLocationOnScreen(); Dimension parentSize = SchedulerBeta.window.getSize(); if (parentSize.width > 300) x = ((parentSize.width - 300) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > 320) y = ((parentSize.height - 320) / 2) + topLeft.y; else y = topLeft.y; frame.setLocation(x, y); frame.setTitle("Semester and School Year"); frame.setLayout(null); frame.setSize(new Dimension(300, 240)); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { Window w = (Window) e.getSource(); w.dispose(); } }); }
@Override public void display(HashBasedTable<String, String, Double> data) { roomToCodeMapping = generateNewRoomToCodeMapping(); dataSet = createDataSet(data); final JFreeChart chart = createChart(dataSet); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1000, 540)); createNewFrameAndSetLocation(); currentFrame.setTitle(this.getTitle()); currentFrame.setContentPane(chartPanel); currentFrame.setVisible(true); currentFrame.setSize(new Dimension(1020, 560)); currentFrame.addWindowListener(this); if (type == MarkovDataDialog.HeatMapType.COMPARISON) { unscaledDifferenceSlider.setLabelTable(unscaledDifferenceSlider.createStandardLabels(5, 5)); differenceSelectorFrame = new JFrame("Choose Size of difference"); differenceSelectorFrame.setLayout(new BorderLayout()); differenceSelectorFrame.add(unscaledDifferenceSlider, BorderLayout.NORTH); statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setText("Current difference size:" + this.unscaledDifference); differenceSelectorFrame.add(statusLabel, BorderLayout.CENTER); differenceSelectorFrame.add(regenerate, BorderLayout.SOUTH); regenerate.addActionListener(this); differenceSelectorFrame.setLocation(100, 10); differenceSelectorFrame.setSize(300, 200); differenceSelectorFrame.setVisible(true); } }
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 void actionPerformed(ActionEvent e) { if (e.getSource() == creer) { this.setVisible(false); JFrame fenetremilieu = new FenetreMilieu(this); fenetremilieu.setVisible(true); fenetremilieu.setLocation(500, 500); } if (e.getSource() == quitter) { this.dispose(); } if (e.getSource() == options) { String message = "Choisissez le port"; numport = Integer.parseInt(JOptionPane.showInputDialog(this, message)); // JFrame fenetreoptions = new FenetreOptions(); // fenetreoptions.setVisible(true); } }
/** * 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); }
private void frameMouseDragged(MouseEvent ev) { int dx = ev.getX() - pressedX; int dy = ev.getY() - pressedY; Point location = frame.getLocation(); location.translate(dx, dy); frame.setLocation(location); }
// filter2d_freq public void filter2d_freq_window() { fr = new JFrame(); panel = new JPanel(); label = new JLabel(); tf = new JTextField(); bt = new JButton(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); fr.setLocation((screenSize.width - 260) / 2, (screenSize.height - 100) / 2); fr.setSize(260, 100); fr.setVisible(true); panel.setLayout(new GridLayout(3, 1)); label = new JLabel("请选择操作,0(平滑),1(锐化)"); label.setHorizontalAlignment(JLabel.CENTER); tf.setHorizontalAlignment(JTextField.CENTER); bt.setText("确定"); panel.add(label); panel.add(tf); panel.add(bt); fr.getContentPane().add(panel, BorderLayout.CENTER); bt.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fr.dispose(); filter2d_freq(Integer.parseInt(tf.getText())); } }); }
// ---------- Constructor ---------- public DrawWindow() { // Create Main DrawWindow JFrame frame = new JFrame(TreeGen.getTitle()); frame.setVisible(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setLocation(0, 0); // Sets Settings For FullSCreen Mode if (TreeGen.isFullScreen()) { frame.setSize( Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); frame.setUndecorated(true); frame.setIgnoreRepaint(true); // vc.setFullScreenWindow(); } // Sets Settings For Standard Mode else { frame.setSize( Toolkit.getDefaultToolkit().getScreenSize().width - 200, Toolkit.getDefaultToolkit().getScreenSize().height - 100); } if (TreeGen.getFPSCap() > 0) { maxWaitTime = 1000 / TreeGen.getFPSCap(); fpsCap = true; } }
public void run() { final JFrame frame1 = new JFrame("Words Counted!!"); frame1.setSize(250, 100); frame1.setLocation(0, 500); out = new JTextArea(30, 50); frame1.add(out); Scanner scanner; try { scanner = new Scanner(f); int wordCount = 0; String s = ""; while (scanner.hasNext()) { s = s + " " + scanner.next(); wordCount++; } scanner.close(); frame1.setVisible(true); out.setVisible(true); out.setText("" + wordCount + " words in file \n\n" + "contents are: \n" + s); } catch (FileNotFoundException e) { // TODO Auto-generated catch block 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); }
// 设置窗体居中 public static void setFrameCenter(JFrame jf) { /* 思路: A:获取屏幕的宽和高 B:获取窗体的宽和高 C:(用屏幕的宽-窗体的宽)/2,(用屏幕的高-窗体的高)/2作为窗体的新坐标。 */ // 获取工具对象 Toolkit tk = Toolkit.getDefaultToolkit(); // 获取屏幕的宽和高 Dimension d = tk.getScreenSize(); double srceenWidth = d.getWidth(); double srceenHeigth = d.getHeight(); // 获取窗体的宽和高 int frameWidth = jf.getWidth(); int frameHeight = jf.getHeight(); // 获取新的宽和高 int width = (int) (srceenWidth - frameWidth) / 2; int height = (int) (srceenHeigth - frameHeight) / 2; // 设置窗体坐标 jf.setLocation(width, height); }
public void testEmptyHeader() { fFrame = new JFrame("Test Window"); // Create a panel to hold all other components JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); // Create a new table instance MyTableModel myModel = new MyTableModel(); fTable = new JTable(myModel); // Add the table to a scrolling pane JScrollPane scrollPane = new JScrollPane(fTable); topPanel.add(scrollPane, BorderLayout.CENTER); fFrame.getContentPane().setLayout(new BorderLayout()); fFrame.getContentPane().add(BorderLayout.CENTER, topPanel); fFrame.setSize(400, 450); fFrame.setLocation(20, 20); fFrame.setVisible(true); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } JTableHeader header = fTable.getTableHeader(); assertTrue( "JTableHeader greater than 5 pixels tall with empty string first element.", header.getSize().height > 5); fFrame.setVisible(false); fFrame.dispose(); }
public void doIt() { mJFrame = new JFrame(mWindowName); mJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create the menu bar. mJMenuBarMain = new JMenuBar(); mJMenuBarMain.setOpaque(true); mJMenuBarMain.setBackground(mMenuColor); mJMenuBarMain.setPreferredSize(new Dimension(X_WINDOW_SIZE, Y_MENU_SIZE)); // Create main component mJMain = new JLabel(); mJMain.setOpaque(true); mJMain.setBackground(mMainColor); mJMain.setPreferredSize(new Dimension(X_WINDOW_SIZE * 5, Y_WINDOW_SIZE * 150)); JScrollPane scrollPane = new JScrollPane(mJMain); scrollPane.setPreferredSize(new Dimension(X_WINDOW_SIZE + 20, Y_WINDOW_SIZE + 20)); // Set the menu bar and add the label to the content pane. mJFrame.setJMenuBar(mJMenuBarMain); mJFrame.getContentPane().add(scrollPane, BorderLayout.CENTER); mJFrame.setLocation(10, 10); // Display the window. mJFrame.pack(); mJFrame.setVisible(true); }
@Override public void enterNode(QuestionTreeNode node) { if (node.isCategory()) { enabled = Boolean.parseBoolean(node.getAttributeValue(KEY)); if (enabled) { QuestionTreeNode attributes = node.getAttribute(KEY); String[] commands = attributes.getAttributeValue(KEY_COMMANDS).split("\n"); createWindow(); for (int i = 0; i < commands.length; i++) { if (!commands[i].equals("")) { int lastSep = commands[i].lastIndexOf(System.getProperty("file.separator")); String caption = commands[i]; if (lastSep != -1) { caption = caption.substring(lastSep + 1); } addButton(caption, commands[i], i); } } frame.pack(); if (location == null) { frame.setLocationRelativeTo(experimentViewer); } else { frame.setLocation(location); } } } }
/** 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); }
public static void pop(String message) { JFrame f = new JFrame(); f.add(new JLabel(message)); f.setAlwaysOnTop(true); f.pack(); f.setVisible(true); final int thisHeight = f.getHeight(); f.addWindowListener( new WindowListener() { public void windowOpened(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowClosing(WindowEvent e) { currentHeight = currentHeight - thisHeight; } public void windowClosed(WindowEvent e) {} public void windowActivated(WindowEvent e) {} }); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); currentHeight = currentHeight + thisHeight; f.setLocation(screenWidth - f.getWidth(), screenHeight - currentHeight); }
private void centraLaVentana() throws HeadlessException { Toolkit toolkit = ventanaPrincipal.getToolkit(); Dimension size = toolkit.getScreenSize(); ventanaPrincipal.setLocation( (size.width - ventanaPrincipal.getWidth()) / 2, (size.height - ventanaPrincipal.getHeight()) / 2); }
public static void main(String[] arg) { // init table with Random Random alea = new Random(System.currentTimeMillis()); for (int i = 0; i < table.length; i++) { table[i] = alea.nextInt(10); } System.out.println(Arrays.toString(table)); // pick median values 3 by 3 using Arrays.sort for (int i = 1; (i < table.length - 1); i++) { int[] sort3 = {table[i - 1], table[i], table[i + 1]}; Arrays.sort(sort3); median[i] = sort3[1]; System.out.printf("%d %d %d : %d\n", table[i - 1], table[i], table[i + 1], median[i]); } System.out.println(Arrays.toString(median)); // create Frame + Panel + Graphics JFrame cadre = new JFrame(); JPanel ardoise = new Graph(); cadre.setVisible(true); cadre.setContentPane(ardoise); cadre.pack(); cadre.setLocation(100, 100); }
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); }
private Canvas() { component = new CanvasComponent(); if (System.getProperty("com.horstmann.codecheck") == null) { frame = new JFrame(); if (!System.getProperty("java.class.path").contains("bluej")) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(component); frame.pack(); frame.setLocation(LOCATION_OFFSET, LOCATION_OFFSET); frame.setVisible(true); } else { final String SAVEFILE = "canvas.png"; final Thread currentThread = Thread.currentThread(); Thread watcherThread = new Thread() { public void run() { try { final int DELAY = 10; while (currentThread.getState() != State.TERMINATED) { Thread.sleep(DELAY); } saveToDisk(SAVEFILE); } catch (Exception ex) { ex.printStackTrace(); } } }; watcherThread.start(); } }
public TabSpawnable spawn() { JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); f.setTitle(_title); TabSpawnable newPanel = (TabSpawnable) clone(); if (newPanel == null) return null; // failed to clone newPanel.setTitle(_title); if (newPanel instanceof TabToDoTarget) { TabToDoTarget me = (TabToDoTarget) this; TabToDoTarget it = (TabToDoTarget) newPanel; it.setTarget(me.getTarget()); } else if (newPanel instanceof TabModelTarget) { TabModelTarget me = (TabModelTarget) this; TabModelTarget it = (TabModelTarget) newPanel; it.setTarget(me.getTarget()); } f.getContentPane().add(newPanel, BorderLayout.CENTER); Rectangle bounds = getBounds(); bounds.height += OVERLAPP * 2; f.setBounds(bounds); Point loc = new Point(0, 0); SwingUtilities.convertPointToScreen(loc, this); loc.y -= OVERLAPP; f.setLocation(loc); f.setVisible(true); if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this); return newPanel; }
public enterInforGUI() { frame = new JFrame(); frame.setForeground(Color.WHITE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(new Point(10, 50)); frame.setSize(new Dimension(300, 120)); frame.setTitle("ChatClient"); frame.setVisible(true); frame.setLayout(new BorderLayout()); JPanel north = new JPanel(new GridLayout(3, 2)); north.add(new JLabel("Enter username: "******"Enter password: "******"Enter"); enter.addActionListener(s); north.add(enter); frame.add(north, BorderLayout.NORTH); // frame.pack(); }
/** Displays the inventory window */ public void inventoryWindow() { if (inventoryWin != null) { inventoryWin.dispose(); } inventoryWin = new JFrame("Inventory"); inventoryWin.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Inventory inv = player.getInventory(); int y = inv.getSize(); if (y == 0) { displayMessage("Inventory is empty"); return; } int cols = 2; int rows = (y - y % cols) / cols; if (y % cols != 0) rows = rows + 1; inventoryWin.setLayout(new GridLayout(0, cols * 2)); for (int i = 0; i < y; i++) { JButton b = new JButton(inv.getItem(i).getName()); inventoryWin.add(b); b.addActionListener(this); JButton d = new JButton("drop " + inv.getItem(i).getName()); inventoryWin.add(d); d.addActionListener(this); } // inventoryWin.setBounds(350, 0, 300, 80*rows); inventoryWin.setLocation(mainWindow.getX(), mainWindow.getY() + mainWindow.getHeight()); inventoryWin.pack(); inventoryWin.setVisible(true); }
public void go() throws Exception { if (!no_channel && !use_state) { channel.connect(groupname); } mainFrame = new JFrame(); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel = new DrawPanel(use_state); panel.setBackground(background_color); sub_panel = new JPanel(); mainFrame.getContentPane().add("Center", panel); clear_button = new JButton("Clear"); clear_button.setFont(default_font); clear_button.addActionListener(this); leave_button = new JButton("Leave"); leave_button.setFont(default_font); leave_button.addActionListener(this); sub_panel.add("South", clear_button); sub_panel.add("South", leave_button); mainFrame.getContentPane().add("South", sub_panel); mainFrame.setBackground(background_color); clear_button.setForeground(Color.blue); leave_button.setForeground(Color.blue); mainFrame.pack(); mainFrame.setLocation(15, 25); mainFrame.setBounds(new Rectangle(250, 250)); if (!no_channel && use_state) { channel.connect(groupname, null, null, state_timeout); } mainFrame.setVisible(true); setTitle(); }