Swing/AWT/SWT :: How To Make GUI Look The Same On All Screen Resolutions
Feb 11, 2015
I had developed small GUI using swing group layout, which is nice to see on windows, but when I tried it on Linux the GUI look is varied. Then I set the GUI height and width by taking screen resolution, still it is varies the screen look. How I can make the GUI such that it looks the same on all screen resolutions.
View Replies
ADVERTISEMENT
Jan 10, 2015
I tried to make a buffered screen image that constantly refreshed an image (a black screen) however it does not seem to be working.
Java Code: import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
[code]....
View Replies
View Related
May 10, 2014
I tried to make a splash screen it didn't work.Here is the error message: Exception in thread "main" java.lang.Error: Unresolved compilation problems:
JSplash cannot be resolved to a type
JSplash cannot be resolved to a type
at com.mime.splashscreen.SplashScreen.main(SplashScre en.java:8)
The code is:
package com.mime.splashscreen;
public class SplashScreen {
private static final String Color = null;
public static void main(String[] args) {
JSplash splash=new JSplash(SplashScreen.class.getResource("splash.png"), true, true, false, "V1",
null, java.awt.Color.RED, java.awt.Color.BLACK);
}
}
View Replies
View Related
Sep 29, 2014
I have created a java gui on Windows 7 with Eclipse EE, using a screen resolution of 1366 x 768. I used groups with specified boundaries. For example:
final Group g5_script_data = new Group(shell, SWT.BORDER_SOLID);
g5_script_data.setText("Current DB");
g5_script_data.setBounds(0, 0, 680, 380);
g5_script_data.setBackground(green);
The groups cover the whole screen.
However my colleague with a smaller resolution looses the far right of the screen.
As this is a proto-type and I'm new to Java I don't want to rework everything or convert it to say a grid layout until the proto-type is accepted and I can start from scratch with a real detailed design. It already has 6500 lines of source.
Just wondered what is my quickest/easiest way to get my app to display on a slightly smaller resolution. For sure it will not be anything silly. Something like 1280 x 768 to 1366 x 768 would do.
View Replies
View Related
Mar 11, 2014
I'm writing my first bigger program (mysql connection and the first thing bigger than 300 lines ). What I'd like to do is to render data from MySQL using JTable - I managed to handle all the queries but I don't know how to update the table on screen. I've tried to use repaint() but nothing happened. I'm not posting whole code because you'll probably not interested, below are the most important things. I thought about using TableModel but how.
public class Main implements ActionListener{
JTable table;
public Main() {
JFrame frame = new JFrame("Frame");
frame.setLayout(new FlowLayout());
frame.add(table);
[code]...
View Replies
View Related
Oct 29, 2014
I am trying to drag the window down wards and screen has alignment issues. I tried to use WindowListeners, Component Listeners, MouseListeners ect…
But still this problem persists as only I release the mouse after drag down it appears fine that we have handled ComponentResized() method. So how to restrict component size while keep dragging down?
View Replies
View Related
Mar 12, 2014
i'm currently doing my system now and my problem is about inserting an image to my jframe form with thread because if i insert image and when i run it it blinks too slow comparing if i use simple oval it doesnt blink.
why is it that if i wrote the code like this.
public void DrawSnake(Graphics g) throws IOException {
Image image = ImageIO.read(this.getClass().getResource("body1.jpg"));
Image image1 = ImageIO.read(this.getClass().getResource("body.jpg"));
Image headr = ImageIO.read(this.getClass().getResource("headr.jpg"));
Image headl = ImageIO.read(this.getClass().getResource("headl.jpg"));
[Code] .....
View Replies
View Related
Apr 9, 2014
I want to build a class that takes a JTable and previews on screen how it will be printed on the default printer. This is what we use to call as "Print Preview", just like MS Word, Excel, etc. As we already know Java does not support this functionality out-of-the-box.
Based on some examples I've found googling I built two classes. The first one TestPreview.java justs shows the JTable and the second one PrintPreview.java previews how the JTable will be printed on the printer.
I have two buttons to go through the pages, "PREV" and "NEXT" and "Print' button to print the JTable. My problem is that when my JTable has too many rows and spans in more than one page PrintPreview does not work. It shows the same page again and again. Also, it does not show the entire JTable data, but only some of them and I can't figure out why.
Below is my two classes.
TestPreview.java
package printpreviewdemo;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
[Code] ....
Below are my screenshots.
View Replies
View Related
Aug 12, 2014
I've got to make a ball bounce around a screen.... From what I can gather they seem to hold back useful java code.
anyway, i've changed the code over and over, and think this is the most succinct way i can manage it. but i have a problem. where i've marked the code (*****) and the following line are conditional on each other. so one won't provide the correct answer without the other line executing first, and vice versa (ignore the code after, i haven't looked at where that should be yet ). Anyway I don't really want to rip the code apart, again, because i'm pretty sure it's close.
View Replies
View Related
Sep 26, 2014
I developed a swing application using group layout. It resizes when I resize the frame but when I change the screen resolution or when I run the application in a laptop which has small sized screen, the components over lap each other. I need my application to fit according to the screen resolution
The code is as follows
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
[Code]...
According to the list item selected, an internal frame will appear in the desktop pane. I use group layout for that internal frame too.
View Replies
View Related
Jul 16, 2014
I want to make swing form full screen even on taskbar on linux machine. But after trying so hard unable to achieve it. I am using fedora as operationg system.
Below i am giving you my swing code. but whenever i run this file form comes up on the screen and waits for a second and it goes in background.
I am using linux OS Fedora 64 bit.
public class ThankYou {
JFrame f;
JTextArea nameField;
JLabel lable;
String str;
[Code] ....
View Replies
View Related
Mar 30, 2015
I'm working on Ubuntu with resolution 1600*900; I used MigLayout to place the components of the application; but when I go with higher resolutions,components adjustment and alignment are not up to the mark.
View Replies
View Related
Mar 16, 2015
I'm making a game of checkers for my A2 Computing coursework which is due in within a week. I have completely finished the game, and only thing I have left to do is connect the two JPanels together via a CardLayout that I have made. However I am unsure how to do so
Here is the code from my CardLayout:
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;
[Code] ....
I have kept the code I am displaying to a minimal, hence I have removed all the action listeners for my buttons, anyway the problem I have is that, I would like it so that when the user clicks on the 'Multiplayer' button which is the array button ourButtons[1], it will then transition into my main game screen so that the user can then play a game of checkers.
Here is the main important GUI from my CheckerBoard class:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CheckerBoard extends JPanel implements ActionListener, MouseListener {
// Main routine that opens an Applet that shows a CheckerBoard
public static void main(String[] args) {
new CLayout();
[Code] ....
Once again kept to a minimal.
View Replies
View Related
Feb 8, 2014
When I click on a row in a JTable, I want to have a row appear above it. For now I'm just making that row be a duplicate of the row I clicked on, but eventually this will be some sort of previous history of that row, so as you are editing the row you actually clicked on you can look directly above it and see what the data used to look like.
I"m not having any problem creating the row, nor am I having an issue getting it positioned correctly. What I want to do with this added row is made it so you can't edit the entire row, and also really make this row stand out. I'd like to say make this row stand out or "POP" so to speak so there is no confusing what it is. I'd almost like to make it look like the row header or even better... Most of what I am seeing are ways to make particular cells uneditable, so I think my backup plan is that, but Is there a good way to do what I described?
View Replies
View Related
Jul 10, 2014
I'm having a hard time finding out the way to make JTextField editable. In what circumstances it can be disabled to write? [even the text in the field can't be selected, not to mention being uneditable. I did the followings to make it editable.
1. In its Properties panel(frame or whatever), checked the "editable" item.
2. In the code I made it run the code below :
void makeFieldsEditable(Boolean flag) {
Left_Name_field.setEditable(flag);
Left_Name_field.setEnabled(flag);
...
}
Is it related with the properties of the control(JTextField)'s surrounding panel, or even the largest containing frame? Using Netbeans ....
View Replies
View Related
Mar 19, 2014
how to make this restart button work. This is what I have so far. I have put the restart button code in red and bold...
package Game;
public class Buttons extends javax.swing.JPanel {
private GameWorld world;
private int restart;
[code]....
View Replies
View Related
Oct 29, 2005
Is it possible to make Expand/Collapsable panels in Java without writing huge amounts of code? I want something like this Expand/Collapse How would I go about it?
View Replies
View Related
Aug 16, 2014
I want to do a simple background which is only rendered once onto my screen. I want to use
G.fillRect(0, 0, getWidth(), getHeight());
and make the whole background black, but only once. I wanted to try out making the fillRect into a variable so I can do:
if (background == null) { //background is the variables name.
G.fillRect(0, 0, getWidth(), getHeight());
}
The point is, I want G.fillRect(0, 0, getWidth(), getHeight()); to be a variable, even if this is the wrong way to approach what I want to accomplish, is it possible to make this line of code into one variable? The rest of my code if you need info:
package com.game.blobber;
import java.util.Random;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
[Code] .....
View Replies
View Related
Apr 26, 2014
Here is an example of a GUI. Is it possible to make this kind of a thing using Java Swing? Is it possible to have a picture on the entire background of the JFrame, and then other Swing components like buttons, labels etc. sitting on it?Is it possible to have action listeners behind pictures? In other words, they will behave like buttons: the user clicks on them and they do something.
View Replies
View Related
Nov 12, 2014
make this button:
look more like this one:
I'm using GridLayout for my main JFrame.
View Replies
View Related
Sep 22, 2014
Is it possible to paint to the screen without using methods such as paint(), paintBorder(), paintChildren, paintBorder, paintComponent, paintAll() and any other paint like methods I may have missed. These are, by the way, taken both from JComponent and Component. So, is it possible?
View Replies
View Related
Apr 22, 2015
I've been reading that there's no way of making a JLabel user writable. What can I use inside the grid to make it writable with a keylistener? I'm making a crossword.
View Replies
View Related
Mar 15, 2014
I want to make installler for my client application in swing using exe4j but after making installer using exe4j When running the exe of application it gives me error as following
java.lang.NoClassDefFoundError: chrriis/dj/nativeswing/swtimpl/components/JFlashPlayer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)
[Code] ....
The source code of my project is as follows:
/*
* See the file "readme.txt" for information on usage and redistribution of this file
* And for a DISCLAIMER OF ALL WARRANTIES.
*/
package flash;
import java.awt.BorderLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import chrriis.common.UIUtils;
import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JFlashPlayer;
[Code] ....
View Replies
View Related
Jul 30, 2014
This is a part of my program. When the user enters "Exam Schedule" in the JtextField and clicks the add button I want the link to change to a link that opens a local pdf file. And if the user enters "Academic Calendar" the Jlabel will be set to another link. So far this works fine but the problem is that if you erase the textfield and enter another value the link of the previous value will still be there.
public void actionPerformed (ActionEvent e){
if (e.getSource ==add) {
if (text.getText().equalsIgnoreCase("Exam Schedule")){
link1.setText(text.getText());
link1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
[Code] .....
View Replies
View Related
Jun 29, 2007
How would you set a column in a JTable to make it unable to gain focus i.e. select the next column on the same row or ignore the command completely when selecting a column that should not be able to be gained focus on?
View Replies
View Related
Nov 12, 2014
I first need to draw this exact shape, which later I will have to make it move anti-clockwise, but for now, how to draw this thing:
First thing I can think of is drawArc, but not so sure...
View Replies
View Related