jframe

Removing a JPanel from a JFrame, so slow

你离开我真会死。 提交于 2019-12-11 11:35:03
问题 This is what the code looks like: class Main extends JFrame { public MyPanel panel; public Main() { //all the frame init stuff panel = new MyPanel(this); Panel badPanel = new Panel();//this makes the remove method go veryy slow //add(badPanel, BorderLayout.SOUTH);// JPanel goodPanel = new JPanel(); add(goodPanel, BorderLayout.SOUTH); // this fixes the slowness of the remove method in calculate() add(panel, BorderLayout.CENTER); } public static void main(String[] args) { SwingUtilities

How to add images icon in the title bar of JFrame?

家住魔仙堡 提交于 2019-12-11 11:28:50
问题 I need to add image in JFrame title bar, can anybody tell me the way to do this? 回答1: You could use Window#setImageIcons(List<Image>) which allows you to supply a series of different sized, which allows the underlying platform to choose a icon that is best suited to the platform and look and feel... List<Image> images = new ArrayList<Image>(4); images.add(ImageIO.read(getClass().getResource("/icons/icon16x16.png")); images.add(ImageIO.read(getClass().getResource("/icons/icon24x24.png"));

What is java eqivalent for getElementAt(double x, double y) from acm java Libraries(GraphicsProgram);

笑着哭i 提交于 2019-12-11 11:22:15
问题 in java i tried using getComponentAt(x, y) method from container class. but for given (x,y) co ordinates it is always returning me object of class javax.swing.JRootPane even if (x,y) contains some image/JLabel/JButton. import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JButton; import javax.swing.JFrame; public class temp2 implements MouseListener{ public static void main(String[] arg){ frame = new JFrame("adsa"); frame.setBounds(0, 0, 1000, 1000); frame

Adjust the image as per screen resolution of window

戏子无情 提交于 2019-12-11 11:17:52
问题 I have add a JLabel in a JFrame and one image of size 1024x768 is added in JLabel . When I set the resolution of window screen in 1024x768 the and run the application the image is shown in full window. But when I set the resolution of window screen in 1280x768 - the image is shown in only one third portion of window. How can I adjust or add the image of size 1024x768 so that in any screen resolution the image will show covering the full window? In other words the image is adjusted as per the

Adding Menubar to JFrame

泪湿孤枕 提交于 2019-12-11 11:14:28
问题 I have the following source code and i just dont get why my menubar/menu wont show on the JFrame, im somewhat new to programming public class drawingApp { public static void main(String[] args) { JFrame frame = new JFrame("DrawingApp"); frame.setSize(600,800); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.setLocationRelativeTo(null); JMenuBar mb = new JMenuBar(); JMenu menu1 = new JMenu("Colour"); mb.add(menu1); JMenu menu2 = new JMenu("Size"); mb.add

KeyListener isn't working?

给你一囗甜甜゛ 提交于 2019-12-11 11:05:01
问题 Ok, so I have this key listener for my game and it isn't working but when I made a new project just to test does it work at all for me it did? So here's some code of my game: public class GameKeyListener implements KeyListener { private void pressMainWeapon() { Constants.MAIN_WEAPON_PRESSED = Constants.MAIN_WEAPON_PRESSED ? true : false; } private void pressSecondaryWeapon() { Constants.SECONDARY_WEAPON_PRESSED = Constants.SECONDARY_WEAPON_PRESSED ? true : false; } private void

choosing the best Layout for this jframe

Deadly 提交于 2019-12-11 11:04:38
问题 plz can any one help me to choose the best Layout to make this window 回答1: I think BoxLayout is a good solution for your situation. You just provides the size of the frame and some gaps but not the components.I give it an assessment of each component. The x is 30 pixels. import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridLayout; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import

How to adjust an application (JFrame) with every kind of screens?

痞子三分冷 提交于 2019-12-11 10:39:12
问题 i have been working on a Swing application that has a JFrame as principal Frame and it contains a lot of JInternalFrames inside of it , and when i installed it in every computer in the company, it seems that some computers screen size is lower and more tight then the screen in wish i had developed my application, and that is not useful, so i am asking if i can adjust my application (Frames) to every kind of screen size, i am using Swing API. Thank you. 回答1: You can check the size of the

Java JFrame removeall hangs an application

只谈情不闲聊 提交于 2019-12-11 10:28:26
问题 I have the following code: ActionListener listenerComboVehicle = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { comboVehicle.removeActionListener(listenerComboVehicle); frameCrewSelection.removeAll(); frameCrewSelection.add(formCrewSelectionForm(SpaceObjectArray.findMannedByName(comboVehicle.getSelectedItem().toString()))); //Create some controls (Jcombobox comboVehicle included) and assign listeners to them. formComboCrews(); //Modify JCombobox controls content

Transparent Window

荒凉一梦 提交于 2019-12-11 10:25:18
问题 I have a fullscreen JFrame . I added a map to JPanel then added it to JFrame . Now I want to add a transparent window to JFrame . I want to see all map and I want to move transparent window. I did it with internal frame but I couldn't it's title tranparent. Could you help me about this? Thanks ... 回答1: One possible way is to add a JPanel to the glasspane. 回答2: Does com.sun.awt.AWTUtilities.setWi­ndowOpacity(this, 0.3f); work? (although it's not an officially supported API, natch). Regardless,