jframe

Java setFullScreenWindow() keep on top

寵の児 提交于 2019-11-30 01:51:46
问题 I'm writing an application that is intended to be run on a dual monitor setup, with a "Display" JFrame going fullscreen on one monitor and a "Control" JFrame on the other monitor, sending instructions to the Display. I've tried two separate methods of setting the Display fullscreen; the success of each seems to depend on the OS. display.setUndecorated(true); display.setExtendedState(JFrame.MAXIMIZED_BOTH); Works in Windows, but the JFrame gets hidden under the dock/panels in OS X and Linux.

How to place a JButton at a desired location in a JFrame using Java

江枫思渺然 提交于 2019-11-30 01:04:56
I want to put a Jbutton on a particular coordinate in a JFrame. I put setBounds for the JPanel (which I placed on the JFrame) and also setBounds for the JButton. However, they dont seem to function as expected. My Output: This is my code: import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Control extends JFrame { // JPanel JPanel pnlButton = new JPanel(); // Buttons JButton btnAddFlight = new JButton("Add Flight"); public Control() { // FlightInfo setbounds btnAddFlight.setBounds(60, 400, 220, 30); // JPanel bounds pnlButton

How to detect JFrame window minimize and maximize events?

ぃ、小莉子 提交于 2019-11-29 19:03:41
问题 Is there a way to an event listener to a JFrame object to detect when the user clicks the window maximize or minimize buttons? Am using the JFrame object as follows: JFrame frame = new JFrame("Frame"); 回答1: You can use WindowStateListener. How to Write Window Listeners tutorial demonstrates how to create window-related event handlers. 回答2: Create a frame and add a listener: JFrame frame = new JFrame(); frame.addWindowStateListener(new WindowStateListener() { public void windowStateChanged

How to paint an arrayList of shapes Java

走远了吗. 提交于 2019-11-29 18:49:30
I am tasked with how to paint an arrayList of shapes in java. I feel i have most of it right, there are two methods i am confused about however the method in ShapeChooserPanel called public void setPoints(int x, int y) Since Xs and Ys are arrays, how would i set the x and y values? And the other is one is the final method in ShapeChooserPanel I cannot find out how to print the Shapes in the array, It should paint the current shape at the place the mouse was clicked. My code is below Main class: import javax.swing.JFrame; public class Lab2 { public static void main (String[] args) { JFrame

Can't call a the third page via the 2nd Page

拜拜、爱过 提交于 2019-11-29 18:23:44
I'd like to create a software that has three pages: The "Home Page" (That's drawn on a JFrame "frame"), "Page 2" and "Page 3". Pages 2 and 3 are drawn on "frame". One uses a navigation pane that sits on the left side of the page and the main content is held on the right. I'm currently only able to navigate to the 2nd page. The class called to draw page 2 on the JFrame can't seem to call Page three. My code is as follows: // The Home Page package Try; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax

How to add data to JTable created in design mode?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 18:08:50
I created an initial JFrame that contains a table with three columns, as shown below: This JFrame was created in design mode, and so now in the panel's constructor, I want to load some data so when the user selects to open this JFrame, the data is loaded. My column data types are Object (generally 'Status' is for an image representing the status of the share - active or inactive), String for the share's name and integer for the number of active clients connected to that share. My question is, how to I add rows to a JTable via code? In a simplified way (can be improved): class MyModel extends

Open JFrame, only after successfull login verification with database. Using Eclipse?

大城市里の小女人 提交于 2019-11-29 17:56:07
what I'm trying to do is open up a main application from a login screen, only after the login information has been verified in the connected database. Using Eclipse, what I have so far: database.java : connection to MS Access Database using UCanAccess. (Success) login.java : A login window that extends JFrame. When a username and password is entered, it is verified with the database. (Success) Home.java : The main application window, that I want to only be accessible with a correct username and password. Does not extend JFrame, but has a JFrame within it. Now, I have been able to set it up so

Using JFrame from another class

↘锁芯ラ 提交于 2019-11-29 17:53:56
Hi I'm small a little issue trying to append some text to a JTextArea from another class within the same package. Below is the main class that pertains to the JFrame: public class Client extends JFrame{ //Static variables private static final String host = "localhost"; private static final int portNumber = 4444; //Variables private String userName; //JFrame Variables private JPanel contentPanel; private JTabbedPane panel_Social; private JPanel jpanel_Social; private JPanel jpanel_Chat; private JTextArea textArea_Receive; private JTextField textField_Send; private JTextArea textArea_ClientList;

Swing - Changing the content of a panel using UpdateUI

心不动则不痛 提交于 2019-11-29 17:41:46
I am going through a legacy application which is using Swing and i am struggling to figure out how the screens are changing when a user clicks a button. One of the reasons i cant figure this out is because this is the first time i am using Swing. I have read a book and got the basics but still struggling. Basically, the screen i am looking at has a JSplitPane which has a number of shortcut buttons on the left and an empty pane on the right. When i click on the button, the right side pane is populated with a different screen depending on the button pressed. Going through the code, i was

Nothing in my JFrame appears

只谈情不闲聊 提交于 2019-11-29 17:31:02
I am practicing using GUIs. I have been following a set of instructions however when I try to run the program only an empty frame appears. No information can be seen inside the frame. here is the code I have: package practice528; import java.util.Scanner; import java.io.*; import javax.swing.*; import java.awt.*; public class Practice528 { public static void main(String[] args) { JFrame frame = new JFrame("Rectangle Calculator"); frame.setVisible(true); frame.setSize(400,300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel lengthL, widthL, areaL, perimeterL; lengthL = new JLabel(