/** Inicializace základních komponent okna */ private void init() { krokLabel = new JLabel("Synchronizace s web aplikací"); Font pismo = new Font("Arial", Font.BOLD, 14); krokLabel.setFont(pismo); NacitaciOkno.add(krokLabel); krokLabel.setBounds(90, 10, 250, 20); startButton = new JButton("Načíst"); startButton.setActionCommand("start"); startButton.setBounds(250, 110, 120, 25); startButton.addActionListener(new Start()); progressBar = new JProgressBar(0, 100); progressBar.setBounds(20, 60, 350, 25); progressBar.setValue(0); progressBar.setStringPainted(true); taskOutput = new JTextArea(5, 20); taskOutput.setMargin(new Insets(5, 5, 5, 5)); taskOutput.setEditable(false); NacitaciOkno.add(startButton); NacitaciOkno.add(progressBar); NacitaciOkno.setVisible(true); vybratButton = new JButton("Otevřít"); NacitaciOkno.add(vybratButton); vybratButton.setBounds(20, 110, 120, 25); vybratButton.addActionListener(new Zpet()); }
public static void main(String[] args) { JFrame frame = new JFrame("Reaction Timer"); frame.setSize(280, 120); final TextField disp = new TextField(); final JButton btn = new JButton("Go"); btn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { u = System.currentTimeMillis(); if (u - t < ONE_SECOND) { disp.setText("" + (u - t)); } t = u; } }); frame.setLayout(null); disp.setBounds(10, 10, 230, 20); frame.add(disp); btn.setBounds(10, 40, 210, 40); frame.add(btn); frame.setVisible(true); frame.setLocationRelativeTo(null); frame.setResizable(false); }
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()); }
public void creditCard() { System.out.println("Credit card match found : Payam Mashrequi"); frame.add(new JLabel()); frame.add(new JLabel("total : " + total)); frame.add(new JLabel("Rs." + total + " Amount has been deduced from your account")); frame.setVisible(true); }
public void go() { picture(); ActionListener listener = new BtListener(); go.addActionListener(listener); btn_update_manual.addActionListener(listener); go.setForeground(Color.black); // rights.setFont((new Font("Arial", Font.PLAIN, 12))); title.setFont((new Font("Arial", Font.BOLD, 36))); title.setForeground(new Color(238, 253, 253)); today.setFont((new Font("Arial", Font.BOLD, 16))); today.setForeground(new Color(163, 184, 204)); frame.setLayout(new BorderLayout()); from.setBackground(Color.white); to.setBackground(Color.white); converted.setFont(new Font("Arial", Font.BOLD, 24)); converted.setForeground(new Color(238, 253, 253)); Lfrom.setForeground(new Color(238, 253, 253)); Lto.setForeground(new Color(238, 253, 253)); quantity.setForeground(new Color(238, 253, 253)); Lfrom.setFont(new Font("Arial", Font.BOLD, 24)); Lto.setFont(new Font("Arial", Font.BOLD, 24)); quantity.setFont(new Font("Arial", Font.BOLD, 24)); north.setLayout(new FlowLayout()); north.add(title); north.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.NORTH, north); inner.setLayout(new BorderLayout()); inner.add(BorderLayout.NORTH, today); inner.add(BorderLayout.WEST, picPanel); center.setLayout(new GridLayout(2, 4, 5, 5)); center.add(Lfrom); center.add(from); center.add(Lto); center.add(to); center.add(quantity); center.add(amount); center.add(go); inner.setBackground(new Color(59, 62, 71)); inner.add(BorderLayout.SOUTH, center); center.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.CENTER, inner); south.setBackground(new Color(59, 62, 71)); south.setLayout(new FlowLayout()); south.add(converted); south.add(answer); south.add(btn_update_manual); // south.add(rights); frame.add(BorderLayout.SOUTH, south); frame.setSize(850, 700); frame.setVisible(true); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.setVisible(false); frame.dispose(); System.exit(0); } }); }
/** * IRC Constructor * * @param jo the JVN object representing the Chat */ public Irc(JvnObject jo) { sentence = jo; frame = new JFrame(); frame.setLayout(new GridLayout(1, 1)); text = new TextArea(10, 60); text.setEditable(false); text.setForeground(Color.red); frame.add(text); data = new TextField(40); frame.add(data); Button read_button = new Button("read"); read_button.addActionListener(new readListener(this)); frame.add(read_button); Button write_button = new Button("write"); write_button.addActionListener(new writeListener(this)); frame.add(write_button); frame.setSize(545, 201); // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("Closed"); try { JvnServerImpl.jvnGetServer().jvnTerminate(); } catch (Exception exc) { System.out.println("An exception: " + exc); } e.getWindow().dispose(); } }); text.setBackground(Color.black); frame.setVisible(true); }
/** 构建客户端的聊天界面 */ private void initUI() { sendButton = new JButton("发送"); userMsgPanel = new JPanel(); sendMsgTextField = new JTextField("enter sth to sent"); sendPanel = new JPanel(); chartTextArea = new JTextArea(); userMsgPanel.setLayout(new BorderLayout()); sendPanel.setLayout(new BorderLayout()); sendPanel.add(sendMsgTextField, BorderLayout.CENTER); sendPanel.add(sendButton, BorderLayout.EAST); chartTextArea.setEditable(false); chartAreaScrollPane = new JScrollPane(chartTextArea); frame.setLayout(new BorderLayout()); frame.add(userMsgPanel, BorderLayout.NORTH); frame.add(chartAreaScrollPane, BorderLayout.CENTER); frame.add(sendPanel, BorderLayout.SOUTH); frame.setSize(500, 300); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.setVisible(false); } }); frame.setVisible(true); }
private void initComponents() { frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); frame.setPreferredSize(new Dimension(400, 70)); frame.setSize(400, 70); frame.setLocationRelativeTo(null); textField = new JTextField(); callBtn = new JButton("Call"); callBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String msg = textField.getText(); if (msg != null & msg.trim().length() > 0) { String lang = hello.getLang(); if (lang != null) { frame.setTitle(name + " in " + lang); frame.repaint(); hello.sayHello(msg); } textField.setText(""); } } }); frame.setLayout(new BorderLayout()); frame.add(textField, BorderLayout.CENTER); frame.add(callBtn, BorderLayout.EAST); frame.getRootPane().setDefaultButton(callBtn); }
// ------------------------------------------------------------------- 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); }
/** * Start here! * * @param args */ public static void main(String[] args) { JFrame frame = new JFrame("Watch Me Move"); final AnimationComponent animation = new AnimationComponent(); frame.add(animation); class AnimatorButton extends JButton implements ActionListener { public void actionPerformed(ActionEvent e) { animation.addSquare(); } } AnimatorButton animatorButton = new AnimatorButton(); animatorButton.setText("Move it!"); animatorButton.addActionListener(animatorButton); frame.add(animatorButton, BorderLayout.SOUTH); // TODO 1: Add Timer here to run the animation // TODO 2: Comment out the Timer and add a thread here to run the animation // Then make the AnimationComponent runnable frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
public static void main(String args[]) { File[] IFCFiles = new File("D:\\Data\\Emiel\\CreateTable\\IFC").listFiles(); File[] XMLFiles = new File("D:\\Data\\Emiel\\CreateTable\\XML").listFiles(); Object[] col = new Object[IFCFiles.length + 1]; Object[][] dat = new Object[XMLFiles.length][IFCFiles.length + 1]; col[0] = " "; for (int j = 0; j < IFCFiles.length; j++) { col[j + 1] = IFCFiles[j].getName(); for (int i = 0; i < XMLFiles.length; i++) { File[] BCFFiles = new File( "D:\\Data\\Emiel\\CreateTable\\Results\\" + IFCFiles[j].getName() + "\\" + XMLFiles[i].getName()) .listFiles(); System.out.println(BCFFiles.length); dat[i][0] = XMLFiles[i].getName(); dat[i][j + 1] = BCFFiles.length; } } JFrame frame = new JFrame("MVD Checker"); JTable table = new JTable(dat, col); frame.setVisible(true); frame.setBounds(0, 0, 500, 500); frame.add(table.getTableHeader(), BorderLayout.PAGE_START); frame.add(table); }
public void init() { // 向内部窗口中添加组件 iframe.add(new JScrollPane(new JTextArea(8, 40))); desktop.setPreferredSize(new Dimension(400, 300)); // 把虚拟桌面添加到JFrame窗口中 jf.add(desktop); // 设置内部窗口的大小、位置 iframe.reshape(0, 0, 300, 200); // 显示并选中内部窗口 iframe.show(); desktop.add(iframe); JPanel jp = new JPanel(); deskBn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // 弹出内部对话框,以虚拟桌面作为父组件 JOptionPane.showInternalMessageDialog(desktop, "属于虚拟桌面的对话框"); } }); internalBn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // 弹出内部对话框,以内部窗口作为父组件 JOptionPane.showInternalMessageDialog(iframe, "属于内部窗口的对话框"); } }); jp.add(deskBn); jp.add(internalBn); jf.add(jp, BorderLayout.SOUTH); jf.pack(); jf.setVisible(true); }
/** This function initializes and displays a Slick2D frame */ public void showSlick() { try { if (game == null) { game = new TestGame(); } contain = new NSlixContainer(game); contain.setSize(sizex, sizey); window.add(contain, BorderLayout.CENTER); window.setSize(sizex, sizey); window.add(textfield, BorderLayout.SOUTH); window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); window.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // SlixLibrary.removeAllScreens(); // SlixLibrary.updateScreens(); window.dispose(); System.exit(0); } }); textfield.setFocusable(true); window.validate(); window.setVisible(true); window.pack(); contain.start(); } catch (SlickException ex) { System.err.println(ex); } }
/** * Creates a new Victor speed controller. * * @param channel The Digital Sidecar channel it should be connected to. */ public Victor(int channel) { frame = new JFrame("Victor Emulator: " + channel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setResizable(false); frame.setLocation(510, 0); frame.setLayout(new BorderLayout()); frame.setPreferredSize(new Dimension(300, 320)); // tells the current speed of the victor in % above the graph. victorSpeed = new JLabel("Current Speed: " + (speed * 100) + "%"); frame.add(victorSpeed, BorderLayout.NORTH); // allows user to stop the movement of the graph. button located under the graph. startStop = new JButton("Stop Graph"); startStop.addActionListener(this); frame.add(startStop, BorderLayout.SOUTH); // makes the actual graph. graph = new SpeedGrapher(300, 300); frame.add(graph, BorderLayout.CENTER); startTime = 0; isGraphRunning = true; frame.addComponentListener(this); frame.pack(); frame.setVisible(true); }
// Create the Graphical User Interface. public JFrame createGUI() { // Initialize the temporary JPanel variable p. JPanel p = null; // Set the basic parameters of the window. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setSize(500, 500); window.setLayout(new GridLayout(3, 1)); // Add the Output panel to the window. p = makeOutputPanel(); window.add(p); // Add the Button panel to the window. p = makeButtonPanel(); window.add(p); // Add the Input panel to the window. p = makeInputPanel(); window.add(p); // Finalize the window. window.pack(); return window; }
/** 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 static void main(String[] args) { final int TEXT_WIDTH = 20; final JTextField txtThought = new JTextField(TEXT_WIDTH); txtThought.setText("What are you thinking?"); JButton btnYes = new JButton("Yes"); btnYes.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { txtThought.setText("Do it! You'll love it!"); } }); JButton btnNo = new JButton("No"); btnNo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { txtThought.setText("Don't do it! You'll feel guilty!"); } }); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.add(btnYes); frame.add(txtThought); frame.add(btnNo); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
/** Sets up the components in this frame. */ private void setupComponents() { myDrawPanel.addMouseListener(new DrawPanelMouseListener()); myFrame.add(myDrawPanel, BorderLayout.CENTER); myFrame.setJMenuBar(myMenuBar); myFrame.setIconImage(new ImageIcon("./images//paint.png").getImage()); createFileMenu(); createOptionMenu(); final Action[] actions = { new PencilAction(myDrawPanel, new PencilTool()), new LineAction(myDrawPanel, new LineTool()), new RectangleAction(myDrawPanel, new RectangleTool()), new EllipseAction(myDrawPanel, new EllipseTool()) }; myDrawPanel.addPropertyChangeListener(this); final JMenu toolMenu = new JMenu("Tools"); toolMenu.setMnemonic(KeyEvent.VK_T); final JToolBar toolBar = new JToolBar(); for (final Action current : actions) { toolMenu.add(createToolMenuButton(current)); toolBar.add(createToolBarButton(current)); myDrawPanel.setTool(new PencilTool()); } myMenuBar.add(toolMenu); createHelpMenu(); createColorMenuItem(); myFrame.add(toolBar, BorderLayout.SOUTH); }
@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(); }
Main() { f = new JFrame("Wiki Seach"); JPanel p = new JPanel(); JPanel p1 = new JPanel(); b = new JButton("Search"); b1 = new JButton("Exit"); t = new JTextField(30); b.addActionListener(this); b1.addActionListener(this); p1.add(b); p1.add(b1); p.add(t); f.setLayout(new GridLayout(2, 1)); f.add(p); f.add(p1); f.pack(); f.setLocationRelativeTo(null); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
public String[] cannotUseRequestedNicknames(Server s) { synchronized (_nickLock) { if (_interface.getComponent() != null) _interface.getComponent().setEnabled(false); if (_frame != null) _frame.setEnabled(false); JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(200, 65); f.setTitle("Change nickname to"); // f.setTitle(getText(IRCTextProvider.GUI_CHANGE_NICK)); JTextField field = new JTextField(_start.getNick()); JButton b = new JButton("Ok"); b.addActionListener(this); f.add(field); f.add(b); f.setVisible(true); try { _nickLock.wait(); } catch (InterruptedException ex) { // ignore... } f.setVisible(false); f.remove(b); f.remove(field); f.dispose(); String[] ans = new String[1]; ans[0] = field.getText(); if (_frame != null) _frame.setEnabled(true); if (_interface.getComponent() != null) _interface.getComponent().setEnabled(true); return ans; } }
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 Group4_GameStart() { JFrame newframe = new JFrame("Rebirth of Legends"); JPanel ha = new JPanel(); ngButton = new JButton("New Game"); cgButton = new JButton("Continue"); oButton = new JButton("Options"); la = new JLabel("No Button Clicked!"); ha.add(ngButton); ha.add(cgButton); ha.add(oButton); ha.add(la); ngButton.addActionListener(new action()); oButton.addActionListener(new Test()); cgButton.addActionListener(new Test()); newframe.add(ha, BorderLayout.CENTER); newframe.add(la, BorderLayout.NORTH); newframe.setSize(600, 400); newframe.setVisible(true); newframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
/** Displays the Spark error log. */ private void showErrorLog() { final File logDir = new File(Spark.getLogDirectory(), "errors.log"); // Read file and show final String errorLogs = URLFileSystem.getContents(logDir); final JFrame frame = new JFrame(Res.getString("title.client.logs")); frame.setLayout(new BorderLayout()); frame.setIconImage(SparkManager.getApplicationImage().getImage()); final JTextPane pane = new JTextPane(); pane.setBackground(Color.white); pane.setFont(new Font("Dialog", Font.PLAIN, 12)); pane.setEditable(false); pane.setText(errorLogs); frame.add(new JScrollPane(pane), BorderLayout.CENTER); final JButton copyButton = new JButton(Res.getString("button.copy.to.clipboard")); frame.add(copyButton, BorderLayout.SOUTH); copyButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.setClipboard(errorLogs); copyButton.setEnabled(false); } }); frame.pack(); frame.setSize(600, 400); GraphicUtils.centerWindowOnScreen(frame); frame.setVisible(true); }
public TabularViewer(final Debugger debugger, final DebuggerListener listener) { this.debugger = debugger; this.listener = listener; frame = new JFrame(); pauseButton = new JButton("Pause"); pauseButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (paused) { paused = false; debugger.play(); pauseButton.setText("Pause"); } else { paused = true; debugger.pause(); pauseButton.setText("Play"); data = listener.getData(); tableModel.setDataVector(data, listener.getHeader()); } } }); frame.add(pauseButton, BorderLayout.NORTH); tableModel = new DefaultTableModel(); tableModel.setColumnIdentifiers(listener.getHeader()); final JTable table = new JTable(tableModel); final TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>(tableModel) { @Override public Comparator<?> getComparator(int column) { return new Comparator<String>() { @Override public int compare(String o1, String o2) { if (o1.matches("\\d+") && o2.matches("\\d+")) { return new Integer(Integer.parseInt(o1)).compareTo(Integer.parseInt(o2)); } else return o1.compareTo(o2); } }; } }; table.setRowSorter(sorter); frame.add(new JScrollPane(table)); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.setSize(400, 600); frame.setVisible(true); table.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = table.rowAtPoint(e.getPoint()); listener.debugCallback( data, sorter.convertRowIndexToModel(row), table.columnAtPoint(e.getPoint())); } }); }
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); } } }); }
@Override public void run() { ArrayList<ArrayList<Integer>> paths = new ArrayList<ArrayList<Integer>>(); buttonOpen = new JButton("Open file"); buttonOpen.addActionListener(new openFile()); openFileL = new JLabel("Open file..."); frame = new JFrame("SRPP PROJECT"); frame.setPreferredSize(new Dimension(510, 590)); frame.setResizable(false); JToolBar bar1 = new JToolBar(); bar1.setFloatable(false); bar1.add(buttonOpen); bar1.add(openFileL); bar1.setMargin(new Insets(5, 5, 5, 5)); frame.add(bar1, BorderLayout.NORTH); drawPanel = new DrawPanel(cities, paths, magazine); frame.add(drawPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
/** Displays the character window */ public void characterWindow() { if (characterWindow != null) { characterWindow.dispose(); } characterWindow = new JFrame("Character"); characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JTextField health = new JTextField(player.health()); health.setEditable(false); JButton weapon = new JButton(player.weapon().split(" ")[1]); if (player.weapon().split(" ")[1].equals("none")) { weapon.setEnabled(false); } weapon.addActionListener(this); JButton armor = new JButton(player.armor().split(" ")[1]); if (player.armor().split(" ")[1].equals("none")) { armor.setEnabled(false); } armor.addActionListener(this); characterWindow.setBounds( mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150); characterWindow.setResizable(false); characterWindow.setLayout(new GridLayout(3, 1)); characterWindow.add(health); characterWindow.add(weapon); characterWindow.add(armor); characterWindow.setVisible(true); }
public start() { MyModel lm = new MyModel(); JList<Integer> jl = new JList<>(lm); JButton b = new JButton("ADD"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lm.add(zahl++); } }); JFrame jf = new JFrame("List Test"); jf.setLayout(new BorderLayout()); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane scrollen = new JScrollPane(jl); jf.add(b, BorderLayout.SOUTH); jf.add(scrollen, BorderLayout.NORTH); jf.setSize(300, 300); jf.setLocation(400, 500); jf.setVisible(true); }